// JavaScript Document
<!--


 
function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}




function Delete_Cookie( name, path, domain ) {
document.cookie = name + "=" +
( ( path ) ? ";path=" + path : "") +
( ( domain ) ? ";domain=" + domain : "" ) +
";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}






function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}
				


function choose_layout(layout_id,default_bg_img,bg_box,select_radio) {
// default_bg_img: 0 if no img otherwise id of def img

 if (select_radio==1) document.getElementById('set_layout_id'+layout_id).checked =true;
	
 document.getElementById('bg_box').selectedIndex =bg_box;
 document.getElementById('layout_id').value=layout_id;

 if (document.getElementById('set_bg_img3').checked!=true) {
	 document.getElementById('bg_box').selectedIndex =0;
 	 if (default_bg_img==0) {
		   document.getElementById('set_bg_img1').checked=true;		   
	 }
	 else { 
	       document.getElementById('set_bg_img2').checked=true;
	 }
	 document.getElementById('filename_bg').disabled='disabled';
     //document.getElementById('bg_img_repeat').disabled='disabled';
     document.getElementById('bg_img_repeat').options[1].selected=true;
 }
 else document.getElementById('bg_box').selectedIndex =1; 
}


function scroll_layouts(start,selected_layout_id,direction,first_time,show_n_layouts) {
 // direction:0 scroll forward, 1 backward

	// define layout settings
    var default_bg_img = new Array('0','0','3','4','0','0','0','0','0','10','0','0','0','0','0');
	var bg_box =         new Array('0','0','1','0','0','0','0','0','0','0','0','0','0','0','0');
	var layout_name =    new Array('Domyślny','Black','Greenlay','Pinkish','Facelook','Olive','Spin102','Fresh ocean','Orange edge','Silver','Contra','Beyond','Red roots','Mild','Turkus');
   
	document.getElementById('display_layouts_inner').innerHTML='';
	k=0;
	// backward
	if (direction==1) { 
		if ((start-show_n_layouts)<1) {	new_start=default_bg_img.length +( start -show_n_layouts)-1;}
		else new_start=start-show_n_layouts-1;
		layout_id_back=new_start+1;
	} else {
		if ((start+1)>default_bg_img.length) layout_id_back=1;
		else layout_id_back=start+1;
	}
	
	for (i=0; i<show_n_layouts; i++) {
		
		  // scroll forward
		  if (direction==0) {
			if (start+k>=default_bg_img.length )  {
				start=0;
				k=0;
			}
            layout_id_index=start+k;
		    layout_id=layout_id_index+1;
            k++;
		  } else { // scroll backward
	
		    if (new_start+k>=default_bg_img.length )  {
				new_start=0;
				k=0;
			}
            layout_id_index=new_start+k;
		    layout_id=layout_id_index+1;
            k++;			  
			  
		 }
		  
		  
		if (selected_layout_id==layout_id) check_layout=' checked="checked" ';
		else check_layout='';
		
		document.getElementById('display_layouts_inner').innerHTML=document.getElementById('display_layouts_inner').innerHTML+'<div style="float:left;padding:0px 7px;"><div style="clear:both;"><a href="javascript:choose_layout('+layout_id+','+default_bg_img[layout_id_index]+','+bg_box[layout_id_index]+',1)" class="img_hover3"><img src="../../img/example_layouts/'+layout_id+'.jpg" width="100" border="0" height="75"></a></div><div style="clear:both;padding-top:2px;"><label><input name="set_layout" '+check_layout+' id="set_layout_id'+layout_id+'" type="radio" value="'+layout_id+'" onclick="choose_layout('+layout_id+','+default_bg_img[layout_id_index]+','+bg_box[layout_id_index]+',0)"  />'+layout_name[layout_id_index]+'</label></div><br /></div>';
		
	}
	document.getElementById('display_layouts_inner').innerHTML=document.getElementById('display_layouts_inner').innerHTML+'<div class="clear-both2"></div>';
	 

	 if (first_time==0) {
		 document.getElementById('scroll_layouts_lnk').setAttribute('href', 'javascript:scroll_layouts('+layout_id+',0,0,0,'+show_n_layouts+');');
		 document.getElementById('scroll_layouts_lnk2_c').style.display='block';
		 document.getElementById('scroll_layouts_lnk2').setAttribute('href', 'javascript:scroll_layouts('+layout_id_back+',0,1,0,'+show_n_layouts+');');
	 }
}

 
function fullScreen(theURL) {
window.open(theURL, 'pomocvideo', 'fullscreen=no, scrollbars=yes,resizable=1,width=1204,height=820');
}


//pop up windows

function displayWindow(url, width, height) {
        var Win = window.open(url,"Nadajemy_Info",'width=' + width + ',height=' + height + ',resizable=0,scrollbars=yes,menubar=no,left=200,top=200' );
}


function showterms() {
	displayWindow('/include_files/regulamin_small.php',500,450)
}
 
 

function check_browser() {

	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
       browser='FF';		
	} else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
	   browser='OPERA';
	} else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
	  browser='IE';	
    } else if (/chrome/.test(navigator.userAgent.toLowerCase() )) {
	  browser='CHROME';
	}
	else browser='UNKNOWN';
	 
 return browser;
	
}




// auto minimize window	if blank
function auto_min_box(element_id,def_height,def_class,def_text) {
	if (document.getElementById(element_id).value=='') {
		document.getElementById(element_id).className = def_class;
		document.getElementById(element_id).value=def_text;
		document.getElementById(element_id).style.height=def_height; 
	}	
}


 
// auto expand window if clicked
function auto_expand_box(element_id,def_height,min_class,max_class) {
  if ( document.getElementById(element_id).className == min_class)  {
	   document.getElementById(element_id).className = max_class;
	   document.getElementById(element_id).value=''; 
	   document.getElementById(element_id).style.height=def_height;
	 }
}
	
	
// auto adjust window when entering text
function auto_adjust_box(element_id,min_height) {
   
    
   browser_name= check_browser();
   
   
   if ((browser_name!='IE')&&(browser_name!='OPERA')) {
		  document.getElementById(element_id).style.height=min_height+'px';
   }
   
   if (browser_name=='CHROME') { h_fix=4;  } // chrome shows 4px more than min_height
   else {h_fix=0;}
   
   comp_min_height=(min_height*1)+h_fix;
   
    
   if ((document.getElementById(element_id).scrollHeight*1) <= comp_min_height) {
	   document.getElementById(element_id).style.height=min_height+'px';
   }
   else {
     document.getElementById(element_id).style.height=(document.getElementById(element_id).scrollHeight*1) + 24  + 'px';	
   }
}	


//-->