﻿var sSV = "ü";
var sMV = "ý";

$(function(){ 
    
    $("ul#ticker01").removeClass("hide");
    $("ul#ticker01").liScroll(); 
    setInterval( "slideSwitch()", 5000 );
        
    //$.swapImage(".swapImageDisjoint");
    //$('#container-1').tabs();
});


function fillFlightsTo(obj,idddlGoingTo,
            idhiddenAirportRegionNames,idhiddenAirportRegionCodes) 
{
    
    
    var arrAirportRegionNames = document.getElementById(idhiddenAirportRegionNames).value.split("*");
    var arrAirportRegionCodes = document.getElementById(idhiddenAirportRegionCodes).value.split("*");
    
    //alert(document.getElementById(idhiddenAirportRegionNames).value);
    //alert(document.getElementById(idhiddenAirportRegionCodes).value);
    //alert(arrAirportRegionCodes.length);
    document.getElementById(idddlGoingTo).options.length = 0;
    for(var i=0;i<arrAirportRegionCodes.length;i++)
    {
        if(arrAirportRegionCodes[i].indexOf(obj.value + ",",0) != -1 )
        {   
            //alert(arrAirportRegionCodes[i]);
            //alert(arrAirportRegionNames[i]);
            
            var arrSubAirportRegionCodes = arrAirportRegionCodes[i].split(",");
            var arrSubAirportRegionNames = arrAirportRegionNames[i].split(",");
            
            cnt=0;             
            for(var j=1;j<arrSubAirportRegionCodes.length;j++)
            {       
                newOpt=new Option; 
                newOpt.value=arrSubAirportRegionCodes[j].replace(/\"/g,"");
                newOpt.text=arrSubAirportRegionNames[j].replace(/\"/g,"");
                document.getElementById(idddlGoingTo).options[cnt]=null;
                document.getElementById(idddlGoingTo).options[cnt]=newOpt;
                cnt++;
            }
         }
         else{}
     }
     document.getElementById(idddlGoingTo).options[0].selected = true;
 }

function setHiddenValue(obj,strhid) 
{
        document.getElementById(strhid).value = obj.value;
}
    
jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.04
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("newsticker")
				var stripWidth = 0;
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).width();
				//alert(stripWidth);
				});
				$strip.width(stripWidth);			
				var defTiming = stripWidth/settings.travelocity;
				var totalTravel = stripWidth+containerWidth;								
				function scrollnews(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollnews(totalTravel, defTiming);});
				}
				scrollnews(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollnews(residualSpace, residualTime);
				});			
		});	
};

/*** 
    Simple jQuery Slideshow Script
    Released by Jon Raasch (jonraasch.com) under FreeBSD license: free to use or modify, not responsible for anything, etc.  Please link out to me if you like it :)
***/

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function displayDuration(rdolist)
{				
	var rdolistCtl = document.getElementById(rdolist);

    var options = rdolistCtl.getElementsByTagName('input');
    for(i=0;i<options.length;i++){
        var opt = options[i];
        if(opt.checked){
            if (opt.value == "Fixed")
	        {
		        document.getElementById("divFixedDate").style.display="block";
		        document.getElementById("divFlexibleDate").style.display="none";
	        }
	        else if (opt.value == "Flexible")
	        {
		        document.getElementById("divFixedDate").style.display="none";
		        document.getElementById("divFlexibleDate").style.display="block";
	        }
	        break;
        }            
    }
}

function toggleAirlineClass(iddivAirlineClass,idchkAirlineClass)
{
    if(document.getElementById(idchkAirlineClass).checked)
    {
       document.getElementById(iddivAirlineClass).style.display="block";
       document.getElementById(iddivAirlineClass).style.visibility="visible";
    }
    else
    {        
        document.getElementById(iddivAirlineClass).style.display="none";
        document.getElementById(iddivAirlineClass).style.visibility="hidden";
    }
}   

function toggleFlightDirection(iddivFlightReturnDateTime,
                               idrboReturn,
                               idhidFlightDirection)
{
    if(document.getElementById(idrboReturn).checked)
    {
       document.getElementById(iddivFlightReturnDateTime).style.display="block";
       document.getElementById(iddivFlightReturnDateTime).style.visibility="visible";
       document.getElementById(idhidFlightDirection).value = "2";
    }
    else
    {        
        document.getElementById(iddivFlightReturnDateTime).style.display="none";
        document.getElementById(iddivFlightReturnDateTime).style.visibility="hidden";
        document.getElementById(idhidFlightDirection).value = "1";
    }
}

function setDynamicSearchControls(iddivFlightDirection,
    idrboSearchFlightsOnly,idrboSearchAccomodationOnly,
    idrboSearchHolidays,iddivRoomNos,
    idddlRooms,iddivpax2,iddivpax3,iddivpax4,iddivpax5,
    iddivforFlightandHolidays,
    iddivforAccommodation,
    idhidSearchOptionSelected
    )
{
    if(document.getElementById(idrboSearchFlightsOnly).checked)
    {  
       document.getElementById(idhidSearchOptionSelected).value = "F";
        //If Flights Only then display "One Way " and "Return"
       document.getElementById(iddivFlightDirection).style.display="block";
       document.getElementById(iddivFlightDirection).style.visibility="visible";
       
       document.getElementById(iddivforFlightandHolidays).style.display="block";
       document.getElementById(iddivforFlightandHolidays).style.visibility="visible";
        
       //If Flights Only then hide the Room Numbers 
       document.getElementById(iddivRoomNos).style.display="none";
       document.getElementById(iddivRoomNos).style.visibility="hidden";
       
       document.getElementById(iddivforAccommodation).style.display="none";
       document.getElementById(iddivforAccommodation).style.visibility="hidden";
       
       document.getElementById(iddivpax2).style.display="none";      
       document.getElementById(iddivpax2).style.visibility="visible";
       
       document.getElementById(iddivpax3).style.display="none";      
       document.getElementById(iddivpax3).style.visibility="visible";
       
       document.getElementById(iddivpax4).style.display="none";      
       document.getElementById(iddivpax4).style.visibility="visible";
       
       document.getElementById(iddivpax5).style.display="none";      
       document.getElementById(iddivpax5).style.visibility="visible";
       
       $(".clsdivRoomChildAges").css({display: 'none'});
       $(".clsdivRoomChildAges").css({visibility: 'hidden'});
    }
    else if(document.getElementById(idrboSearchAccomodationOnly).checked)
    {
       $(".clsdivRoomChildAges").css({display: 'block'});
       $(".clsdivRoomChildAges").css({visibility: 'visible'});
       document.getElementById(idhidSearchOptionSelected).value = "A"; 
       
       document.getElementById(iddivforAccommodation).style.display="block";
       document.getElementById(iddivforAccommodation).style.visibility="visible"; 
      
       //If Flights Only then hide the Room Numbers 
       document.getElementById(iddivRoomNos).style.display="block";
       document.getElementById(iddivRoomNos).style.visibility="visible";
       
       //If Flights Only then display "One Way " and "Return"
       document.getElementById(iddivFlightDirection).style.display="none";
       document.getElementById(iddivFlightDirection).style.visibility="hidden";
      
       document.getElementById(iddivforFlightandHolidays).style.display="none";
       document.getElementById(iddivforFlightandHolidays).style.visibility="hidden";
    }
    else if(document.getElementById(idrboSearchHolidays).checked)
    {  
       $(".clsdivRoomChildAges").css({display: 'block'});
       $(".clsdivRoomChildAges").css({visibility: 'visible'});
        
       document.getElementById(idhidSearchOptionSelected).value = "H";
        
       document.getElementById(iddivforFlightandHolidays).style.display="block";
       document.getElementById(iddivforFlightandHolidays).style.visibility="visible";
        
       document.getElementById(iddivRoomNos).style.display="block";      
       document.getElementById(iddivRoomNos).style.visibility="visible";
       
       document.getElementById(iddivFlightDirection).style.display="none";
       document.getElementById(iddivFlightDirection).style.visibility="hidden";
       
       document.getElementById(iddivforAccommodation).style.display="none";
       document.getElementById(iddivforAccommodation).style.visibility="hidden"; 
    } 
    
    displayPaxForRooms(
                    idddlRooms,
                    iddivpax2,
                    iddivpax3,
                    iddivpax4,
                    iddivpax5,
                    idrboSearchFlightsOnly)
}

function displayPaxForRooms(
                    idddlRooms,
                    iddivpax2,
                    iddivpax3,
                    iddivpax4,
                    iddivpax5,
                    idrboSearchFlightsOnly
                    )
{
    if((document.getElementById(idrboSearchFlightsOnly).checked))
    {   
        document.getElementById(iddivpax2).style.display="none";      
        document.getElementById(iddivpax2).style.visibility="hidden";
        document.getElementById(iddivpax3).style.display="none";      
        document.getElementById(iddivpax3).style.visibility="hidden";
        document.getElementById(iddivpax4).style.display="none";      
        document.getElementById(iddivpax4).style.visibility="hidden";
        document.getElementById(iddivpax5).style.display="none";      
        document.getElementById(iddivpax5).style.visibility="hidden";
    }
    else{
        if(document.getElementById(idddlRooms).value=="2")
        {
            document.getElementById(iddivpax2).style.display="block";      
            document.getElementById(iddivpax2).style.visibility="visible";
            document.getElementById(iddivpax3).style.display="none";      
            document.getElementById(iddivpax3).style.visibility="hidden";
        }
        else if(document.getElementById(idddlRooms).value=="3")
        {
            document.getElementById(iddivpax2).style.display="block";      
            document.getElementById(iddivpax2).style.visibility="visible";
            document.getElementById(iddivpax3).style.display="block";      
            document.getElementById(iddivpax3).style.visibility="visible";
            document.getElementById(iddivpax4).style.display="none";      
            document.getElementById(iddivpax4).style.visibility="hidden";
            document.getElementById(iddivpax5).style.display="none";      
            document.getElementById(iddivpax5).style.visibility="hidden";
        }
        else if(document.getElementById(idddlRooms).value=="4")
        {
            document.getElementById(iddivpax2).style.display="block";      
            document.getElementById(iddivpax2).style.visibility="visible";
            document.getElementById(iddivpax3).style.display="block";      
            document.getElementById(iddivpax3).style.visibility="visible";
            document.getElementById(iddivpax4).style.display="block";      
            document.getElementById(iddivpax4).style.visibility="visible";
            document.getElementById(iddivpax5).style.display="none";      
            document.getElementById(iddivpax5).style.visibility="hidden";
        }
        else if(document.getElementById(idddlRooms).value=="5")
        {
            document.getElementById(iddivpax2).style.display="block";      
            document.getElementById(iddivpax2).style.visibility="visible";
            document.getElementById(iddivpax3).style.display="block";      
            document.getElementById(iddivpax3).style.visibility="visible";
            document.getElementById(iddivpax4).style.display="block";      
            document.getElementById(iddivpax4).style.visibility="visible";
            document.getElementById(iddivpax5).style.display="block";      
            document.getElementById(iddivpax5).style.visibility="visible";
        }
        else if(document.getElementById(idddlRooms).value=="1")
        {
            document.getElementById(iddivpax2).style.display="none";      
            document.getElementById(iddivpax2).style.visibility="hidden";
            document.getElementById(iddivpax3).style.display="none";      
            document.getElementById(iddivpax3).style.visibility="hidden";
            document.getElementById(iddivpax4).style.display="none";      
            document.getElementById(iddivpax4).style.visibility="hidden";
            document.getElementById(iddivpax5).style.display="none";      
            document.getElementById(iddivpax5).style.visibility="hidden";
        }
    }
    
}

function getElementsByClassName(classname) {
if (document.getElementsByTagName) {
var els = document.getElementsByTagName("*");
var c = new RegExp('/b^|' + classname + '|$/b');
final = new Array();
var n=0;
for (var i=0; i < els.length; i++) {
if (els[i].className) {
if(c.test(els[i].className)) {
final[n] = els[i];
n++;
}
}
}
return final;
} else{return false;}
}

function displayChildAgesForRooms
                (
                   idChildrenSelected,
                   sRoomNo,
                   idhidSearchOptionSelected
                )
{
        if(document.getElementById(idhidSearchOptionSelected).value != "F")
        {
            $(".clsdivRoomChildAges").css({display: 'block'});
            $(".clsdivRoomChildAges").css({visibility: 'visible'});
             
            var valChildrenSelected = document.getElementById(idChildrenSelected).value;
            if(valChildrenSelected >= 1)
            {
                $(".divRoom" + sRoomNo +"ChildAges").css({display: 'block' });
                $(".divRoom" + sRoomNo +"ChildAges").css({visibility: 'visible'});
            }
            else
            {
                $(".divRoom" + sRoomNo +"ChildAges").css({display: 'none'});
                $(".divRoom" + sRoomNo +"ChildAges").css({visibility: 'hidden'});
            }
            for(var i=1;i<=5;i++)
            {
                if(i<=valChildrenSelected)
                {   
                    $(".divRoom" + sRoomNo + "Child" + i +"Ages").css({display: 'block'});
                    $(".divRoom" + sRoomNo + "Child" + i +"Ages").css({visibility: 'visible'});
                }
                else
                {
                    $(".divRoom" + sRoomNo + "Child" + i +"Ages").css({display: 'none'});
                    $(".divRoom" + sRoomNo + "Child" + i +"Ages").css({visibility: 'hidden'});
                }
            }
        }
        else
        {
            //alert("Flights");
             $(".clsdivRoomChildAges").css({display: 'none'});
             $(".clsdivRoomChildAges").css({visibility: 'hidden'});
        }
}

function setReturnsDate(ddlDay,ddlMon,hidDate,
                        ddlRtnDay,ddlRtnMon,hidRtnDate)
{
    if(document.getElementById(ddlMon).value != "")
    {
        PopulateDays(ddlDay,ddlMon)
        if (document.getElementById(ddlDay).value == "")
        {
            document.getElementById(hidDate).value = document.getElementById(ddlMon).value;
        
            if(ddlRtnMon)
            {
                document.getElementById(ddlRtnMon).value = document.getElementById(ddlMon).value;
                PopulateDays(ddlRtnDay,ddlRtnMon);
            }   
        }
    }
    
    setDate(ddlDay,ddlMon,hidDate)
    
    if((document.getElementById(ddlDay).value == "")
        && (document.getElementById(ddlMon).value!=""))
    {
        if((hidRtnDate) && (ddlRtnMon))
        {
            document.getElementById(hidRtnDate).value = document.getElementById(ddlRtnMon).value;
         }   
    }
}

function setDate(ddlDay,ddlMon,hidDate,
                 ddlRtnDay,ddlRtnMon,hidRtnDate)
{
    var arrMonthYear; 
    if((document.getElementById(ddlMon).value != "")
        && (document.getElementById(ddlDay).value != ""))
    {
        document.getElementById(hidDate).value = document.getElementById(ddlDay).value + 
                                                    "/" + 
                                                    document.getElementById(ddlMon).value ;
        
        if((ddlRtnDay) && (ddlRtnMon))
        {
            //alert("set return date");
            arrMonthYear = document.getElementById(ddlMon).value.split("/");                                            
            var dDepDate = new Date(arrMonthYear[1],arrMonthYear[0]-1, document.getElementById(ddlDay).value);
            var dRtnDate = new Date(dDepDate.getTime() + 7*24*60*60*1000 ); 
            //Populate and Set Return Days
            //alert(dRtnDate);
            var sDate = dRtnDate.getDate() + "/" + (dRtnDate.getMonth() + 1) + "/" + dRtnDate.getFullYear();
            document.getElementById(hidRtnDate).value = sDate;
            PopulateDays(ddlRtnDay,ddlRtnMon,sDate);
        }
    }
}

function PopulateDays(ddlDay,ddlMon,sDate)
{
    var arrMonthYear; 
    var ileapYear;
    var icurYear;
    var icurMon;
    var dt= new Date();
    var iStartDay = 1;
    var iOptCnt = 0;
    
    if(sDate)
    {
        //alert("Date Provided");
        arrMonthYear = sDate.split("/");
        ileapYear = arrMonthYear[2] % 4;
        icurYear = arrMonthYear[2];
        icurMon = arrMonthYear[1].trim();
    }
    else
    {
        //alert("Date Not Provided");
        arrMonthYear = document.getElementById(ddlMon).value.split("/");
        ileapYear = arrMonthYear[1] % 4;
        icurYear = arrMonthYear[1];
        icurMon = arrMonthYear[0];
     }   
    
    
    if((dt.getMonth()+ 1 == icurMon) && 
        (dt.getFullYear() == icurYear))
    {
        iStartDay = dt.getDate();
    }
    
    removeAllOptions(document.getElementById(ddlDay));
    
    newOpt=new Option; 
    newOpt.value="";
    newOpt.text="Day";	
	document.getElementById(ddlDay).options[iOptCnt]=null;
    document.getElementById(ddlDay).options[iOptCnt++]=newOpt;
	            
    for (var intDay = iStartDay; intDay <= 31; intDay++)
    {
         if (icurMon == 4 || icurMon == 6 || icurMon == 9 || icurMon == 11)
         {
             if (intDay <= 30)
             {
		        newOpt=new Option; 
	            newOpt.value= "" + intDay;
		        newOpt.text="" + intDay;	
            	document.getElementById(ddlDay).options[iOptCnt]=null;
	            document.getElementById(ddlDay).options[iOptCnt]=newOpt;
	         }
         }
         if (icurMon == 2)
         {
            if (ileapYear == 0)
            {
                 if (intDay <= 29)
                 {
		            newOpt=new Option; 
	                newOpt.value="" + intDay;
		            newOpt.text="" + intDay;	
            	    document.getElementById(ddlDay).options[iOptCnt]=null;
	                document.getElementById(ddlDay).options[iOptCnt]=newOpt;
    		    }

            }
            else
            {
                 if (intDay <= 28)
                 {
		            newOpt=new Option; 
	                newOpt.value="" + intDay;
		            newOpt.text="" + intDay;	
            	    document.getElementById(ddlDay).options[iOptCnt]=null;
	                document.getElementById(ddlDay).options[iOptCnt]=newOpt;
	             }    
		    }
         }
                
         if (icurMon == 1 || icurMon == 3 || icurMon == 5 || icurMon == 7 || icurMon == 8 || icurMon == 10 || icurMon == 12)
	    {
		     newOpt=new Option; 
	         newOpt.value="" + intDay;
		     newOpt.text="" + intDay;	
             document.getElementById(ddlDay).options[iOptCnt]=null;
	         document.getElementById(ddlDay).options[iOptCnt]=newOpt;
	    }
	    
	    iOptCnt++;
	   }
	   
	   if(sDate)
       {
            //alert(icurMon + "/" + icurYear);
            if (arrMonthYear[0].substring(0,1) == '0')
            {
                arrMonthYear[0] = arrMonthYear[0].substring(1, arrMonthYear[1].length);
                //alert(arrMonthYear[0]);
            }
            
            document.getElementById(ddlDay).value = arrMonthYear[0];
            /*for(i=0;i<document.getElementById(ddlMon).length;i++)
            {
                alert(document.getElementById(ddlMon).options[i].value + "-" + arrMonthYear[1] + "/" + arrMonthYear[2]);
                if(document.getElementById(ddlMon).options[i].value==arrMonthYear[1] + "/" + arrMonthYear[2])
                {
                    document.getElementById(ddlMon).selectedIndex=i;
                }
            }*/
            
            if (arrMonthYear[1].substring(0,1) == '0')
            {
                arrMonthYear[1] = arrMonthYear[1].substring(1, arrMonthYear[1].length);
                //alert(arrMonthYear[1]);
            }
            document.getElementById(ddlMon).value = arrMonthYear[1] + "/" + arrMonthYear[2];
       }
	  
}

function removeAllOptions(selectbox)
{
    var i;
    for(i=selectbox.options.length-1;i>=0;i--)
    {
        selectbox.remove(i);
    }
}


function validateSearchFor(hidSearchOptionSelected,
                           ddlFrom,ddlTo,
                           ddlDepDay,ddlDepMonYear,
                           ddlRtnDay,ddlRtnMonYear,
                           txtFindAccommodation,
                           ddlcheckInDay,
                           ddlcheckInMon,
                           ddlcheckOutDay,
                           ddlcheckOutMon,
                           ddlAccommCountry,
                           ddlAccommAirport,
                           ddlAccommResort,
                           hidAccomFilterSelected,
                           hidSelAccomAirportCodes,
                           hidSelAccomResortCodes,
                           sAbsolutePath)
{
    //alert(document.getElementById(hidSearchOptionSelected).value);
    if(document.getElementById(hidSearchOptionSelected).value != "A")
    {
        if(document.getElementById(ddlFrom).value == "")
        {
            alert("Please enter where you want to leave From.");
            return false;
        }
        if(document.getElementById(ddlTo).value == "")
        {
            alert("Please enter where you want to travel.");
            return false;
        }
        if(document.getElementById(ddlDepMonYear).value == "")
        {
            alert("Please enter your departure month/year.");
            return false;
        }
        if(document.getElementById(ddlDepDay).value == "")
        {
            alert("Please enter your departure day.");
            return false;
        }
        if(document.getElementById(ddlRtnMonYear).value == "")
        {
            alert("Please enter your return month/year.");
            return false;
        }
        if(document.getElementById(ddlRtnDay).value == "")
        {
            alert("Please enter your return day.");
            return false;
        }
        
        
        var arrMonYear = document.getElementById(ddlDepMonYear).value.split("/");
        var dDepDate = new Date(arrMonYear[1],arrMonYear[0] - 1,
                        document.getElementById(ddlDepDay).value);
        
        arrMonYear = document.getElementById(ddlRtnMonYear).value.split("/");                
        var dRtnDate = new Date(arrMonYear[1],arrMonYear[0] - 1,
                        document.getElementById(ddlRtnDay).value);
                                    
        if(dRtnDate <= dDepDate)
        {
            alert("The return date must be at least a day after the departure date.");
            return false;
        }
    }
    else
    {
        if(document.getElementById(ddlAccommCountry).value == "")
        {
            alert("Please enter the country.");
            return false;
        }
        
        /*alert("AccomFilterSelected" + document.getElementById(hidAccomFilterSelected).value + "!");
        alert("hidSelAccomAirportCodes" + document.getElementById(hidSelAccomAirportCodes).value + "!");
        alert("hidSelAccomResortCodes" + document.getElementById(hidSelAccomResortCodes).value + "!");*/
        
        if(document.getElementById(hidAccomFilterSelected).value == "N")
        {
            if(document.getElementById(txtFindAccommodation).value == "")
            {
                alert("Please enter where you want to stay.");
                return false;
            }
        }
        else if(document.getElementById(hidAccomFilterSelected).value == "A") 
        {
           if(document.getElementById(hidSelAccomAirportCodes).value == "")
            {
                alert("Please enter Destination Airport.");
                return false;
            }
        }
        else if(document.getElementById(hidAccomFilterSelected).value == "R") 
        {
           if(document.getElementById(hidSelAccomResortCodes).value == "")
            {
                alert("Please enter Destination Resort.");
                return false;
            }
        }
        
        if(document.getElementById(ddlcheckInMon).value == "")
        {
            alert("Please enter check in month.");
            return false;
        }
        if(document.getElementById(ddlcheckInDay).value == "")
        {
            alert("Please enter check in day.");
            return false;
        }
        if(document.getElementById(ddlcheckOutMon).value == "")
        {
            alert("Please enter check out month.");
            return false;
        }
        if(document.getElementById(ddlcheckOutDay).value == "")
        {
            alert("Please enter check out day.");
            return false;
        }
        
        var arrMonYear = document.getElementById(ddlcheckInMon).value.split("/");
        var dCheckInDate = new Date(arrMonYear[1],arrMonYear[0] - 1,
                        document.getElementById(ddlcheckInDay).value);
        
        arrMonYear = document.getElementById(ddlcheckOutMon).value.split("/");                
        var dCheckOutDate = new Date(arrMonYear[1],arrMonYear[0] - 1,
                        document.getElementById(ddlcheckOutDay).value);
        
        if(dCheckOutDate <= dCheckInDate)
        {
            alert("The check out date must be at least a day after the check in date.");
            return false;
        }                   
    }
    
    if(document.images.imgWait!=null)
   {
        $("#divWait").removeClass("hide");
        //$("#divWrapper").addClass("hide");
        if(sAbsolutePath.indexOf("localhost")!=-1)
            setTimeout('document.images["imgWait"].src = "http://localhost/planet/Images/wait_holiday_search.gif"', 200); 
        /*else if(sAbsolutePath.indexOf("acer")!=-1)
            setTimeout('document.images["imgWait"].src = "http://acer/planet/Images/wait_holiday_search.gif"', 200); */
        else if(sAbsolutePath.indexOf("212.115.53.226")!=-1)  
        {
            setTimeout('document.images["imgWait"].src = "http://212.115.53.226/Images/wait_holiday_search.gif"', 200);             
        }
        else if(sAbsolutePath.indexOf("planet-holidays")!=-1)            
            setTimeout('document.images["imgWait"].src = "http://planet-holidays.co.uk/Images/wait_holiday_search.gif"', 200);                 
        
        //setTimeout(function(){sTemp(sAbsolutePath);}, 200); 
    }
//    if(document.images.imgWait!=null)
//    {
        //$("#divWait").removeClass("hide");
        //setTimeout('document.images["imgWait"].src = "../Images/wait.gif"', 200); 
        
        //var sTemp = 'document.images["imgWait"].src =' + sAbsolutePath + '/Images/wait.gif'; 
        //setTimeout(function(){sTemp(sAbsolutePath);}, 200); 
        //setTimeout("sTemp(sAbsolutePath)", 200); 
        
        //setTimeout('document.images["imgWait"].src ='
//   }

    return true;
}

function sTemp(sAbsolutePath)
{
    //alert("'document.images[\"imgWait\"].src =\"" + sAbsolutePath + "/Images/wait.gif\"'");
    return "'document.images[\"imgWait\"].src =\"" + sAbsolutePath + "/Images/wait.gif\"'"; 
}
function displayAccomSearchOptions
                (
                   idrboAccomFilterAirport,
                   idrboAccomFilterResort,
                   idrboAccomFilterName,
                   hidAccomFilterSelected,
                   idhidSelAccomAirportCodes,
                   idhidSelAccomResortCodes,
                   iddivAccommAirport,
                   iddivAccommResort,
                   iddivAccommName
                )
{
    document.getElementById(idhidSelAccomAirportCodes).value="";
    document.getElementById(idhidSelAccomResortCodes).value="";
    if(document.getElementById(idrboAccomFilterAirport).checked)
    {  
        document.getElementById(hidAccomFilterSelected).value = "A";
        document.getElementById(iddivAccommAirport).style.display="block";  
        document.getElementById(iddivAccommAirport).style.visibility="visible";  
        document.getElementById(iddivAccommResort).style.display="none";      
        document.getElementById(iddivAccommResort).style.visibility="hidden";
        document.getElementById(iddivAccommName).style.display="none";      
        document.getElementById(iddivAccommName).style.visibility="hidden";
        
    }
    else if(document.getElementById(idrboAccomFilterResort).checked)
    {
        document.getElementById(hidAccomFilterSelected).value = "R";
        document.getElementById(iddivAccommAirport).style.display="none";  
        document.getElementById(iddivAccommAirport).style.visibility="hidden";  
        document.getElementById(iddivAccommResort).style.display="block";      
        document.getElementById(iddivAccommResort).style.visibility="visible";
        document.getElementById(iddivAccommName).style.display="none";      
        document.getElementById(iddivAccommName).style.visibility="hidden";
    }
    else if(document.getElementById(idrboAccomFilterName).checked)
    {
        document.getElementById(hidAccomFilterSelected).value = "N";
        document.getElementById(iddivAccommAirport).style.display="none";  
        document.getElementById(iddivAccommAirport).style.visibility="hidden";  
        document.getElementById(iddivAccommResort).style.display="none";      
        document.getElementById(iddivAccommResort).style.visibility="hidden";
        document.getElementById(iddivAccommName).style.display="block";      
        document.getElementById(iddivAccommName).style.visibility="visible";
    }
}


function fillAccomCriteria(obj, 
                        idddlAccommAirport,
                        idddlAccommResort,
                        idhidAccommCountryCodes,
                        idhidAccommCountryNames,
                        idhidAccomAirportCodes,
                        idhidAccomAirportNames,
                        idhidAccomResortCodes,
                        idhidAccomResortNames,
                        idhidAccomCodes,
                        idhidAccomNames,
                        idhidSelAccomCodes,
                        idhidSelAccomNames,
                        idhidSelAccomCountryCodes)
{
    
    document.getElementById(idhidSelAccomCountryCodes).value = obj.value;
    
    var arrAccomCountryNames = document.getElementById(idhidAccommCountryNames).value.split("*");
    var arrAccomCountryCodes = document.getElementById(idhidAccommCountryCodes).value.split("*");
    
    var arrAccomAirportNames = document.getElementById(idhidAccomAirportNames).value.split("*");
    var arrAccomAirportCodes = document.getElementById(idhidAccomAirportCodes).value.split("*");
    
    var arrAccomResortNames = document.getElementById(idhidAccomResortNames).value.split("*");
    var arrAccomResortCodes = document.getElementById(idhidAccomResortCodes).value.split("*");
    
    var arrAccomNames = document.getElementById(idhidAccomNames).value.split("*");
    var arrAccomCodes = document.getElementById(idhidAccomCodes).value.split("*");
    
    document.getElementById(idddlAccommAirport).options.length = 0;
    document.getElementById(idddlAccommResort).options.length = 0;
    
    for(var i=0;i<arrAccomCountryCodes.length;i++)
    {
        if( arrAccomCountryCodes[i] == obj.value )
        {   
            var arrSubAccomAirportNames = arrAccomAirportNames[i].split(sSV);
            var arrSubAccomAirportCodes = arrAccomAirportCodes[i].split(sSV);
            
            newOpt=new Option; 
            newOpt.value="";
            newOpt.text="Choose Destination Airport";
            document.getElementById(idddlAccommAirport).options[0]=null;
            document.getElementById(idddlAccommAirport).options[0]=newOpt;
            
            cnt=1;             
            for(var j=0;j<arrSubAccomAirportCodes.length;j++)
            {       
                newOpt=new Option; 
                newOpt.value=arrSubAccomAirportCodes[j];
                newOpt.text=arrSubAccomAirportNames[j];
                document.getElementById(idddlAccommAirport).options[cnt]=null;
                document.getElementById(idddlAccommAirport).options[cnt]=newOpt;
                cnt++;
            }
            
            var arrSubAccomResortNames = arrAccomResortNames[i].split(sSV);
            var arrSubAccomResortCodes = arrAccomResortCodes[i].split(sSV);
            
            newOpt=new Option; 
            newOpt.value="";
            newOpt.text="Choose Destination Resort";
            document.getElementById(idddlAccommResort).options[0]=null;
            document.getElementById(idddlAccommResort).options[0]=newOpt;
            
            cnt=1;             
            for(var j=0;j<arrSubAccomResortCodes.length;j++)
            {       
                newOpt=new Option; 
                newOpt.value=arrSubAccomResortCodes[j];
                newOpt.text=arrSubAccomResortNames[j];
                document.getElementById(idddlAccommResort).options[cnt]=null;
                document.getElementById(idddlAccommResort).options[cnt]=newOpt;
                cnt++;
            }
            
            //Names
            document.getElementById(idhidSelAccomCodes).value = arrAccomCodes[i];
            document.getElementById(idhidSelAccomNames).value = arrAccomNames[i];
            
            var arrSubAccomNames = arrAccomNames;
            //var arrSubAccomCodes = arrAccomCodes[i].split(sSV);
            //cnt=0;             
            //var stempStr = "";
            var x;
            var tmp;
            
            for (x in arrAccomNames) {
                tmp = arrAccomNames[x].split("ü");
                arrSubAccomNames[x] = tmp[0].replace(" - ", ""); 
            }
                                   
            $(".clsFindAccommodation").autocompleteArray(arrSubAccomNames);            
         }
         else{}
     }
     document.getElementById(idddlAccommAirport).options[0].selected = true;
     document.getElementById(idddlAccommResort).options[0].selected = true;
 }


function validateAccomSelect(idhidRoomCnt,
                             sresAccomKeys,
                             idhidRoomTypeCnt,
                             idhidRoomTypeCatsSelected)
{
    var srbID =  sresAccomKeys;
    document.getElementById(idhidRoomTypeCatsSelected).value = "";
    var nNoOfRoomsSel = 0;
    for(var i=0;i<parseInt(document.getElementById(idhidRoomTypeCnt).value);i++)
    {
        if(nNoOfRoomsSel >= parseInt(document.getElementById(idhidRoomCnt).value))
            break;
            
        if(document.getElementById(srbID + "_" + i.toString()))
        {
            if(document.getElementById(srbID + "_" + i.toString()).checked)
            {
                nNoOfRoomsSel++;
                if(document.getElementById(idhidRoomTypeCatsSelected).value == "")
                {
                    document.getElementById(idhidRoomTypeCatsSelected).value = 
                          document.getElementById(srbID + "_" + i.toString()).value;       
                 }
                 else
                 {
                    document.getElementById(idhidRoomTypeCatsSelected).value = 
                          document.getElementById(idhidRoomTypeCatsSelected).value
                          + sMV  
                          + document.getElementById(srbID + "_" + i.toString()).value;       
                 }
             }
        }
        
    }
    
    if(nNoOfRoomsSel < parseInt(document.getElementById(idhidRoomCnt).value))
    {
        
        alert("Selected rooms can't be less than total number of Rooms");
        return false;
    }
    else
    {
        return true;
    }
}


function MultipleFieldsValidatorEvaluateIsValid(val) {
 
    controltovalidateIDs = val.controlstovalidate.split(',');
    //alert(controltovalidateIDs);
    switch (val.condition) {
        case 'OR':
            for(var controltovalidateIDIndex in controltovalidateIDs) {
                var controlID = controltovalidateIDs[controltovalidateIDIndex];
                if (ValidatorTrim(ValidatorGetValue(controlID)) != '') {
                    return true;
                } 
            }
            return false;
        break;
        case 'XOR':
            for(var controltovalidateIDIndex in controltovalidateIDs) {
                var controlID = controltovalidateIDs[controltovalidateIDIndex];
                if (controltovalidateIDIndex == '0') {
                    var previousResult = !(ValidatorTrim(ValidatorGetValue(controlID)) == '');
                    continue;
                }
                var currentResult = !(ValidatorTrim(ValidatorGetValue(controlID)) == '');
                if (currentResult != previousResult) {
                    return true;
                }
                previousResult != currentResult;
            }
            return false;
        break;
        case 'AND':
            for(var controltovalidateIDIndex in controltovalidateIDs) {
                var controlID = controltovalidateIDs[controltovalidateIDIndex];
                if (ValidatorTrim(ValidatorGetValue(controlID)) == '') {
                    return false;
                } 
            }
            return true;
        break;
        case 'CUSTOM':
            for(var controltovalidateIDIndex in controltovalidateIDs) {
                var controlID = controltovalidateIDs[controltovalidateIDIndex];
                var control;
                var chkControlChecked;
                var otherControlEmpty;
                control = document.getElementById(controlID);
                
                if (control.type == "checkbox" )
                {
                    //alert(controlID);
                    if (control.checked)
                        chkControlChecked = true;
                        //return true;
                }
                if (ValidatorTrim(ValidatorGetValue(controlID)) == '') {
                    otherControlEmpty = true
                    
                } 
            }
            if(chkControlChecked && otherControlEmpty) 
                return false;
            else
                return true;
        break;
       case 'MANDATORYCHECKBOX':
            for(var controltovalidateIDIndex in controltovalidateIDs) {
                var controlID = controltovalidateIDs[controltovalidateIDIndex];
                var control;
                var chkControlChecked;
                var otherControlEmpty;
                control = document.getElementById(controlID);
                
                if (control.type == "checkbox" )
                {
                    if (control.checked){
                        return true;
                     }
                     return false;
                }
               
            }
            
        break;
      case 'BIRTHDATE':
        var sBirthDate="";
        var sRtnDate="";
        var sAge="";
        var sPaxType="";
        var control;
        var paxAge;
        //alert(controltovalidateIDs);
        for(var controltovalidateIDIndex in controltovalidateIDs) 
        {
            var controlID = controltovalidateIDs[controltovalidateIDIndex];
            control = document.getElementById(controlID);
            
            if(control!=null)
            {
                if (control.type == "text" )
                {
                    if (ValidatorTrim(ValidatorGetValue(controlID)) != '') 
                    {
                        sBirthDate = ValidatorTrim(ValidatorGetValue(controlID));
                        //alert(sBirthDate);
                    }
                } 
                
                 /*if (control.type == "select-one" )
                 {
                    sAge = ValidatorTrim(ValidatorGetValue(controlID));
                    //alert(sAge);
                 } */
                
                if (control.type == "hidden" )
                {
                    //alert(control.type);
                    var stemp = ValidatorTrim(ValidatorGetValue(controlID))
                    //var stemp = control.value;
                    if (stemp != '') 
                    {
                        if(stemp.indexOf("/")!= -1)
                        {
                            sRtnDate = stemp;
                        }
                        else
                        {
                            sPaxType = stemp;
                        }
        
                    }
                } 
            }
        }   //End of For Loop 
        
        if(sBirthDate != "" )
        {
            var DOBdmy = (sBirthDate).split('/');
            //Bdate = new Date(DOBdmy[2],DOBdmy[1]-1,DOBdmy[0]);
            //BDateArr = (''+Bdate).split(' ');
            var Rtndmy = sRtnDate.split('/');
            //Rdate = new Date(Rtndmy[2],Rtndmy[1]-1,Rtndmy[0]);
            var y = Rtndmy[2];
            var m = Rtndmy[1];
            var d = Rtndmy[0];
            
            var Age = (y-DOBdmy[2]);
            if (m <= DOBdmy[1] && d < DOBdmy[0])
            {
                paxAge = Age - 1;
            }
            else if(m > DOBdmy[1] )
            {
                paxAge = Age + 1;
            }
            else if(m >= DOBdmy[1] &&  d >= DOBdmy[0])
            {
                paxAge = Age + 1;
            }
            if(sPaxType == 'C')
            {
                if(paxAge <=12)
                    return true;
                else
                    return false;
            }
            else if(sPaxType == 'I')
            {
                if(paxAge <=1)
                    return true;
                else
                    return false;
            }
         }
         return true;
 }
    return true;
}       
       
    


Date.prototype.getAgeInYears = function () {
    var now = new Date(); 
    var d = new Date(this.getTime()); 
    d.setYear(now.getFullYear()); 
    return d > now ? now.getFullYear() - this.getFullYear() - 1 : now.getFullYear() - this.getFullYear()
}

function link_popup(url,width,height,scrollbar)
{
    window.open(url,'Register','menubar=0,status=0,location=0,toolbar=0,width=' + width + ',height=' + height + ',scrollbars=' + scrollbar );
}

function close_popup()
{
    window.close();
}

function changeImgBorder(iddivimgAccom,bHighlightImage)
{
    if(bHighlightImage == "1")
        document.getElementById(iddivimgAccom).className="HighlightHolDtlsImgStyle floatLeft";
    else
        document.getElementById(iddivimgAccom).className="HolDtlsImgStyle floatLeft";    
        
}

function AddCreditCardCharge(idddlCardType,    
                                    idlblSubTotal,
                                    idhidOrigSubTotal)
{
    
    
    var sCardType= document.getElementById(idddlCardType).value;
    var shidOrigSubTotal= document.getElementById(idhidOrigSubTotal).value;
    
    //alert(slblSubTotal);
    //alert(slblAuthoriseAmount);
    //alert(shidOrigSubTotal);
    
    if(sCardType=="MAS" || sCardType=="VIS")
    {
        var stempAmt = (parseFloat(shidOrigSubTotal) * ((103/100))).toFixed(2);
        
        setLabelValue(document.getElementById(idlblSubTotal),"£" + stempAmt);
        
        /*document.getElementById(iddivlblCardCharge).style.display="block";
        document.getElementById(iddivlblCardCharge).style.visibility="visible";*/
    }
    else
    {
        //alert(parseFloat(shidOrigSubTotal) + parseFloat(1));
        setLabelValue(document.getElementById(idlblSubTotal),"£" + (parseFloat(shidOrigSubTotal) + parseFloat(1)).toFixed(2) );
        
        
        /*document.getElementById(iddivlblCardCharge).style.display="none";
        document.getElementById(iddivlblCardCharge).style.visibility="hidden";*/
    }
}
       
function displayDepositAmount(objThis,    
                            idDepositAmount,idlitTotalPayment,
                            idhidDepositAmount,idhidTotHolValue,
                            idtxtDepositAmount,idlblFinalTotal,
                            idddlCardType,idhidOrigSubTotal)
{
    
    //alert(objThis.value);
    var hidDepositAmount =  document.getElementById(idhidDepositAmount).value;
    var hidTotHolValue = document.getElementById(idhidTotHolValue).value;
    var sCardType = document.getElementById(idddlCardType).value;
    var txtDepositAmount = document.getElementById(idtxtDepositAmount).value;
    if(objThis.value == "F") 
    {
        document.getElementById(idDepositAmount).style.display="none";
        document.getElementById(idDepositAmount).style.visibility="hidden";
        document.getElementById(idtxtDepositAmount).value = hidTotHolValue;
        setLabelValue(document.getElementById(idlblFinalTotal),"£" + (parseFloat(0)).toFixed(2) );
    }
    else
    {
        document.getElementById(idDepositAmount).style.display="block";
        document.getElementById(idDepositAmount).style.visibility="visible";
        document.getElementById(idtxtDepositAmount).value = hidDepositAmount;
        setLabelValue(document.getElementById(idlblFinalTotal),"£" + (parseFloat(hidTotHolValue) - parseFloat(hidDepositAmount)).toFixed(2) );
    }
    
    if(sCardType != "")
    {
        AddCreditCardCharge(idddlCardType,idlitTotalPayment,idhidOrigSubTotal);
    }
    else
    {
        setLabelValue(document.getElementById(idlitTotalPayment),"£" + (parseFloat(txtDepositAmount)).toFixed(2) );
    }
}

function checkDepositAmount(idtxtDepositAmount,    
                            idhidDepositAmount,idhidTotHolValue,
                            idlitTotalPayment,idlblFinalTotal,
                            idddlCardType,idhidOrigSubTotal)
{
    var txtDepositAmount = document.getElementById(idtxtDepositAmount).value;
    var hidDepositAmount =  document.getElementById(idhidDepositAmount).value;
    var hidTotHolValue = document.getElementById(idhidTotHolValue).value;
    var sCardType = document.getElementById(idddlCardType).value;
    //alert("onblur");
    
    if(txtDepositAmount >= hidDepositAmount && txtDepositAmount <= hidTotHolValue )
    {
        setLabelValue(document.getElementById(idlblFinalTotal),"£" + (parseFloat(hidTotHolValue) - parseFloat(txtDepositAmount)).toFixed(2) );
        if(sCardType != "")
        {
            AddCreditCardCharge(idddlCardType,idlitTotalPayment,idtxtDepositAmount);
        }
        else
        {
            setLabelValue(document.getElementById(idlitTotalPayment),"£" + (parseFloat(txtDepositAmount)).toFixed(2) );
        }
        return true;
    }
    else if(txtDepositAmount < hidDepositAmount)
    {
        
        alert("Amount can't be less than " + hidDepositAmount);
        document.getElementById(idtxtDepositAmount).focus();
        return false;
    }
    else if(txtDepositAmount > hidTotHolValue)
    {
        alert("Amount can't be greater than " + hidTotHolValue);
        document.getElementById(idtxtDepositAmount).focus();
        return false;
    }
}

function setLabelValue(Ref, sValue)
{
    if ( Ref.textContent )
    {
        // Firefox...
        Ref.textContent = sValue;
        //alert("FireFox" + stroptionalExtrasValue);
    }
    else if ( Ref.innerText )
    {
        // IE...
        Ref.innerText = sValue;
        //alert("IE" + stroptionalExtrasValue);
    }
    else
    {
        // Default...
        Ref.innerHTML = sValue;
        /*var regExp = /<\/?[^>]+>/gi;
        sValue = sValue.replace(regExp, '');
        //alert("default" + stroptionalExtrasValue);*/
    }
    
    return sValue;
 }      