	$(document).ready(function(){
  $("#rozsirene a").click(function(){
    //$('#categorySel').selectbox({onChange: updateSearch, params: { }});
    //$('#placeSel').selectbox({onChange: updateSearch, params: { }});
    //$('#hotelSel').selectbox({onChange: updateSearch, params: { }});
    //$('#nightsSel').selectbox({onChange: updateSearch, params: { }});
    //$('#transportSel').selectbox({onChange: updateSearch, params: { }});
    //$('#foodSel').selectbox({onChange: updateSearch, params: { }});
    //$('#priceFromSel').selectbox({onChange: updateSearch, params: { }});
    //$('#priceToSel').selectbox({onChange: updateSearch, params: { }});
    //$('#starsSel').selectbox({onChange: updateSearch, params: { }});
    if ($("#expandSearchContent").is(":hidden")) {
        $("#expandSearchContent").slideDown("slow");
        document.getElementById('rozsirene').innerHTML = document.getElementById('rozsireneDown').innerHTML;
      } else {
        //$("#expandSearchContent").hide("slow");
      }
      return false;
    });

	$("#expand2").click(function(){
	    if ($("#locations2").is(":hidden")) {
	        $("#locations2").slideDown("slow");
	    }
	      return false;
	    });
	$("#collaps2").click(function(){
	    if ($("#locations2").is(":hidden")) {
	      } else {
	        $("#locations2").hide("slow");
	      }
	      return false;
	    });  
	$("#expand69").click(function(){
	    if ($("#locations69").is(":hidden")) {
	        $("#locations69").slideDown("slow");
	    }
	      return false;
	    });
	$("#collaps69").click(function(){
	    if ($("#locations69").is(":hidden")) {
	      } else {
	        $("#locations69").hide("slow");
	      }
	      return false;
	    });  
	$("#expand93").click(function(){
	    if ($("#locations93").is(":hidden")) {
	        $("#locations93").slideDown("slow");
	    }
	      return false;
	    });
	$("#collaps93").click(function(){
	    if ($("#locations93").is(":hidden")) {
	      } else {
	        $("#locations93").hide("slow");
	      }
	      return false;
	    });  
	$("#expand94").click(function(){
	    if ($("#locations94").is(":hidden")) {
	        $("#locations94").slideDown("slow");
	    }
	      return false;
	    });
	$("#collaps94").click(function(){
	    if ($("#locations94").is(":hidden")) {
	      } else {
	        $("#locations94").hide("slow");
	      }
	      return false;
	    });  
    if($('#krajina')) $('#krajina').selectbox({onChange: updateSearch, params: { }});
    if($('#krajina_1')) $('#krajina_1').selectbox({onChange: updateSearch, params: { }});
    if($('#miesto_1')) $('#miesto_1').selectbox({onChange: updateSearch, params: { }});
    if($('#krajina_2')) $('#krajina_2').selectbox({onChange: updateSearch, params: { }});
    if($('#miesto_2')) $('#miesto_2').selectbox({onChange: updateSearch, params: { }});
  
	$('.rounded').corner({ 
    	tl: { radius: 5 },
      tr: { radius: 5 },
      bl: { radius: 5 },
      br: { radius: 5 },
      antiAlias: true});
    try { $("#firsttermin").fixedHeader({width:600, height:340});} catch(err) {}
    $(".datepicker").datepicker({ altFormat: '@' });
           
//    opt.onChange = opt.onChange || false;
//    opt.params = opt.params || false;
    if (document.getElementById('firsttermin_body_container'))
    		document.getElementById('firsttermin_body_container').scrollTop= oldRows*24;
    
});
	function callbackFunction(obj) {
		alert(obj.selectedVal + ', ' + obj.action + ', ' + obj.another);
		}	

//globalne premenne aby som si ich mohol pozerat cez firebug
var terminRow;
var terminCol;
var posComb = new Array();
var sum = new Array;
var priceB = new Array();									// index je age_to obsah je suma
var priceC = new Array();									// index je 0adult 1kid 2kid2
var host;
var maxStep = 0;

// pokliku na "Objednaj" - zvolenie terminu
// nacita typy izieb a kompltne ceny
//1 krok
function chooseTermin(terminId, dates) {
//(date_start,date_exit) {
	//tx_rtcestovka_pi1[AJAX];
	maxStep = 1;
	step(1);
	document.getElementById('inputTermin').value = terminId;
	document.getElementById('formDate').innerHTML = dates;
	
//	document.getElementById('step1').style.backgroundImage="url(fileadmin/templates/img/number_bg_grey.gif)";
//	getAjax(host+"/index.php?id=6&no-cache=1&tx_rtcestovka_pi1[hotel]="+hotelID+"&tx_rtcestovka_pi1[AJAX]=1&tx_rtcestovka_pi1[date_start]="+date_start+"&tx_rtcestovka_pi1[date_exit]="+date_exit+"&L="+langId,2);
}

function step2(terminId) {
	maxStep = 2;
	step(2);
	getAjax(host+"/index.php?id=6&no-cache=1&tx_rtcestovka_pi1[hotel]="+hotelID+"&tx_rtcestovka_pi1[AJAX]=1&tx_rtcestovka_pi1[termin]="+terminId+"&L="+langId,2);
}

function checkOrderForm() {
   var name = document.shortOrder.name;
  var email = document.shortOrder.email;
   var phone = document.shortOrder.phone; 
   var adults = document.shortOrder.adults;
   var agree = document.shortOrder.agree;
  
   if (name.value == "")
   {
   	 if (enterName) window.alert(enterName);
   	 else
   		 window.alert("Prosím, zadajte Vaše meno.");
       name.focus();
       return false;
   }

    if (email.value == "")
   {
   	 if (enterEmail) window.alert(enterEmail);
   	 else
   		 window.alert("Prosím, zadajte Váš email.");
       email.focus();
       return false;
   }
   if (email.value.indexOf("@", 0) < 0)
   {
   	 if (enterRightEmail) window.alert(enterRightEmail);
   	 else
   	    window.alert("Prosím, zadajte správnu emailovú adresu.");
       email.focus();
       return false;
   }
   if (email.value.indexOf(".", 0) < 0)
   {
   	 if (enterRightEmail) window.alert(enterRightEmail);
   	 else
   	    window.alert("Prosím, zadajte správnu emailovú adresu.");
       email.focus();
       return false;
   }
   if (email.value.indexOf(".", 0) == email.value.length-1)
   {
   	 if (enterRightEmail) window.alert(enterRightEmail);
   	 else
   	    window.alert("Prosím, zadajte správnu emailovú adresu.");
       email.focus();
       return false;
   }
    if (phone.value == "")
   {
   	 if (enterTel) window.alert(enterTel);
   	 else
   	   window.alert("Prosím, zadajte Vaše telefónne číslo.");
       phone.focus();
       return false;
   }
    if (adults.value == "")
   {
   	 if (enterAdults) window.alert(enterAdults);
   	 else
   	   window.alert("Prosím, zadajte počet dospelých osôb.");
       adults.focus();
       return false;
   }
    if (agree.checked == "")
   {
   	 if (enterTradeCond) window.alert(enterTradeCond);
   	 else
   	   window.alert("Musíte súhlasiť s obchodnými podmienkami.");
       return false;
   }
return true;
}

function ceckOrderForm(){

var reason = "";

  reason += validateEmail(theForm.name);
  reason += validateEmpty(theForm.mail);
  reason += validateEmpty(theForm.phone);
  reason += validateEmpty(theForm.adults);
      
  if (reason != "") {
    alert("Chyba:\n" + reason);
    return false;
  }

  return true;
}
function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
        error = "Musíte vyplniť povinné polia.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}

function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "Zadajte prosím emailovú adresu.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Skontrolujte prosím zadanú emailovú adresu.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "Emailová adresa obsahuje nepovolené znaky.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}



var combo;

function echo(msg){
	return;
	if (msg=="reset")
		document.getElementById('messages').innerHTML ="";
	else 
		document.getElementById('messages').innerHTML +="<br>"+msg;
}

function smallRoom() {
	echo('Nevojdete sa do Vami zvolenej izby');
//	document.getElementById('to2ndStep').disabled = 1;
}

//vrati najmensi a najvacsi pocet osob danej urovne adult/kid/kid2
function minMaxPers(per){
	ret=new Array(100,0);
	for (i in ret) {
		if (per[i]<ret[0]) ret[0] = per[i];
		if (per[i]>ret[1]) ret[1] = per[i];
	}
	return ret;
}

//do globalneho pola posComb vlozi vsetky mozne kombinacie ako sa zvoleny pocet a typ ludi vojde do cennika
//per[0] = adult; per[1]=kid; per[2]=kid2
function transformBeds(combo,per){
//	if (typeof(combo[per[0]]) == "undefined" || typeof(combo[per[0]][per[1]]) == "undefined" || typeof(combo[per[0]][per[1]][per[2]]) == "undefined" ) {
//	echo( per[0]);
	per[0] *=1;per[1] *=1;per[2] *=1;
	if (typeof(combo[per[0]]) != "undefined")
		if (typeof(combo[per[0]][per[1]]) != "undefined")
			if(typeof(combo[per[0]][per[1]][per[2]]) != "undefined") { //dobra kombinacia
//				echo("n"+per);
				ok = 1;
				okx = 0;
				for (i in posComb){
//					echo("g"+i+"|"+per[0]+"|"+per[1]+"|"+per[2]);
//					echo(posComb[i][per[0]]);
					if(typeof(posComb[i][0]) != "undefined" && posComb[i][0]==per[0]){
//						echo("c0");
//						okx = 1;
					if(typeof(posComb[i][1]) != "undefined" && posComb[i][1]==per[1]) {
//						echo("c1");
//						okx = 1;
					if(typeof(posComb[i][2]) != "undefined" && posComb[i][2]==per[2]) {
//						echo("c2");
						okx = 1;
//						echo('naslo');
					}}}
					if (okx ==1) ok = 0;
					okx=0;
				}
				if (ok || posComb.length==0) {
//					echo("p"+per);
					posComb[posComb.length]=per;
				}
				
			}
	
	mmPer = minMaxPers(combo);
	if (mmPer[0] > per[0] && per[1] > 0) {
		transformBeds(combo,Array(per[0]+1,per[1]-1,per[2]))
	}
	if (per[2] > 0) {
		transformBeds(combo,Array(per[0],per[1]+1,per[2]-1))
	}
	
	return;
	
}
function accomComb(){
	echo("reset");
	posComb = new Array();
	accoms = booking_unit_layout.split(",");
	combo = new Array();
	maxA = 0;
	minA = 999999;
	for (k in accoms){						//kombinacie pre dabu izbu
		a=0;c=0;i=0;x=0;
		chars="";
		chars = accoms[k].split("");
		for (j in chars) {					//pismenka v danej kombinacii
			if (chars[j]=="A") a++;
			if (chars[j]=="C") c++;
			if (chars[j]=="I") i++;
			if (chars[j]=="X") x++;
		}
		a+=x;
		if ( typeof(combo[a]) == "undefined" ) 
			combo[a] = new Array();
		if ( typeof(combo[a][c]) == "undefined" ) 
			combo[a][c] = new Array;
		combo[a][c][i] = 1;
		if (maxA<a) maxA=a;
		if (minA>a) minA=a;
//echo(a+" "+c+" "+i+" "+combo[a][c][i]);		
	}
	
	
	var adult = document.getElementById('adult').value*1;
	var kid = document.getElementById('kid').value*1;
	var kid2 = document.getElementById('kid2').value*1;
	var personNum = adult+kid+kid2;
//echo("------<br>"+adult+" "+kid+" "+kid2);
//echo (adult +" "+ maxA +" "+ personNum +" "+ combo.length);	
/*	if ((adult > maxA || personNum > combo.length)) {		//nevojdu sa do izby
		smallRoom();
		alert("Nevojdete sa do izby.");
		return;
	}*/
	persons = new Array(adult,kid,kid2);
	transformBeds(combo,persons,persons);	//napln izbu tak aby to bola moznost podla cennika
	echo(posComb);							// posComb je pole vysledkov podla cenika 

	prices = "";
	prices=calculPrice();
//alert(prices);
//	alert((adult+kid+kid2)+"  "+  maxA+"  "+(adult+kid+kid2 > maxA) );
	if (perApartman) {
		if(adult+kid > maxA) {
			document.getElementById('price').innerHTML = "Nevojdete sa do izby.";
//			document.getElementById('to2ndStep').disabled = 1;
			return;
		}
		minPrice = calculPrice()*1;
		minPrice += calculPriplatky(adult+kid+kid2)*1;
		document.getElementById('price').innerHTML= minPrice; 
		return;
	}
	
	else if (posComb=="") {
		//wrongComb();
		message = 0;
		if (adult+kid+kid2 > maxA)
			message = "Nevojdete sa do izby.";	
		if (adult+kid+kid2 < minA)
			message = "Nenaplnili ste izbu";
		if (message) document.getElementById('price').innerHTML = message;
//		document.getElementById('to2ndStep').disabled = 1;
		return;
	} else {
//		document.getElementById('to2ndStep').disabled = 0;
	}
	minPrice = 999999999;
	for (i in prices) {
		if (minPrice > prices[i][3])
			minPrice = prices[i][3]
	}
	minPrice +=calculPriplatky(adult+kid+kid2)*1;
	document.getElementById('price').innerHTML= minPrice; 
	return false;
}

function calculPriplatky (persons) {
	sumPrip = 0*1;
	for (i in priplatok) {
		if (document.getElementById('prip'+i).checked) {
			if (priplatok[i]['perPers'])
				sumPrip += persons * priplatok[i]['price'];
			else
				sumPrip += priplatok[i]['price'];
		}
	}
	return sumPrip;
}

//vrati 2 rozmerne pole, sum[i][3] je vysledna suma pre danu kombinaciu 
function calculPrice() {
	priceB = new Array();
	priceC = new Array();
	priceA = pricesP;		// cele pole priplatky
	echo(priceA);
	for(i in priceA) {
		echo(priceA[i]['price_description']);
		if(priceA[i]['price_type'] == 'zakladni' && !priceB[priceA[i]['age_limit_to']]) {
			priceB[priceA[i]['age_limit_to']] = priceA[i]['unit_price_currency'];
			echo(priceA[i]['age_limit_to']+" "+priceA[i]['unit_price_currency']);
		}
	}
//	priceB.sort();
//	priceB.reverse();
//priceC[0] = dospely
//priceC[1] = dieta1
//priceC[2] = deta2
//priceC[-1] = dospely pristelka
	for (i in priceB){
		if(i==99) {
			if (isNaN(priceC[0]))					//dospely
				priceC[0] = priceB[i];			
			else { 							//dospely uz je
				dospel1 = priceC[0];
				priceC[0] = max(priceC[0],priceB[i]);
//				if ()
			}
		}
		else { 
			if(typeof(priceC[1])=='undefined')
				priceC[1] = priceB[i];
			else {
				if (priceC[1] < priceB[i]) {
					priceC[2] = priceC[1];
					priceC[1] = priceB[i];
				}
				else
					priceC[2] = priceB[i];
			}
		}
	}
	for (i in posComb){
		sum[i]= new Array();
		sum[i][0]=posComb[i][0]*priceC[0];
		sum[i][1]=posComb[i][1]*priceC[1];
		sum[i][2]=posComb[i][2]*priceC[2];
		if (isNaN(sum[i][1])) sum[i][1]=0;
		if (isNaN(sum[i][2])) sum[i][2]=0;
		sum[i][3]=sum[i][0]+sum[i][1]+sum[i][2];
		echo(sum[i]);
	}
	if (perApartman) return priceC[0];
	else return sum;
}
// posklada najkratsie retazce booking_unit_layout pre vybrany pocet cestujucich
// comb = vysledne pole, buddyNum zvoleny pocet turistov,char znak pre dany typ turistu
/*function buildUnitLayou(comb,turistNum,char) {
	for (i=0;i<turistNum;i++) {
		comb[0]+=char;//AAC,AAC,..
		comb[1]+="A";//AAA
		comb[2]+="X";//XXX
	}
	return comb;
}*/

function addUsers(select) {
	document.getElementById('peopleForms').style.display='block';
//	location.hash = 'thirdSlide';

//	formw=document.getElementById(formular);
//	var c=formw.choice.options[formw.choice.selectedIndex].value;
	var c= document.getElementById(select).value
	var str='';
	var place='print'+select;
	if (c!=0){
		for (i=1;i<=c;i++)	{
			var str=str+'Meno: <input type="text" id="meno'+i+'">'+
			'Priezvisko: <input type="text" id="priezvisko'+i+'">'+
			'Dátum narodenia (dd/mm/yyyy): <input type="text" maxlength="2" size="1" id="den'+i+'"><input type="text" maxlength="2" size="1" id="mesiac'+i+'"><input type="text" maxlength="4" size="2" id="rok'+i+'"><br/>';
		}
		if (select=='adult') title = 'Dospelí';
		if (select=='kid') title = 'Deti do '+child_age_limit+' rokov.';
		if (select=='kid2') title = 'Deti do '+child2_age_limit+' rokov.';
		str = '<div class="kontaktTitle">'+title+'</div>' + str;
		document.getElementById(place).innerHTML=str;
	}
	else {
		document.getElementById(place).innerHTML=str;
	}
	
}

function calculate(row,col){
	//plati sa samostatne za osobu
	  if (termins[row][col]['priplatky'][0]['price_per_booking_unit']=='za osobu'){
	     
	  }
	//plati sa pausalne
	  else
	  {
	  //treba dorobit kontrolu poctu ludi vs pocet miest - pravdepodobne booking_unit_layout
	  
	  //zaklad bude tvorit pausal, urcite medzi prvymi a prvy so statusom zakladni a vekom do 99
	    if ((termins[row][col]['priplatky'][0][price_type])&&
	    		(termins[row][col]['priplatky'][0][price_type]=='zakladni')&&
	    		(termins[row][col]['priplatky'][0][age_limit_to]=='99'))
	    {
	    	var suma_vysledna = termins[row][col]['priplatky'][0]['unit_price_currency'];
	    }
	    else if((termins[row][col]['priplatky'][1][price_type])&&
	    		(termins[row][col]['priplatky'][1][price_type])=='zakladni')
	    {
	    	var suma_vysledna = termins[row][col]['priplatky'][1]['unit_price_currency'];
	    }
	    else if((termins[row][col]['priplatky'][2][price_type])&&
	    		(termins[row][col]['priplatky'][2][price_type])=='zakladni')
	    {
	    	var suma_vysledna = termins[row][col]['priplatky'][2]['unit_price_currency'];
	    }
	  /* plus pocet poisteni, zatial je to len checkbox - ten treba zmenit na selectbox, priblizny navrh nizsie.. pocet poli selectu sa zistuje podla poctu dospelych/deti/druhych deti a infantov.. tento check by sa mal robit asi pri kazdom onChange tych selectov na zmenu cestujucich. 
	  for (i in termins[row][col]['priplatky']){if (termins[row][col]['priplatky'][i][price_description]=='Komplexné poistenie Union') {
	    var counter=0;
	    var suma_za_poistenie=termins[row][col]['priplatky'][i]['unit_price_currency'];
	    if (document.getElementByID("adult").value!='0') counter=counter+document.getElementById("adult").value
	    if (document.getElementByID("kid").value!='0') counter=counter+document.getElementById("kid").value
	    if (document.getElementByID("kid2").value!='0') counter=counter+document.getElementById("kid2").value
	    if (document.getElementByID("infant").value!='0') counter=counter+document.getElementById("infant").value
	    
	    var str='';
	    str+='<SELECT id="poistenie" name="union">';
	    str+='  <OPTION selected value="0">0<\/OPTION>';
	    for (i=1;i<=counter;i++){
	      str+='   <option value="'+i+'">'+i+'<\/option>';
	      }
	    str+='<\/SELECT>';
	    document.write(str); // vlozit kam treba
	    }
	  }
	  
	  */
	  var pocet_poistenych=document.getElementById("poistenie").value;
	  if(pocet_poistenych>'0'){
	    suma_poist_vysledna=pocet_poistenych*suma_za_poistenie;
	  }
	  
	  
	  
	  }
	}


function LocationsByCountry() {
	document.getElementById('miesto').innerHTML = locations[document.getElementById('krajina').value];
	document.getElementById('miesto_1').innerHTML = locations[document.getElementById('krajina_1').value];
	document.getElementById('miesto_2').innerHTML = locations[document.getElementById('krajina_2').value];
	$('#miesto_input').remove();
	$('#miesto_container').remove();
	$('#miesto').selectbox();
	$('#miesto_1').selectbox();
	$('#miesto_2').selectbox();

}

function getXMLRequester( )
{
    var xmlHttp = false;
    // try to create a new instance of the xmlhttprequest object        
    try
    {
        // Internet Explorer
        if( window.ActiveXObject )
        {
            for( var i = 5; i; i-- )
            {
                try
                {
                    // loading of a newer version of msxml dll (msxml3 - msxml5) failed
                    // use fallback solution
                    // old style msxml version independent, deprecated
                    if( i == 2 )
                    {
                        xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );    
                    }
                    // try to use the latest msxml dll
                    else
                    {
                        
                        xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
                    }
                    break;
                }
                catch( excNotLoadable )
                {                        
                    xmlHttp = false;
                }
            }
        }
        // Mozilla, Opera und Safari
        else if( window.XMLHttpRequest )
        {
            xmlHttp = new XMLHttpRequest();
        }
    }
    // loading of xmlhttp object failed
    catch( excNotLoadable )
    {
        xmlHttp = false;
    }
    return xmlHttp ;
}

function getAjax(url,div) {
	params = "";
	xmlhttp = getXMLRequester();
	xmlhttp.open("POST", url,true);
	xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlhttp.send(params);
	xmlhttp.onreadystatechange = handle_http_state_gallery;	
	
}

function handle_http_state_gallery() {
	  if (xmlhttp.readyState == 4) {
	    if (xmlhttp.status == 200) {
			if(xmlhttp.responseText){
			  eval(xmlhttp.responseText);
			}
	    }
		else{
			alert('Error! Status: '+xmlhttp.status);
		}
	 }
}

var booking_unit_layout;
function step(id,pbooking_unit_layout) {
	location.hash = id;
//	currentAnchor = id;
	if (maxStep >= id ){
		for (i=0;i<=2;i++) {
//			alert(i+" "+id+" "+maxStep);
			if (i == id) document.getElementById('step'+i).className='akt_step';
			else document.getElementById('step'+i).className='neakt_step';
			if (i == id) {
				document.getElementById('step'+i).style.backgroundImage="url(fileadmin/templates/img/number_bg.gif)";
				document.getElementById('stepText'+i).className="stepText aktText";
			}
			else if (maxStep > i) { 
				document.getElementById('step'+i).style.backgroundImage="url(fileadmin/templates/img/number_bg_opa.gif)";
				document.getElementById('stepText'+i).className="stepText formerText";
			}
			else {
				document.getElementById('step'+i).style.backgroundImage="url(fileadmin/templates/img/number_bg_grey.gif)";
				document.getElementById('stepText'+i).className="stepText neaktText";
			}
				
			//if (i < maxStep) document.getElementById('step'+i).style.backgroundImage="url(fileadmin/templates/img/number_bg_opa.gif)";
//			else document.getElementById('step'+i).style.backgroundImage="url(fileadmin/templates/img/number_bg_grey.gif)";
		}
		document.getElementById('zeroSlide').style.display=(id==0?'block':'none');
		document.getElementById('firstSlide').style.display=(id==2?'block':'none');
		document.getElementById('secondSlide').style.display=(id==1?'block':'none');
		document.getElementById('objednaj').style.visibility=(id==1?'visible':'hidden');
		document.getElementById('endorder').style.visibility=(id==2?'visible':'hidden');
		if (pbooking_unit_layout)
			booking_unit_layout = pbooking_unit_layout;
//		maxStep = max(maxStep,id);
	}
	if (id < 2)
		document.getElementById('step2').style.visibility='hidden';
	
	return false;

}
var alertMessage = 1;
function updateSearch() {
	alertMessage = 0;
	searchFormSubmit();
	alertMessage = 1;	
//		document.getElementById('searchHotels').value = 0;
	//	document.getElementById('searchForm').submit();
}

var currentAnchor = 0;
$().ready(function(){  
    setInterval("checkAnchor()", 300);  
}); 
function checkAnchor(){  
//	alert(document.location.hash);
     //Check if it has changes  
     if(currentAnchor != document.location.hash){  
         currentAnchor = document.location.hash;
         step(currentAnchor.substring(1,2));
     }  
//     setInterval("checkAnchor()", 3000); 
}  

function searchFormSubmit() {
	items = new Array ('krajina','krajina_1','krajina_2','miesto','miesto_1','miesto_2','textinput','categorySel','placeSel','hotelSel','nightsSel','foodSel','priceFromSel','priceToSel','starsSel', 'fulltextInput');
	filled = 0;
	if (document.getElementById('textinput').value.indexOf('/') == -1) filled--;
	for(i=0;i<items.length;i++) {
		//alert(items[i]);
		if (document.getElementById(items[i]) && document.getElementById(items[i]).value)
			filled++;
	}
	if (filled>0) {
		if (document.form6) document.form6.submit();
		if (document.form7) document.form7.submit();
/*		if ((document.getElementById('krajina_1') && document.getElementById('krajina_1').value) 
			|| (document.getElementById('miesto_1') && document.getElementById('miesto_1').value))
			document.form6.submit();
		if ((document.getElementById('krajina_2') && document.getElementById('krajina_2').value)
			|| (document.getElementById('miesto_2') && document.getElementById('miesto_2').value))
			document.form7.submit();*/
		return false;
	}
	else {
		if (alertMessage) 
			alert(messageEmptySearchForm);
		return false;
	}
}

function hideDivOnClickOut() {
	$('body').append('<div id="jquery-overlay"></div>');
	var arrPageSizes = ___getPageSize();
	$('#jquery-overlay').css({
		backgroundColor:	'#000000',
		opacity:			0.8,
		width:				arrPageSizes[0],
		height:				arrPageSizes[1]
	}).fadeIn();
	
	

	function ___getPageSize() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	};
	
}


