function errorsuppressor(){
	return true;
}
window.onerror=errorsuppressor;

var isIE = false;

function getHTTPObject() {
	var xmlhttp;

	if (window.XMLHttpRequest) {
		xmlhttp = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		isIE = true;
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(err1) {
			try {
				xmlhttp = new ActiveXObject("Msml2.XMLHTTP");
			} catch(err2) {
				xmlhttp = false;
			}
		}
	}
    
	return xmlhttp;
}

function vyplnObjednavku(){
  http = getHTTPObject();
  if (http) { 
		http.open("GET", "/user/vyplneniObjednavky.php?rand="+(Math.random()*9), false);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(null);
			
	  doVyplneniObjednavkyOutput();;
	} 
}

function vyplnObjednavkuKlientem(id){
  http = getHTTPObject();
  if (http) { 
		http.open("GET", "/user/vyplneniObjednavky.php?klient="+id+"&rand="+(Math.random()*9), false);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(null);
			
	  doVyplneniObjednavkyOutput();;
	} 
}

function doVyplneniObjednavkyOutput() {
	if (http.readyState == 4) {
	
		xmldoc = http.responseXML;
				
		if(!xmldoc) {
			return true;
		}
	  os_udaje = xmldoc.getElementsByTagName("vypis_osobnich_udaju");
	  
	  for(i=0; i<os_udaje[0].childNodes.length; i++){      
	    if (el = document.getElementById(os_udaje[0].childNodes[i].tagName)){
        el.value = os_udaje[0].childNodes[i].getAttribute("value");
      }
    } 
	}
}

/* slevove kody - overeni platnosti kodu */
function slevovyKodCheck() {
	
	// 8.8.2008 - vyrazeni slevovych kuponu
	// debugger;
	countOrderSum();	
	return;
	/*
	var el 				= document.getElementById('slevovy_kod');
	var objSlevaCastka = document.getElementById('slevovy_kod_sleva_castka2');
	var objRow 			= document.getElementById('slevovy_kod_sleva');
	var objSlevaKod 	= document.getElementById('slevovy_kod_sleva_kod');
	var msg				= document.getElementById('slevovy_kod_msg');
	
	if(el.value.length == 8) {
		var data = 'slevovy_kod=' + encodeURIComponent(el.value);
		
		var req = getHTTPObject();
		if (req) {
			req.open("POST", "/inc/slevovyKodCheck.php?rand="+(Math.random()*9), true);
			req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			req.send(data);

			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					//alert(req.responseText);
    				xmldoc = req.responseXML;
    				
					if(!xmldoc) {
						msg.innerHTML = 'Litujeme, ale platnost kódu se nepodařilo ověřit.';
					}
					
					kodEl = xmldoc.getElementsByTagName("kod").item(0);
					kod = kodEl.firstChild.nodeValue;
					
					stavEl = xmldoc.getElementsByTagName("stav").item(0);
					stav = stavEl.firstChild.nodeValue;

					el.value = kod;
					
					if(stav == "VALID") {
						
						objSlevaCastka.value = 0;
						countOrderSum();
						
						// cenikova polozka se slevou
						objSlevaKod.innerHTML = kod;
						
						celkemCastkaEl = document.getElementById('obj_celkova_suma');
						celkovaCastka = parseInt(celkemCastkaEl.value);
						sleva = -Math.ceil(celkovaCastka*0.02);
						if(sleva < -1000) {
							sleva = -1000;
						}
						
						objSleva = document.getElementById('slevovy_kod_sleva_castka');
						objSleva.innerHTML = sleva == -1000 ? '-1 000' : String(sleva);
						objSlevaCastka.value = sleva;
						countOrderSum();
						
						msg.innerHTML = 'Zadaný kód je platný. Bude vám přiznána sleva ve výši 2%, max. 1 000 Kč.';
						msg.className = 'ok';
						
						if(isIE) {
							objRow.style.display = "block";
						}
						else {
							objRow.style.display = "table-row";
						}
						
					}
					else if(stav == "USED") {
						msg.innerHTML = 'Litujeme, ale tento kód byl již uplatněn.';
					}
					else {
						msg.innerHTML = 'Litujeme, ale tento kód není platný. V případě uplatňování dárkových poukazů, uveďte jejich čísla do poznámky v objednávce.';
					}
				}
			};
		}
	}
	else {
		objSlevaCastka.value = 0;
		countOrderSum();
		objRow.style.display = "none";
		if(el.value.length > 0) {
			msg.innerHTML = 'Litujeme, ale tento kód je neúplný nebo není platný. V případě uplatňování dárkových poukazů, uveďte jejich čísla do poznámky v objednávce.';
			msg.className = 'err';
		}
		else {
			msg.innerHTML = '';
		}
	}
	//*/
}

/* slevove kody - konec */


function set_position(id,podle,co,oco) {
  if (co == "top"){
    document.getElementById(id).style.top=document.getElementById(podle).offsetTop+oco+"px";
  }
  else if (co=="left"){
     document.getElementById(id).style.left=document.getElementById(podle).offsetLeft+oco+"px"; 
  }
  
}

function clearBackground(id){
  if (el = document.getElementById(id)) {
    el.style.background = "white";
  }
}

function headerQuestionOn(){
  el = document.getElementById('header_question');
  if (el.style.visibility != "visible")
    el.style.visibility = "visible";
}

function headerQuestionOff(){
  el = document.getElementById('header_question');
  if (el.style.visibility != "hidden")
    el.style.visibility = "hidden";
}

function headerOperatorkaOn(){
  el = document.getElementById('header_operatorka');
  if (el.style.visibility != "visible")
    el.style.visibility = "visible";
}

function headerOperatorkaOff(){
  el = document.getElementById('header_operatorka');
  if (el.style.visibility != "hidden")
    el.style.visibility = "hidden";
}

var elToFluentVisible;

function fluentVisible()
{
	for (var i=0;i<11;i++)
		setTimeout('setOpacity('+i+')',100*i);
	return false;
}

function setOpacity(value)
{
	elToFluentVisible.style.opacity = value/10;
	elToFluentVisible.style.filter = 'alpha(opacity=' + value*10 + ')';
}

var last_global_id;
function menu_on(id) {
	for(i=1;i<8;i++) {
		if(i!=id) {
			if (el = document.getElementById('menu'+String(i)))
        el.style.visibility="hidden";
        last_global_id = null;
		}
	}
	el = document.getElementById('menu'+String(id));
	last_global_id = el;
  setTimeout(function(){
  	if (el && last_global_id == el){	 
  	 el.style.visibility="visible";
  	 last_global_id = el;
  	}
  },500);
}

function menu_off(id) {
	if (el = document.getElementById('menu'+String(id)))
    el.style.visibility="hidden";
}

function userShowDestinace() {
	var obj = document.forms['user_setup_form'].elements['zeme[]'];
	var el;
	for(var i=0; i<obj.options.length;i++) {
		if (el = document.getElementById('d_'+String(obj.options[i].value))) {
			if(obj.options[i].selected==true) {
				el.style.display="block";
			}
			else {
				el.style.display="none";
			}
		}
	}
}

function userShowFirstSelectedListItem() { 
	f = document.forms['user_setup_form'];
	for (i=0;i<f.elements.length;i++) { 
		if (f.elements[i].type.indexOf('select')==0) { 
			f.elements[i].options[f.elements[i].selectedIndex].selected=true; 
		}
	}
} 

function zobrazNastupniMista(limit) {
	for(var i=1; i<=limit; i++) {
		if(document.getElementById('nm_'+String(i)).style.display=="none") {
			document.getElementById('nm_'+String(i)).style.display="block";
		}
		else {
			document.getElementById('nm_'+String(i)).style.display="none";
		}
	}
}

var win=null;
function newWindow(mypage,myname,w,h,scroll,pos){
	if(pos=="random"){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	if(pos=="center"){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	else if((pos!="center" && pos!="random") || pos==null){
		LeftPosition=0;
		TopPosition=20
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
	win=window.open(mypage,myname,settings);
}


function showImage(url, width, height){
	if(!width) width=600;
	if(!height) height=500;
	
	newWindow('http://www.zajezdy.cz/showImage.php?img='+url, 'ImgWindow', width, height, 'no', 'center');
}

function showImageText(url, width, height, text){
	if(!width) width=600;
	if(!height) height=500;
	
	newWindow('http://www.zajezdy.cz/showImage.php?img='+url+'&text='+text, 'ImgWindow', width, height, 'no', 'center');
}

function showPoukaz(url){
	settings='width=800,height=600,top=0,left=0,scrollbars=yes,location=no,directories=no,status=no,menubar=yes,toolbar=no,resizable=yes';
	win=window.open('http://www.zajezdy.cz/poukazy/showImage.php?img='+url, 'ImgWindow',settings);	
}

function showPoukaz(url){
	settings='width=800,height=600,top=0,left=0,scrollbars=yes,location=no,directories=no,status=no,menubar=yes,toolbar=no,resizable=yes';
	win=window.open('http://www.zajezdy.cz/poukazy/showImage.php?img='+url, 'ImgWindow',settings);	
}

function openSelectWindow(page) {
	var selectedOption = document.forms['sbsForm'].elements['parametr'].options[document.forms['sbsForm'].elements['parametr'].selectedIndex].value;
	newWindow(page+'&action=select&parametr='+selectedOption, 'SelectWindow', 700, 400, 'yes', 'center');
}

function openSelectWindow2(page) {
	newWindow(page, 'SelectWindow', 700, 400, 'yes', 'center');
}

function openHelp(display) {
	newWindow('/help.php?display='+display, 'HelpWindow', 800, 400, 'yes', 'center');
}

function searchDelkaGroup() {
	var groups = document.forms['param_form'].elements['delka_group[]'];
	var delky = document.forms['param_form'].elements['delka[]'];
	
	if (!groups.length) {
		checked = groups.checked;
		parts = groups.value.split(',');
		lb = parseInt(parts[0]);
		ub = parseInt(parts[1]);
		
		if (!delky.length) {
			delky.checked = checked;
		}
		else {
			for (var x=0; x<delky.length; x++) {
				d = parseInt(delky[x].value);
				if (lb <= d && d <= ub) {
					delky[x].checked = checked;
				}
			}
		}
	}
	else {
		for (var i=0; i<groups.length; i++) {
			checked = groups[i].checked;
			parts = groups[i].value.split(',');
			lb = parseInt(parts[0]);
			ub = parseInt(parts[1]);
			
			for (var x=0; x<delky.length; x++) {
				d = parseInt(delky[x].value);
				if (lb <= d && d <= ub) {
					delky[x].checked = checked;
				}
			}
		}
	}
}

function countOrderSum() {
	var sum = 0;	
	var regexp = /[^0-9]/;
	var val = '';
	var form = document.forms['obj_form'];
	var ceny = form.elements['ceny[]'];
	var hodnoty = form.elements['hodnoty[]'];
	
	if (!ceny.length) {
		val = hodnoty.value;
		hodnoty.value = val.replace(regexp, '');
		nasobek = hodnoty.value == "" ? parseFloat(0) : parseFloat(hodnoty.value);
		cena = parseFloat(ceny.value);
		sum += (cena*nasobek);
	}
	else {
		for(i=0; i < ceny.length; i++) {
			val = hodnoty[i].value;
			hodnoty[i].value = val.replace(regexp, '');
			nasobek = hodnoty[i].value == "" ? parseFloat(0) : parseFloat(hodnoty[i].value);
			cena = parseFloat(ceny[i].value);
			sum += (cena*nasobek);
		}
	}
	
	ceny = form.elements['ceny_skipasy[]'];
	hodnoty = form.elements['hodnoty_skipasy[]'];	
    
  if (ceny && hodnoty) {  
  	if (!ceny.length) {
  		val = hodnoty.value;
  		hodnoty.value = val.replace(regexp, '');
  		nasobek = hodnoty.value == "" ? parseFloat(0) : parseFloat(hodnoty.value);
  		cena = parseFloat(ceny.value);
  		sum += (cena*nasobek);
  	}
  	else {
  		for(i=0; i < ceny.length; i++) {
  			val = hodnoty[i].value;
  			hodnoty[i].value = val.replace(regexp, '');
  			nasobek = hodnoty[i].value == "" ? parseFloat(0) : parseFloat(hodnoty[i].value);
  			cena = parseFloat(ceny[i].value);
  			sum += (cena*nasobek);
  		}
  	}	
	}
	
	
	ceny = form.elements['ceny_pojisteni[]'];
	hodnoty = form.elements['hodnoty_pojisteni[]'];	
    
  if (ceny && hodnoty) {  
  	if (!ceny.length) {
  		val = hodnoty.value;
  		hodnoty.value = val.replace(regexp, '');
  		nasobek = hodnoty.value == "" ? parseFloat(0) : parseFloat(hodnoty.value);
  		cena = parseFloat(ceny.value);
  		sum += (cena*nasobek);
  	}
  	else {
  		for(i=0; i < ceny.length; i++) {
  			val = hodnoty[i].value;
  			hodnoty[i].value = val.replace(regexp, '');
  			nasobek = hodnoty[i].value == "" ? parseFloat(0) : parseFloat(hodnoty[i].value);
  			cena = parseFloat(ceny[i].value);
  			sum += (cena*nasobek);
  		}
  	}	
	}
	
	form.elements['celkem'].value = sum;
	
	target = document.getElementById('obj_celkova_suma_1');
	target.innerHTML = formatNumber(sum);
}

function orderAmount(el) {
	if(el.value == '0') {
		el.value = '';
		el.focus();
	}
}

function formatNumber(n, d) {
	// round to 2 decimals if cents present
   n = (Math.round(n * 100) / 100).toString().split('.');
  	myNum = n[0].toString();
	fmat = new Array();
	len = myNum.length;
	d = d == null ? ' ' : d;
	i = 1;
	deci = ',';
  for(i; i < len + 1; i++) fmat[i] = myNum.charAt(i-1);

	fmat = fmat.reverse();
	for(i = 1; i < len; i++)
	{
		if(i % 3 == 0) {
		fmat[i] += d;
		}
	}
	var val = fmat.reverse().join('') +
	 ( n[1] == null ? '' :
	   (deci + n[1])
	 );
	return val;
}

function kontrola(formular) {
	if (formular.celkem.value==0 || formular.celkem.value=='') {
		alert("Nezadali jste žádné údaje pro výpočet ceny!");
		return false;
	}
	if (formular.jmeno.value=="") {
		alert("Jméno je nutné vyplnit!");
		formular.jmeno.focus();
	 	return false;
	}
	if (formular.prijmeni.value=="") {
		alert("Příjmení je nutné vyplnit!");
	 	formular.prijmeni.focus();
	 	return false;
	}
	if (formular.ulice.value=="") {
		alert("Ulici je nutné vyplnit!");
		formular.ulice.focus();
		return false;
	}
	if (formular.cp.value=="") {
		alert("Číslo popisné je nutné vyplnit!");
		formular.cp.focus();
		return false;
	}
	if (formular.obec.value=="") {
		alert("Obec je nutné vyplnit!");
		formular.obec.focus();
		return false;
	}
	if (formular.psc.value=="") {
		alert("PSČ je nutné vyplnit!");
		formular.psc.focus();
		return false;
	}
	if (formular.pocet_dospelych.value=="") {
		alert("Počet dospělých je nutné vyplnit!");
		formular.pocet_dospelych.focus();
		return false;
	}
	if (formular.pocet_deti.value=="") {
		alert("Počet dětí je nutné vyplnit!");
		formular.pocet_deti.focus();
		return false;
	}
	if (formular.telefon.value=="") {
		alert("Telefon je nutné vyplnit!");
		formular.telefon.focus();
		return false;
	}
	if (formular.email.value=="") {
		alert("E-mailovou adresu je nutné je nutné vyplnit!");
		formular.telefon.focus();
		return false;
	}
	return true;
}

function clipboardChange(idZ, activeTab) {
  
  if (activeTab)
    activateTab(zakaznik_tabs_pos['schranka'], 'zakaznik_tabs');

	var action = 'add';
	if (document.images) {
		if (document.images['schranka_'+String(idZ)].src.indexOf('add') > 0) {
			action = 'add';
			document.images['schranka_'+String(idZ)].src = '/img/schranka_text_remove.gif';
		}
		else {
			action = 'remove';
			document.images['schranka_'+String(idZ)].src = '/img/schranka_text_add.gif';
		}
	}
	http = getHTTPObject();
	if (http) {
		http.open("GET", '/clipboard.php?action='+action+'&zajezd_id='+String(idZ)+'&rand='+(Math.random()*9), false);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(null);

		if (http.readyState == 4) {
			if (el = document.getElementById('schranka_pocet_z')){
				el.innerHTML = http.responseText;
			}

			/* if (el = document.getElementById('zakaznik_tabs:tab'+zakaznik_tabs_pos['registrace'])) {
			if ( http.responseText == 0) el.style.display='';
			else el.style.display='none';
			}

			if (el = document.getElementById('zakaznik_tabs:tab'+zakaznik_tabs_pos['schranka'])) {
			if (http.responseText == 0 &&
			document.getElementById('zakaznik_tabs:tab'+zakaznik_tabs_pos['registrace']))
			el.style.display='none';
			else
			el.style.display='';
			} */

			if ( http.responseText != 0){
				//activateTab(zakaznik_tabs_pos['schranka'],'zakaznik_tabs');
				document.getElementById('schranka_ul').className = 'active_href';
			}
			else {
				/*if (document.getElementById('zakaznik_tabs:tab'+zakaznik_tabs_pos['registrace']))
				activateTab(1,'zakaznik_tabs');*/
				document.getElementById('schranka_ul').className = 'non_active_href';
			}
		}
		propagateScript('/clipboard.php?action='+action+'&zajezd_id='+String(idZ)+'&rand='+(Math.random()*9));
	}
	return false;
}
function clipboardClear(){
	if (document.getElementById('schranka_pocet_z').innerHTML != '0'){
		if (confirm('Opravdu chcete vymazat obsah schránky?')){
			http = getHTTPObject();
			if (http) {
				http.open("GET", "/clipboard.php?action=clear&rand="+(Math.random()*9), false);
				http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				http.send(null);

				if (http.readyState == 4) {
					if (el = document.getElementById('schranka_pocet_z')){
						el.innerHTML = '0';

						var zaj_ids = http.responseText.split(";");

						for(var i=0; i<zaj_ids.length; i++) {
							if (el = document.getElementById('schranka_'+zaj_ids[i])) {
								el.src = '/img/schranka_text_add.gif';
							}
						}
					}
					if (el = document.getElementById('schranka_ul')){
						el.className = 'non_active_href';
					}
					/*          if (el = document.getElementById('zakaznik_tabs:tab'+zakaznik_tabs_pos['registrace']))
					if (el2 = document.getElementById('zakaznik_tabs:tab'+zakaznik_tabs_pos['schranka'])) {
					el2.style.display='none';
					el.style.display='';
					activateTab(1,'zakaznik_tabs');
					} */
				}
			}
			
			propagateScript('/clipboard.php?action=clear&rand='+(Math.random()*9));
		}
	}
	return false;
}
function clipboardView() {
  if (document.getElementById('schranka_pocet_z').innerHTML != '0'){
    http = getHTTPObject();
    if (http) { 
      http.open("GET", "/clipboard.php?action=view&rand="+(Math.random()*9), false);
      http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
      http.send(null);
      
      if (http.readyState == 4) {
        window.location = '/zajezdy/?schranka='+http.responseText;
      } 		
    } 
  }
  return false;
}
function clipboardEmail() {
  if (document.getElementById('schranka_pocet_z').innerHTML != '0'){
    newWindow('/clipboard.php?action=mail_form', 'SchrankaWindow', 300, 260, 'yes', 'center');
  }
  return false;
}


function aheadPositionChange() {
	if (document.getElementById("banner_ahead")) {
		if(el = document.getElementById("menu_main")) {
			el.style.top = "115px";
		}
		if(el = document.getElementById("new_logo_hp")) {
			el.style.top = "144px";
		}
		if(el = document.getElementById("menu_shadow")) {
			el.style.top = "133px";
		}
		if(el = document.getElementById("site_map")) {
			el.style.top = "245px";
		}
		if(el = document.getElementById("rc")) {
			el.style.top = "262px";
		}
		if(el = document.getElementById("soutez_zbozi_upoutavka")) {
			el.style.top = "195px";
		}
		if(el = document.getElementById("header_upoutavka")) {
			el.style.top = "195px";
		}
		if(el = document.getElementById("header_upoutavka_akce")) {
			el.style.top = "150px";
		}
		if(el = document.getElementById("content_headline")) {
			el.style.top = "117px";
		}
		if(el = document.getElementById("header_pojisteni")) {
			el.style.top = "156px";
		}
	}
}

function setCookie (name, value, expires) {
   document.cookie = name + "=" + escape (value) +
     ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +  "; path=/";
}
function getCookieVal (offset) {
   var endstr = document.cookie.indexOf (";", offset);
   if (endstr == -1)
      endstr = document.cookie.length;
   return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
   var arg = name + "=";
   var alen = arg.length;
   var clen = document.cookie.length;
   var i = 0;
   while (i < clen) 
      {
      var j = i + alen;
      if (document.cookie.substring(i, j) == arg)
         return getCookieVal (j);
      i = document.cookie.indexOf(" ", i) + 1;
      if (i == 0) 
         break; 
      }
   return null;
} 

function colorIt(element, switchOn) {
	if (switchOn) {
		pom=element.className;
		element.className = pom + " el_hover";
	} else {
		element.className=pom;
	}
}

// funkce pro zalozky 

var prevTab = new Array(); // pole kde se uladaji cisla predchozich zalozek

function activateTab(tabNo, tabbed_pane_id, tabContent) {
  document.getElementById(tabbed_pane_id + ':close').style.display = 'block';
  el = document.getElementById(tabbed_pane_id + ':tab1');
  active = '';
  if (el.parentNode.className.indexOf('blue') >= 0) {
    active = 'active_b';
  }
  else {
    active = 'active_o';
  }
	var tNo = parseInt(tabNo);
	var i = 1;
	while (el = document.getElementById(tabbed_pane_id + ':tab' + i)) {
		el.className = i == tNo ? active : '';
		i++;
	}
	var elem;
	if (prevTab[tabbed_pane_id] != 100)
    document.getElementById(tabbed_pane_id+":content"+prevTab[tabbed_pane_id]).style.display = 'none';      
  document.getElementById(tabbed_pane_id + ':content' + tabNo).style.display = 'block';
	prevTab[tabbed_pane_id] = tabNo;
	setCookie(tabbed_pane_id,tabNo);
	setVyskaLevehoSloupce();
}

function tabOver(el) {
  over = '';
  if (el.parentNode.className.indexOf('blue') >= 0) {
    over = 'over_b';
  }
  else {
    over = 'over_o';
  }
	if (el.className.indexOf('active') < 0) {
		el.className = over;
	}
}

function tabOut(el, side) {
	if (el.className.indexOf('active') < 0) {
		el.className = side;
	}
} 
function dispAtiveContent(tabbed_pane_id){
  var i = 1;
  var el = null;
  el = document.getElementById(tabbed_pane_id + ':tab' + i);
 	while (el &&  el.className.indexOf('active') < 0) {
		i++;
		el = document.getElementById(tabbed_pane_id + ':tab' + i);
	} 
	if (el){
    document.getElementById(tabbed_pane_id+":content"+i).style.display = 'block';
    prevTab[tabbed_pane_id] = i;
    if (tabbed_pane_id == 'hledani_tabs' && i==2) {
    	ssfReload();
    }
  }
	else {
	  prevTab[tabbed_pane_id] = 100;
	  if (getCookie(tabbed_pane_id) < 100) 
      activateTab(1,tabbed_pane_id);
    else 
      document.getElementById(tabbed_pane_id + ':close').style.display = 'none';
  }
}
function closeTabbedPane(tabbed_pane_id){
  document.getElementById(tabbed_pane_id + ':close').style.display = 'none';
  var i = 1;
 	while (el = document.getElementById(tabbed_pane_id + ':tab' + i)) {
		el.className = '';
		i++;
	} 
	if (prevTab[tabbed_pane_id] != 100)
    document.getElementById(tabbed_pane_id+":content"+prevTab[tabbed_pane_id]).style.display = 'none';
	setCookie(tabbed_pane_id,100);
	prevTab[tabbed_pane_id] = 100;
}
// end - funkce pro zalozky

  // this function returns the x, y position
 // works in IE and Mozilla.
function getElementPosition(element){
  var x=0,y=0;
  while (element!=null){
    x+=element.offsetLeft;//-element.scrollLeft;
    y+=element.offsetTop;//-element.scrollTop;
    element=element.offsetParent;
  }
  return {x:x,y:y};
}

function setAdFoxPosition(main_id, main_old_y){

    //alert(main_id);

    if ((adFox = document.getElementById('ban760')) && adFox.className.indexOf('af_760')){
      elm1 = document.getElementById('urceni_vysky_menu');
      elm2 = document.getElementById('urceni_vysky_main');
      
      menuYpos = getElementPosition(elm1).y;
      mainYpos = getElementPosition(elm2).y;
      
      //alert("(" + main_old_y + " + " + adFox.offsetHeight + ") >= " + "(" + (menuYpos+4) + ")");
      
      if ((main_old_y + adFox.offsetHeight) >= (menuYpos+4)){
        adFox.style.position = 'static';
        if (navigator.appName != "Microsoft Internet Explorer")  {
            mainx = document.getElementById(main_id);        
            mainx_vyska = main_old_y + adFox.offsetHeight -
              getElementPosition(mainx).y + 5;
            mainx.style.height = mainx_vyska + "px";
        }
      }
      else {
        elm1Y = elm1.offsetTop;
        adFoxY = adFox.offsetTop;  
        if (navigator.appName=="Microsoft Internet Explorer")  {
          elm1Y = elm1.offsetTop;
          adFox.style.position = 'absolute';
          adFox.style.left = '0px';
          adFoxNewTop = elm1Y - adFox.offsetHeight - 24;  
        }
        
        else {
          adFox.style.position = 'relative';
          adFoxOldTop = parseInt(adFox.style.top);
          if (!adFoxOldTop) adFoxOldTop = 0;
          adFoxNewTop = adFoxOldTop + elm1Y - adFoxY - adFox.offsetHeight - 14;
          //alert("adFoxOldTop = "+adFoxOldTop+"\nadFoxNewTop = "+adFoxNewTop+"\nelm1Y = "
          // +elm1Y+"\nadFox.offsetHeight = "+adFox.offsetHeight+"\nadFoxY = "+adFoxY);
        }
        
        adFox.style.top = adFoxNewTop + "px";
      }
    } 
}

function setVyskaLevehoSloupce(){
  elm1 = document.getElementById('urceni_vysky_menu');
  elm2 = document.getElementById('urceni_vysky_main');

  elm1Y = getElementPosition(elm1).y;
  elm2Y = getElementPosition(elm2).y;
   
  //alert(elm1Y + " -- " + elm2Y);
   
  if (elm2Y < elm1Y+4){
    var mainx;
    if (!(mainx = document.getElementById('main_outer')))
      if (!(mainx = document.getElementById('main_outer_index')))
        if (!(mainx = document.getElementById('main_outer_results')))
          if (!(mainx = document.getElementById('user_main_outer')));    
    
    //alert('mainx.id = '+mainx.getAttribute('id')+'\n' + elm1Y + " -- " + elm2Y);
    elm1Y = elm1Y - 7;
    
    mainx_vyska = elm1Y - getElementPosition(mainx).y;
    mainx.style.height = mainx_vyska + "px";
        
    setTimeout("setAdFoxPosition('"+mainx.getAttribute('id')+"', "+elm2Y+")",500);
  }  
}
function setMinSirka() {
  if (screen.width < 820){
  	var mainx;
  	if (!(mainx = document.getElementById('main_outer')))
  	 if (!(mainx = document.getElementById('main_outer_index')))
  	    if (!(mainx = document.getElementById('main_outer_results')))
  	      if (!(mainx = document.getElementById('user_main_outer')));
                      
  	h_img = document.getElementById("header_img");
  	el_rc = document.getElementById("rc");
  	if (mainx) {  	
  		mainx.style.width = '700px';
    }						
  	if (el_rc) {
  		el_rc.style.left = '712px';
  	}
  	if (h_img) {
      h_img.style.width = '965px';     
    }  
  }
}



function nerozhodujeClick(formName, elName, nerozhoduje){
	var chL = document.forms[formName].elements[elName].length;
	if (nerozhoduje) {
		document.forms[formName].elements[elName][0].checked = true;
		var i = 1;
		while(i<chL) {
			document.forms[formName].elements[elName][i].checked = false;
			i++;
		}
	}
	else {
		document.forms[formName].elements[elName][0].checked = false;
	}
}


function propagateScript(url) {
	var hosts = new Array('www.cestovni-kancelare.cz', 'www.zajezdy.cz', 'www.last-minute.cz');
	var host;
	
	for(i=0;i<hosts.length;i++) {
		host = hosts[i];
		if(host.indexOf(document.domain) < 0) {
			document.requestImg.src = 'http://' + host + url;
		}
		
	}
	
}
function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 8;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
function screenWidth() {
  var myWidth = 0;
  if (typeof( window.innerWidth ) == 'number') {
    myWidth = window.innerWidth;
  } 
  else if (document.documentElement && document.documentElement.clientWidth) {
    myWidth = document.documentElement.clientWidth;
  } 
  else if (document.body && document.body.clientWidth) {
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

// zapnuti animovaneho scrollovani
$(document).ready(function() {
  function filterPath(string) {
    return string
      .replace(/^\//,'')  
      .replace(/(index|default).[a-zA-Z]{3,4}$/,'')  
      .replace(/\/$/,'');
  }
  $('#main a[href*=#].animScroll').each(function() {
    if ( filterPath(location.pathname) == filterPath(this.pathname)
    && location.hostname == this.hostname
    && this.hash.replace(/#/,'') ) {
	     $(this).click(function() {
	       var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
	  	   var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
	       var targetOffset = $target.offset().top;
	       if ($target) {
	       	 $('html, body').animate({scrollTop: targetOffset}, 400);
	         return false;
	       }
	     });
	    var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
	  	var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
	    var targetOffset = $target.offset().top;
	  	if ($target) {
	       if ($(this).offset().top < targetOffset) {
	       	// odkaz smeruje na stejne strane smerem dolu
		   		$(this).css("text-decoration","none");
		   		$(this).html('<span style="padding-left: 8px;" title="níže na této stránce" class="icon-down2">&nbsp;</span><font style="text-decoration: underline;">'
				   +$(this).html()+'</font>');
		   }
	       else { // nahoru
		   		$(this).css("text-decoration","none");
		   		$(this).html('<span style="padding-left: 8px;" title="výše na této stránce" class="icon-up2">&nbsp;</span><font style="text-decoration: underline;">'
				   +$(this).html()+'</font>');
		   }
	  	}
	     
    }
  });
});

// odkazy do noveho okna s ikonkou
$(document).ready(function() {
	makeNewWinIcons();
	setInterval("makeNewWinIcons()", 1000);
});
function makeNewWinIcons() {
	$('#show_BETA a[target*=blank]:not([class~=normal])').each(function() {
		if ($(this).children($('font[class*=icon-newwin]')).length < 2) {
			//pokud jeste nema ikonu, tak ji pridam
			$(this).css("text-decoration","none");
			$(this).html('<font style="text-decoration: underline;">' + $(this).html() 
			+'</font><font style="padding-right: 9px;" title="Stránka se Vám zobrazí v novém okně" class="icon-newwin">&nbsp;</font>');
		}
	});
}

// odkazy do noveho okna s ikonkou
$(document).ready(function() {
	$('#catalogue_data:not([class~=not_thru]) a').each(function() {
		if($(this).attr('name').length == 0) {
			if ($(this).attr('href').lastIndexOf('?') >= 0)
				$(this).attr('href', $(this).attr('href')+"&thru=cat");
			else 
				$(this).attr('href', $(this).attr('href')+"?thru=cat");
		}
	});
});

function online_check_result(termin_id, odkaz) {
	if($(odkaz).attr('disabled') == 'disabled') return false;
	$(odkaz).attr('disabled', 'disabled');
	if($("#online_check").length > 0) {
		$("#online_check").remove();
	}
	var $dialog = $('<div id="online_check"></div>').dialog({
		autoOpen: false,
		closeText: 'Zavřít',
		width: 400,
		title: 'Ověření dostupnosti online',
		beforeclose: function() { $(odkaz).removeAttr('disabled'); }
	});
	$dialog.dialog('open');	
	$dialog.html('<img src="/img/loading.gif" alt="" />');
    $.ajax({   
		type: "POST",
		url: '/inc/ajax/online_check/onlinecheck.php?hash='+randomString(),
		data: 'termin_id='+termin_id,
		success: function(ret){
			$dialog.html(ret);
		}
	});		
	return false;
}

function online_check_result_advanced(termin_id) {
	var data = $("#check_form").serialize();
	$("#online_check").html('<img src="/img/loading.gif" alt="" />');
    $.ajax({   
		type: "POST",
		url: '/inc/ajax/online_check/onlinecheck.php?advanced=1&hash='+randomString(),
		data: data+'&termin_id='+termin_id,
		success: function(ret){
			$("#online_check").html(ret);
		}
	});	
	return false;
}

function online_rezaportal_prebooking(termin_id) {
	var data = $("#check_form").serialize();
	$("#online_check").html('<img src="/img/loading.gif" alt="" />');
    $.ajax({   
		type: "POST",
		url: '/inc/ajax/online_check/rezaportal_prebooking.php?hash='+randomString(),
		data: data+'&termin_id='+termin_id,
		success: function(ret){
			$("#online_check").html(ret);
		}
	});	
	return false;
}

function addRoomsRows() {
	var count = $("#unit option:selected").val();
	$("#addedRooms").html(" ");
	for (var i=1; i <= count; i++) {
		$("#addedRooms").html($("#addedRooms").html() + 
		"<b>" + i + ".</b>&nbsp;&nbsp; Dospělí: <input type='text' name='adults[]' size='2' /> "
		+ " Děti: <input type='text' name='childs[]' size='2' /> "
		+ " Infanti: <input type='text' name='infants[]' size='2' /><br />"
		);
	}
}

// rozsiri jQuery o $.URLEncode(string) a $.URLDecode(string)
$.extend({URLEncode:function(c){var o='';var x=0;c=c.toString();var r=/(^[a-zA-Z0-9_.]*)/;
  while(x<c.length){var m=r.exec(c.substr(x));
    if(m!=null && m.length>1 && m[1]!=''){o+=m[1];x+=m[1].length;
    }else{if(c[x]==' ')o+='+';else{var d=c.charCodeAt(x);var h=d.toString(16);
    o+='%'+(h.length<2?'0':'')+h.toUpperCase();}x++;}}return o;},
URLDecode:function(s){var o=s;var binVal,t;var r=/(%[^%]{2})/;
  while((m=r.exec(o))!=null && m.length>1 && m[1]!=''){b=parseInt(m[1].substr(1),16);
  t=String.fromCharCode(b);o=o.replace(m[1],t);}return o;}
});



function askForOdjezd(odkaz, data) {
	if($(odkaz).attr('disabled') == 'disabled') return false;
	$(odkaz).attr('disabled', 'disabled');
	var $dialog = $('<div></div>').dialog({
		autoOpen: false,
		closeText: 'Zavřít',
		width: 400,
		title: 'Upřesněte termín odjezdu',
		beforeclose: function() { 
			$(odkaz).removeAttr('disabled'); 
			$dialog.html(" ");
		}
	});
	$dialog.dialog('open');	
	$dialog.html('<img src="/img/loading.gif" alt="" />');
    $.ajax({   
		type: "POST",
		url: '/inc/ajax/results_askForOdjezd.php?hash='+randomString(),
		data: data,
		success: function(ret){
			$dialog.html(ret);
			$("#dleCeny").click(function () {
				var znak = '&';
				if (odkaz.href.indexOf('?') < 0) znak = '?';
				var no_steps = odkaz.href.replace(/&steps=[^&]+/, "");
				window.location = no_steps + znak + $("#results_odjezdInterval").serialize();
			});
		}
	});		
	return false;
}


function sendMailDialog(odkaz, data) {
	if($(odkaz).attr('disabled') == 'disabled') return false;
	$(odkaz).attr('disabled', 'disabled');
	var $dialog = $('<div></div>').dialog({
		autoOpen: false,
		closeText: 'Zavřít',
		width: 400,
		title: 'Poslat informace o zájezdu e-mailem sobě nebo přátelům',
		beforeclose: function() { 
			$(odkaz).removeAttr('disabled'); 
			$dialog.html(" ");
		}
	});
	$dialog.dialog('open');	
	$dialog.html('<form id="submit_dialog"><label for="email_dialog"><b>Zaslat na e-mail:</b></label><br /><input type="text" name="email" id="email_dialog" style="width: 350px" /><br />'+
		'<label for="nick_dialog">Vaše jméno či přezdívka:</label><br /><input type="text" name="nick" id="nick_dialog" style="width: 350px" /><br />'+
		'<label for="text_dialog">Váš komentář:</label><br /><textarea style="width: 350px" name="comment" id="text_dialog"></textarea><br />'+
		'<input type="submit" value="Odeslat" /></form>');	
	$('#submit_dialog').submit(function() {
		data += '&'+$("#submit_dialog").serialize();
		$dialog.html('<img src="/img/loading.gif" alt="" />');
	    $.ajax({   
			type: "POST",
			url: '/inc/ajax/show_sendMail.php?hash='+randomString(),
			data: data,
			success: function(ret){
				$dialog.html(ret);
				setTimeout(function () { $dialog.dialog('close'); },4000);
			}
		});	
		return false;
	});
		
	return false;
}
