





function ckmOnLoadHandler()
{
	//window.alert("onLoadhandler");
   //tu su vsetky veci co maju byt na onLoad na body
   //setTitleOvers();
   window.setTimeout("setTitleOvers()", 5000);
   //window.setTimeout("disableAutofill()", 5000);
}

flashfix = function() 
{
	theObjects = document.getElementsByTagName("object");
	for (var i = 0; i < theObjects.length; i++) 
	{
	 theObjects[i].outerHTML = theObjects[i].outerHTML;
	}
} 

function htmlSelectTagAddOptionCity(select, promptText)
{
	if (select.value == "")
	{
		var myValue = window.prompt(promptText, "");
		myValue = ""+myValue;
	   if (myValue!="" && myValue!="null" && myValue!="undefined")
	   {
	   	var optionName = new Option(myValue, myValue, true, true)
	      select.options[select.length] = optionName;	      
	   }
	   else
	   {
	      select.selectedIndex = 0;
	   }
	}
}

var lastSearchBox = null;
var lastSearchButton = null;
function getPageElement(name)
{
   var el = null;
   if (document.getElementById)
   {
      el = document.getElementById(name);
   }
   return(el);
}

function writeElement(elementId, text)
{
   var el = getPageElement(elementId);
   if (el != null)
   {
      el.innerHTML = text;
   }
}


function showSearchBox(name)
{
   var el = getPageElement(name);
   if (el != null)
   {
      if (lastSearchBox != null)
      {
		   lastSearchBox.style.display = "none";
		}
		if (lastSearchButton != null)
		{
		   lastSearchButton.style.backgroundColor = "transparent";
		   lastSearchButton.style.backgroundImage = "url('/images/style/menu_orange.gif')";
		}
		el.style.display = "block";
		lastSearchBox = el;
		
		el = getPageElement(name+"Button");
		if (el != null)
		{
		   el.style.backgroundColor = "red";
		   el.style.backgroundImage = "none";
		   lastSearchButton = el;
		}
	}
}



function highlightTopIcon()
{
   var location=window.location.href;
   var name = null;   
   if (location.indexOf("doprava/letenky")!=-1) name="letenkySearchBoxButton";
   if (location.indexOf("ubytovanie/hotely")!=-1) name="hotelySearchBoxButton";
   if (location.indexOf("prehliadky")!=-1) name="prehliadkySearchBoxButton";
   if (location.indexOf("cobrand/insurance")!=-1) name="poistenieSearchBoxButton";
   if (location.indexOf("produkty/poistenie")!=-1) name="poistenieSearchBoxButton";
   if (location.indexOf("letiskove-saloniky")!=-1) name="salonikySearchBoxButton";
   if (location.indexOf("loungepass")!=-1) name="salonikySearchBoxButton";
   if (location.indexOf("cobrand/hostels")!=-1) name="hostelySearchBoxButton";
   if (location.indexOf("ubytovanie/hostely")!=-1) name="hostelySearchBoxButton";
   if (location.indexOf("ubytovanie/apartmany")!=-1) name="apartmanySearchBoxButton";
   if (location.indexOf("doprava/transfery")!=-1) name="transferySearchBoxButton";
   if (location.indexOf("doprava/prenajom-aut")!=-1) name="autaSearchBoxButton";
   if (location.indexOf("hresult_flights.jsp")!=-1) name="letenkyHotelySearchBoxButton";
   if (location.indexOf("letenky-hotely")!=-1) name="letenkyHotelySearchBoxButton";
   
	
	if (name != null)
	{
	   el = getPageElement(name);
		if (el != null)
		{
		   el.style.backgroundColor = "red";
		   el.style.backgroundImage = "none";
		}
	}
}



//veci co su vo voucheri pre Octopus
function showMap(arg1, arg2)
{

}
function localizeDate(date, format)
{
   
}

function showHideElement(elementId, show)
{
   if(document.getElementById)
   {
      var rowEl = document.getElementById(elementId);
	   if (rowEl != null)
	   {
		   if (show)
			{
				if (rowEl.tagName && rowEl.tagName.toLowerCase()=="tr") rowEl.style.display="table-row";
				else rowEl.style.display="block";
			}
		   else rowEl.style.display="none";
		}
   }
}

function closeDiv(elementId)
{
   var divEl = getPageElement(elementId);
   if (divEl != null) divEl.style.display="none";
   var divEl = getPageElement(elementId+"Iframe");
   if (divEl != null) divEl.style.display="none";
}

function hhOctRoomChanged(select, prefix)
{   
	select.form.roomcount4.value = "0";
	select.form.roomcots4.value = "";
   if (select.value == "1")
   {
      select.form.roomcount1.value = "1";
	   select.form.roomcount2.value = "0";
	   select.form.roomcount3.value = "0";
	   select.form.roomtype2.selectedIndex = 0;
	   select.form.roomtype3.selectedIndex = 0;
	   select.form.roomcots2.value = "";
	   select.form.roomcots3.value = "";
	   showHideElement(prefix+"2", false);
   	showHideElement(prefix+"3", false);
	}
   if (select.value == "2")
	{	   
	   select.form.roomcount1.value = "1";
	   select.form.roomcount2.value = "1";
	   select.form.roomcount3.value = "0";
	   select.form.roomtype3.selectedIndex = 0;
	   select.form.roomcots3.value = "";
	   showHideElement(prefix+"2", true);
	   showHideElement(prefix+"3", false);
   }
   if (select.value == "3")
	{
	 	select.form.roomcount1.value = "1";
	   select.form.roomcount2.value = "1";
	   select.form.roomcount3.value = "1";
	   showHideElement(prefix+"2", true);
	   showHideElement(prefix+"3", true);	   
   }
}

function fillRoomCountHP(room)
{
  var roomParam = eval('document.searchTicketsHotelForm.'+ room); 
  if (roomParam.value == '') roomParam.value = 1; 
}

function paymentMethodChange(select)
{
   var divElement = getPageElement("creditCardInfo");
   if (divElement != null)
   {
	   if (select.value == "ckm_credit_card")
	   {
		   divElement.style.display = "block";
		   REQCOND1 = "no";
		}
		else
		{
		   divElement.style.display = "none";
		   REQCOND1 = "yes";
		   
		   if (document.orderForm!=null)
		   {
		      document.orderForm.ccName.value="";
		      document.orderForm.ccVerify.value="";
		      document.orderForm.ccNumber.value="";
		      document.orderForm.ccExp.value="";
		   }
		}
	}
	checkForm.recheck();
}

function poistenieStornaClick(cb)
{
   var poistenieStornaTR = getPageElement("poistenieStornaTR");
   var poistenieStornaTR2 = getPageElement("poistenieStornaTR2");
   var totalPayTD = getPageElement("totalPayTD");
   //var poistenieStornaRCDiv = getPageElement("poistenieStornaRCDiv");
   
   if (poistenieStornaTR==null || totalPayTD==null) return;   
   
   if (cb.checked)
   {
      poistenieStornaTR.style.display = "block";
      if (poistenieStornaTR2!=null) poistenieStornaTR2.style.display = "block";      
      totalPayTD.innerHTML = totalPricePoistenie;
      //if (poistenieStornaRCDiv!=null) poistenieStornaRCDiv.style.display = "block";
   }
   else
   {
      poistenieStornaTR.style.display = "none";
      if (poistenieStornaTR2!=null) poistenieStornaTR2.style.display = "none";
      totalPayTD.innerHTML = totalPrice;
      //if (poistenieStornaRCDiv!=null) poistenieStornaRCDiv.style.display = "none";
   }
}

function poistenieMenoPriezviskoBlur(iPassenger, field)
{
	var passPoistenie = getPageElement("passPoistenie_"+iPassenger);
	if (passPoistenie!=null)
	{
		//var fullName = eval("document."+field.form.name+".name_"+iPassenger+".value") + " " + eval("document."+field.form.name+".surname_"+iPassenger+".value");
		//passPoistenie.innerHTML = fullName;
	}
}

function poistenieMenoBlur(iPassenger, field)
{
	var passPoistenie = getPageElement("passPoistenie_"+iPassenger);
	if (passPoistenie!=null)
	{
		//passPoistenie.innerHTML = field.value;
	}
}

var dateLastFocusElement = null;

function checkDate(vstup)
{ 
   return(checkDate(vstup, false));
}

function checkDate(vstup, allowBack)
{   
  if (vstup && vstup.value && vstup.value.length > 0)
  {
   test_date = vstup.value;   
   test_date = test_date.replace(",", ".");
   test_date = test_date.replace(" ", ".");
   test_date = test_date.replace(":", ".");
   test_date = test_date.replace("-", ".");
   test_date = test_date.replace("/", ".");
   vstup.value = test_date;

   test_date = vstup.value;
   test_date = test_date.replace(",", ".");
   test_date = test_date.replace(" ", ".");
   test_date = test_date.replace(":", ".");
   test_date = test_date.replace("-", ".");
   test_date = test_date.replace("/", ".");
   vstup.value = test_date;
   
   //replace nazvov
   test_date = vstup.value.toUpperCase();
   test_date = test_date.replace("JAN", ".01.");
   test_date = test_date.replace("FEB", ".02.");
   test_date = test_date.replace("MAR", ".03.");
   test_date = test_date.replace("APR", ".04.");
   test_date = test_date.replace("MAJ", ".05.");
   test_date = test_date.replace("MAY", ".05.");
   test_date = test_date.replace("JUN", ".06.");
   test_date = test_date.replace("JUL", ".07.");
   test_date = test_date.replace("AUG", ".08.");
   test_date = test_date.replace("SEP", ".09.");
   test_date = test_date.replace("OKT", ".10.");
   test_date = test_date.replace("OCT", ".10.");
   test_date = test_date.replace("NOV", ".11.");
   test_date = test_date.replace("DEC", ".12.");
   vstup.value = test_date;
   
   if (test_date.length == 8 && test_date.indexOf(".")==-1)
   {
      test_date = test_date.substring(0,2)+"."+test_date.substring(2,4)+"."+test_date.substring(4);
      vstup.value = test_date;
   }

   var text
   var index
   var tecka
   var den
   var mesic
   var rok
   var ch
   text=""

   den=""
   mesic=""
   rok=""
   tecka=0

   for (index = 0; index < vstup.value.length; index++)
   {
      ch = vstup.value.charAt(index);
      if (ch != "0" && ch != "1" && ch != "2" && ch != "3" && ch != "4" && ch != "5" && ch != "6" && ch != "7" && ch != "8" && ch != "9" && ch != ".")
         {text="Dátum musí byť vo formáte DD.MM.RRRR (DD=deň, MM=mesiac, RRRR=rok).\r"}
      if ((ch == "0" || ch == "1" || ch == "2" || ch == "3" || ch == "4" || ch == "5" || ch == "6" || ch == "7" || ch == "8" || ch == "9") && (text ==""))
      {
         if (tecka == 0)
            {den=den + ch}
         if (tecka == 1)
            {mesic=mesic + ch}
         if (tecka == 2)
            {rok=rok + ch}
      }
      if (ch == "." && text == "")
      {
         if (tecka == 1)
            {tecka=2}
         if (tecka == 0)
            {tecka=1}

      }
   }
   
   den = Number(den);
   mesic = Number(mesic);
   
   if (!rok || rok == "")
   {
   	var dNow = new Date();
      if (mesic < (dNow.getMonth()+1))
      {
         rok = dNow.getYear()+1;
      }
      else if (mesic == (dNow.getMonth()+1) && den < dNow.getDate())
      {
         rok = dNow.getYear()+1;
      }
      else
      {
         rok = dNow.getYear();
      }
   }
   
   rok = Number(rok);
   
   //window.alert("den="+den);

   if ((den<1 || den >31) && (text == ""))
      {text=text + "Počet dní v mesiaci nesmie byť menej ako 1 alebo viac ako 31.\r"}
   if ((mesic<1 || mesic>12) && (text == ""))
      {text=text + "Mesiac nemôže byť menší ako 1 alebo väčší ako 12.\r"}
   if (rok<100 && tecka == 2 && text == "" && rok != "")
   {
      rok = 2000 + rok;
   }
   else if (rok<1900 && tecka == 2 && text == "" && rok != "")
   {
      text=text + "Rok nemôže byť menší ako 1900.\r"      
   }
   if ((tecka == 2 && rok == "") || (tecka > 2))
      {text=text+ "Dátum musí byť vo formáte DD.MM alebo DD.MM.RRRR (DD=deň, MM=mesiac, RRRR=rok).\r"}
   if (mesic == 2)
   {
      if (rok != "")
         {
         if (rok % 4 == 0)
            {
            if (den>29)
               {text=text + "Vo februári roku " + rok + " je iba 29 dní.\r"}
            }
         else
            {
            if (den>28)
               {text=text + "Vo februári roku " + rok + " je iba 28 dní.\r"}
            }
         }
      else
         {
         if (den>29)
            {text=text + "Vo februári je 29 dní.\r"}
         }
   }

   if ((mesic == 4 || mesic == 6 || mesic == 9 || mesic == 11) && (den>30))
      {text=text + "Počet dní vo vybranom mesiaci nesmie byť menej ako 1 alebo viac ako 30.\r"}

   if (text!="")
   {   	
      window.alert(text);           
      if (dateLastFocusElement==null || dateLastFocusElement!=vstup)
   	{
   		vstup.focus();
      	vstup.select(); 
      	dateLastFocusElement = vstup;
      }
      return(vstup);
   }
   else
   {
      //zostav formatovany datum
      var myDatum = ""+den;
      if (den < 10) myDatum = "0"+den;
      if (mesic < 10) myDatum += ".0"+mesic;
      else myDatum += "."+mesic;
      myDatum += "."+rok;
      vstup.value = myDatum;
      
      if (allowBack==false)
      {
	      //skontroluj, ci nie je v minulosti
			var myDate = getDate(vstup.value);
			
			var nowDate = getDate("04.08.2010");
			if (myDate < nowDate)
			{
				text = text + "Dátum musí byť väčší alebo rovný ako 04.08.2010";
				window.alert(text);           
		      if (dateLastFocusElement==null || dateLastFocusElement!=vstup)
		   	{
		   		vstup.focus();
		      	vstup.select(); 
		      	dateLastFocusElement = vstup;
		      }
		      return(vstup);
			}
		}
      
      return(null);
   }   
 }
 return(null)
}

//////////////////////////////////////////////////////////////////////
// Numerical Checking Support (internal use)

function IsNumber(Value, AllowPoint, DigitsAfter, DigitsBefore)
// Returns true if the given Value is a number that parseInt/Float will read correctly
// Returns false is the given Value contains junk which parseInt/Float would ignore
// Additionally, can limit number of digits before and after point
{
   // If AllowPoint is not set, assume it is false ie check for an integer
   if (IsNumber.arguments.length < 2)
      AllowPoint = false;

   if (!(AllowPoint))
   {  DigitsBefore = -1;
      DigitsAfter = -1;
   }

   // Flags for float/integer validation
   DigitsStarted = false;
   DigitsStopped = false;
   PointPosition = -1;
   SignPosition = -1;
   CountBefore = 0;
   CountAfter = 0;
   ValidNumber = false;

   // Check its a valid number
   for (I = 0; I < Value.length; I++)
   {  // "-" is allowable once, immediately before digits and/or point only
      if (Value.charAt(I) == "-")
      {  if ((DigitsStarted) || (SignPosition > -1) || PointPosition > -1)
         {  ValidNumber = false;
            break;
         }
         else
            SignPosition = I;
      }

      // "." is allowed once and must be immediately before or after a digit
      else if (Value.charAt(I) == ".")
      {  if ((PointPosition > -1) || (DigitsStopped) || (!(AllowPoint)))
         {  ValidNumber = false;
            break;
         }
         else
            PointPosition = I;
      }

      // " " is allowable when leading or trailing only
      else if (Value.charAt(I) == " ")
         DigitsStopped = DigitsStarted;

      // numbers are allowable when in one lump
      // any sign or point must be immediately previous if this is the first digit
      else if ((Value.charAt(I) >= "0") &&
               (Value.charAt(I) <= "9"))
      {  ValidNumber = true;
         if ( (((SignPosition > -1) && (SignPosition != I-1) && (SignPosition != PointPosition-1)) && (!(DigitsStarted)))
              ||
              (((PointPosition > -1) && (PointPosition != I-1)) && (!(DigitsStarted)))
              ||
              (DigitsStopped)
            )
         {  ValidNumber = false; alert(I + " " + SignPosition + " " + PointPosition + " " + DigitsStarted);
            break;
         }

         DigitsStarted = true;
         if (PointPosition > -1)
            CountAfter++;
         else
            CountBefore++;

         if (((DigitsBefore > -1) && (CountBefore > DigitsBefore)) ||
             ((DigitsAfter > -1) && (CountAfter > DigitsAfter)))
         {  ValidNumber = false;
            break;
         }
      }

      // nothing else is allowed
      else
      {  ValidNumber = false;
         break;
      }
   }

   return ValidNumber;
}


function checkTime(Field)
// Checks the contents of a given TEXT/TEXTAREA is a valid time hh:mm
{
   // Allow blank times
   if (!Field || !Field.value || Field.value.length == 0) { return null; }

   test_time = Field.value;   
   test_time = test_time.replace(",", ":");
   test_time = test_time.replace(" ", ":");
   test_time = test_time.replace("\.", ":");
   test_time = test_time.replace("-", ":");

   if (test_time.length == 4 && test_time.indexOf(":")==-1)
   {
      test_time = test_time.substring(0,2)+":"+test_time.substring(2);
   }

   dvojbodka = test_time.indexOf(":");

   // Check it
   if ( (test_time.length > 5)                   // its too long
        ||
        (dvojbodka < 1)              // its not got a : in the middle
        ||
        (!(IsNumber(test_time.substring(0,dvojbodka))))   // its hours isnt a number
        ||
        (!(IsNumber(test_time.substring(dvojbodka+1,test_time.length))))   // its minutes isnt a number
        ||
        (test_time.indexOf(" ") > -1)             // its got spaces in it
        ||
        (test_time.indexOf("-") > -1)             // its got negatives in it
        ||
        (parseInt(test_time.substring(0,2)) > 23) // its got too many hours
        ||
        (parseInt(test_time.substring(3,5)) > 59) // its got too many minutes
      )
   {
      window.alert("Zadaný čas nie je korektný");
      if (dateLastFocusElement==null || dateLastFocusElement!=Field)
      {
      	Field.select();
      	Field.focus();
      	dateLastFocusElement = Field;
      }
      return Field;
   }
   else
   {
      Field.value = test_time;
      return null;
   }
}

function getDate(dateString)
{
   var values = dateString.split(".");
   var date = new Date(values[2], values[1]-1, values[0]);
   //window.alert(date);
   return(date);
}

function checkEndDate(fieldStart, fieldEnd, b_isEnd)
{
   if (b_isEnd == false && checkDate(fieldStart)!=null)
   {
      return false;
   }
   if (checkDate(fieldEnd)!=null)
   {  
      //fieldEnd.focus();
      //window.alert("Nesprávne zadaný koncový dátum.");
      return false;
   }
   if (fieldStart.value.length < 10)
   {
      //return;
   }
   
   var dateStart = getDate(fieldStart.value);
	var dateEnd = getDate(fieldEnd.value);

	//window.status = dateStart + " end=" + dateEnd;
	var diff = dateEnd - dateStart;
	//window.alert(diff);
   if (dateEnd < dateStart)
   {
   	if (b_isEnd == true) window.alert("Koncový dátum nemôže byt skôr ako začiatočný.");
   	if (dateLastFocusElement==null || dateLastFocusElement!=fieldEnd)
   	{
   		fieldEnd.value = "";
      	fieldEnd.focus();  
      	fieldEnd.select();
      	
      	//upravene - do koncoveho datumu dame start + 5 dni
      	dateEnd = new Date((Date.parse(dateStart)) + (1000*60*60*24*5));
      	fieldEnd.value=dateEnd.getDate()+"."+(dateEnd.getMonth()+1)+"."+dateEnd.getFullYear();
      	
      	dateLastFocusElement = fieldEnd;
      }
      return;
   }
   if (b_isEnd == false && fieldStart.value.length == 10 && fieldEnd.value.length < 10)
   {
   	var dateStart = getDate(fieldStart.value);
   	var dateEnd = new Date((Date.parse(dateStart)) + (1000*60*60*24*5));
     	fieldEnd.value=dateEnd.getDate()+"."+(dateEnd.getMonth()+1)+"."+dateEnd.getFullYear();
   }
   
}

function checkEndTime(fieldStart, fieldEnd, b_isEnd)
{
   if (checkTime(fieldStart)!=null)
   {
      return;
   }
   if (checkTime(fieldEnd)!=null)
   {
      return;
   }

   startTime = fieldStart.value;
   endTime = fieldEnd.value;

   if (endTime.length < 3 || endTime.indexOf(":") < 1)
   {
      fieldEnd.value = "";
      return;
   }
   if (startTime.length < 3 || startTime.indexOf(":") < 1)
   {
      startTime = "08:30"
      fieldStart.value = startTime;
   }

   minutesStart = (startTime.substring(0,startTime.indexOf(':'))-0) * 60 +
                  (startTime.substring(startTime.indexOf(':')+1,startTime.length)-0);
   minutesEnd = (endTime.substring(0,endTime.indexOf(':'))-0) * 60 +
                (endTime.substring(endTime.indexOf(':')+1,endTime.length)-0);

   if (b_isEnd == false && lastTimeDif > 0)
   {
      minutesEnd = minutesStart + lastTimeDif;
      hours = Math.floor(minutesEnd / 60);
      if (hours < 10) hours = "0"+hours;
      minutes = (minutesEnd - (hours * 60));
      if (minutes < 10) minutes = "0"+minutes;
      fieldEnd.value = hours + ':' + minutes;
      endTime = fieldEnd.value;
   }
   else
   {
      if (minutesEnd < minutesStart)
      {
         fieldEnd.value = "";
         window.alert("Koncový cas nemôže byt skôr ako začiatočný.");
         return;
      }
   }
   lastTimeDif = minutesEnd - minutesStart;
   //window.alert("min start="+minutesStart+" end="+minutesEnd);

}

function showPopupDivId(divId, zobraz, obj, width) 
{
   var divEl = getPageElement(divId);
   if (divEl != null)
   {
      var text = divEl.innerHTML;
      showPopupDiv(text, zobraz, obj, width);
   }
}

function showPopupDiv(text, zobraz, obj, width) 
{
	return(showPopupDiv2("infoPopupDiv", text, zobraz, obj, width));
}

function showPopupDiv2(elementId, text, zobraz, obj, width) 
{	
	if (!width || width == null) width = "250";

   var infoPopupDiv = getPageElement(elementId);
	if (infoPopupDiv == null)
	{
      return;	    
	}
	var infoPopupDivIframe = getPageElement(elementId+"Iframe");
	if (infoPopupDivIframe==null) infoPopupDivIframe = getPageElement("infoPopupDivIframe");
   
   if (zobraz == false)
   {
   	infoPopupDiv.style.display="none";
   	if (infoPopupDivIframe != null) infoPopupDivIframe.style.display="none";
   	return;
   }
   
	var posX = 0; 
	var posY = 0; 
	if (obj.offsetLeft) posX = obj.offsetLeft;
	if (obj.offsetTop) posY = obj.offsetTop;
	
	aTag = obj;
	do
	{
		aTag = aTag.offsetParent;
		if (aTag != null)
		{
			posX += aTag.offsetLeft;
			posY += aTag.offsetTop;
		}
	} while (aTag && aTag.tagName != 'BODY');
	if (posX > (900-width))
	{
	   posX = posX - width;
	   if (obj.offsetWidth) posX = posX + obj.offsetWidth;
	}
	if (posX < 10) posX = 10;
	posY = posY + 22;
	
	//window.status = posX+" y="+posY + " text=" + text;
   infoPopupDiv.style.display="block";
   infoPopupDiv.style.top = posY + "px";
   infoPopupDiv.style.left = posX + "px";   
   
   if (text != null && text.length < 50)
   {
   	infoPopupDiv.style.width = "auto";
   }
   else
   {   
   	infoPopupDiv.style.width = width+"px";
   }
   
   if (text == null) return;
   
   if (text!=null)
   {
      //najskor zisti, ci to nema content div
      var contentEl = getPageElement(elementId+"Content");
      if (contentEl != null)
      {
      	contentEl.innerHTML = text;
      }
      else
      {
      	infoPopupDiv.innerHTML = text;
      }
   }
   
   infoPopupDiv.style.zIndex = 20;
   
   if (infoPopupDivIframe != null)
	{	   
	   infoPopupDivIframe.style.left = infoPopupDiv.style.left;
	   infoPopupDivIframe.style.top = infoPopupDiv.style.top;				
	   infoPopupDivIframe.style.width = infoPopupDiv.offsetWidth + "px";
	   infoPopupDivIframe.style.height = infoPopupDiv.offsetHeight+"px";
	   //window.status = infoPopupDiv.offsetHeight;
	   infoPopupDivIframe.style.display = "block";
	   
	   infoPopupDivIframe.style.zIndex = 19;
	}
}

// Scott Andrew's event attacher
function ckmAddEvent(obj, evType, fn){
	if (obj.addEventListener){
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent){
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else {
		return false;
	}
}

function ckmFixE(e) {
	if (!e && window.event) e = window.event;
	if (!e.target) e.target = e.srcElement;
	return e;
}

function autoTitleShow(e)
{
   if (e && e.tagName) {
		obj = e;
	} else {
		e = ckmFixE(e);
		obj = e.target;
	}
	showPopupDiv(obj.autoTitle, true, obj); 
}

function autoTitleHide(e)
{
   if (e && e.tagName) {
		obj = e;
	} else {
		e = ckmFixE(e);
		obj = e.target;
	}
	showPopupDiv("&nbsp;", false, obj); 
}

function setTitleOvers()
{
   //prejdi cely dokument a vsetkym elementom co maju title nastav JS volania
   var els = document.getElementsByTagName("*");
   var elsLen = els.length;
  	//window.alert("prechadzam size="+elsLen);
   for (i = 0; i < elsLen; i++) 
   {
		if (els[i].title !=null && els[i].title != "")
		{
			if (els[i].className == null || els[i].className.indexOf("noTitleHover")==-1)
			{
			  //window.alert(i+" "+els[i].title);
				els[i].autoTitle = els[i].title;
				els[i].title = "";
				ckmAddEvent(els[i], "mouseover", autoTitleShow);
				ckmAddEvent(els[i], "mouseout", autoTitleHide);
			}			
		}
	}
}

ckmAddEvent(window, "load", ckmOnLoadHandler);

function changeChildAgeVisibility(select, name)
{
  var childsCount = 5;
  var ageSelect;
  
  if (!name || name==null)
  {
     name = "ssearch";
  }
  
  var myEl = document.getElementById(name+"VekSpan");
  if (myEl != null)
  {
     if (select.value=="")
     {
        myEl.style.display = "none";
     }
     else
     {
     	  myEl.style.display = "inline";
     }
  }
  
  name = name+"VekSelect";
	
  for (var i=1; i<=childsCount; i++)
  {
    ageSelect = getPageElement(name+i);
    if (i <= select.value)
    {
      ageSelect.style.visibility = 'visible';
    }
    else
    {
      ageSelect.style.visibility = 'hidden';
      ageSelect.value = '';
    }
  }
}

function disableAutofill()
{
   var els = document.getElementsByTagName("INPUT");
   var elsLen = els.length;
   for (i = 0; i < elsLen; i++) 
   {
		if (els[i].title !=null && els[i].title != "")
		{
			//window.alert(els[i].title);
			els[i].title = "";
		}
	}
}

function letenkyToleranceFocus(select)
{
   var maxFlexi = 3;
   var maxDni = 9;
   if (select.form.ffromAjax.value.toLowerCase().indexOf("flexi")!=-1)
   {
      //mozeme mat max maxFlexi dni
      if (select.options.length > maxFlexi)
      {
         var failsafe = 0;
         while (select.options.length > maxFlexi && failsafe < 20)
         {
            select.options[select.options.length-1]=null;
            failsafe++;
         }
      }
   }
   else
   {
      if (select.options.length <= maxFlexi)
      {
         for (i=maxFlexi; i<=maxDni; i++)
         {
            select.options[select.options.length] = new Option("±"+i+" dní", i);
         }
      }
   }
}

function oneWayFlightClickHP(cb)
{
   var pageEl = getPageElement("letenkyFonHP");
   var pageEl2 = getPageElement("letenkyFonTextHP");
	if (cb.value=="true")
	{
	   cb.form.ron.value = '01.01.2010';
	   if (pageEl != null) pageEl.style.visibility = "hidden";
	   if (pageEl2 != null) pageEl2.style.visibility = "hidden";
	}
	else
	{
		cb.form.ron.value = '';
		if (pageEl != null) pageEl.style.visibility = "visible";
		if (pageEl2 != null) pageEl2.style.visibility = "visible";
	}
}


function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++)
	 {
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles()
  {
    if(event.srcElement.style.backgroundColor != "")
    {
      event.srcElement.style.backgroundColor = "";
    }
  }

if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  
//octopus
function fillRoomCount2(field, room)
{ 
  var roomParam = field.form.elements[room]; 
  if (roomParam.value == '')
	roomParam.value = 1;
}

function showPopupDivFare(id, zobraz, obj, width)
{
   var tableEl = getPageElement(id);
   if (tableEl != null)
   {
      var htmlCode = tableEl.innerHTML;
      showPopupDiv(htmlCode, zobraz, obj, width)
   }
}

function showPopupDivPrice(id, zobraz, obj, width)
{
   var tableEl = getPageElement(id);
   if (tableEl != null)
   {
      var htmlCode = tableEl.innerHTML;
      showPopupDiv(htmlCode, zobraz, obj, width)
   }
}
