﻿//HomeMain.js File
var brNM = 'Microsoft';
var itC,tg,tBG,_stop,_val;
var who, ESC=27, TAB=9, ALT=18, UP=38, DOWN=40, LEFT=37, RIGHT=39, ENTER=13, SHIFT=16, lastKey=0, DEL = 46, _rqDestRev = 0, _rqDest=0, _rqHotelRev = 0;
var enEnt = true;
var hRV=null; var _rqDest=0;
var IsHomeNewLoaded=false;

function _$e(e){ return document.getElementsByTagName(e)};
function crE(e) { return document.createElement(e)}
function crTN(e) { return document.createTextNode(e)}
function CreateXmlHttp()
{
    var XmlHttp;
    try { XmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e) { try { XmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }  catch(oc) { XmlHttp = null; } }
    if(!XmlHttp && typeof XMLHttpRequest != "undefined")  { XmlHttp = new XMLHttpRequest(); }
    return XmlHttp;
}
function LoadIntelli()
{
    checkloadjscssfile('/Search/javascript/HomeIntelli.js', 'js');
}
function LoadPopup()
{
    checkloadjscssfile('/Search/javascript/HomePopup.js', 'js');
}
function LoadTabJS()
{
    //checkloadjscssfile('/Search/ASHX/Scripts.ashx?JS=A,B&/Search/&<%=System.Configuration.ConfigurationManager.AppSettings["ScriptVersionNo"]%>&HomeNew', 'js');
}
function homeTab(_v)
{ 
    if(_cObj(_$('hidFnH'))) _$('hidFnH').value = _v 
    if(_v == '1') 
    {        
        _$('hotel_label').className = "selected"; 
        _$('lblDuration').innerHTML = "Duration";
        _$("divBoard").style.display = "none";
        _$('flightandhotel_label').className = "";
        _$('lblCin').innerHTML = "Check-in Date"; _$('lblCout').innerHTML = "Check-out Date";
        _$('divAir').style.display = "none";  _$("divHlnk").style.display = "none"; _$("divResort").style.display = "block"; _$("divRAR").style.display = "none";
        pDr("1", _$("ctl00_plhBody_ddlDuration"));              
        clearVal("e.g. Paris");rCk('Hotelly') ;hpCal('');       
    }
    else//FNH 
    {         
         _$('flightandhotel_label').className = "selected";
        _$('lblDuration').innerHTML = "Duration (7,10,14)";
        _$("divBoard").style.display = "block";
       _$("divHlnk").style.display = "none";
       _$('hotel_label').className = "";
        _$('lblCin').innerHTML = "Departure Date"; _$('lblCout').innerHTML = "Return Date";
        pDr("0", _$("ctl00_plhBody_ddlDuration"));        
        _$('divAir').style.display = "block"; _$("divHlnk").style.display = "none"; _$("divRAR").style.display = "none"; _$("divResort").style.display = "none";        
        checkJsStatus();      
    }     
}
function checkJsStatus()
{
     if(!IsHomeNewLoaded){setTimeout("checkJsStatus()" , 3);}
     //else{clearVal("e.g. Costa Del Sol"); _$("imgAirport").style.display = "inline";var ddlAirport = _$("ctl00_plhBody_ddlAirport"); var _opI,_tV,_dId;if(ddlAirport.options.length<12){dIS('IATA', '184', '0');}setTimeout("rCk('FnHHotelly');_$('imgAirport').style.display = 'none';" , 200);}  
     else{clearVal("e.g. Costa Del Sol");setTimeout("rCk('FnHHotelly');" , 200);}  
}

var filesadded="" //list of files already added
function loadjscssfile(filename, filetype)
{
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

function checkloadjscssfile(filename, filetype)
{
 if (filesadded.indexOf("["+filename+"]")==-1){
  loadjscssfile(filename, filetype)
  filesadded+="["+filename+"]" //List of files added in the form "[filename1],[filename2],etc"
 }
//     else
//      alert("file already added!")
}

// Function required for destfocus()
function keypressed(keyCode, keyvalue)
{
    prsd = new Date().getTime();
    if((_cObj(_$("destDiv")) && _$("destDiv").style.display != "none" ) || (_cObj(_$("hotelRevDiv")) && _$("hotelRevDiv").style.display != "none" ) || (_cObj(_$("destRevDiv")) && _$("destRevDiv").style.display != "none" ))
    {
        switch (keyCode) {
            case LEFT:
            case UP:
                crsl = crsl - 1;
                if (crsl<0) { crsl=0; }
                selChc(crsl);
                break;
            case RIGHT:
            case DOWN:
                crsl++;
                if (crsl>=itC) { crsl=itC-1; }
                selChc(crsl);
                break;
            case ENTER:
                if (itC>0) { setValue(crsl); clIS(); }
                hdChc();
                break;
            case ESC:
                clIS();
                _stop = true;
                if(navigator.appName.indexOf(brNM) != -1 )
                if(event.srcElement.id == "ctl00_plhBody_txtDestination") { _$('ADes').focus(); }
                else if(event.srcElement.id == "ctl00_plhBody_txtHotelVideo") { _$('A1').focus(); }
                else if(event.srcElement.id == "ctl00_plhBody_txtDestVideo") { _$('A2').focus(); }
                break;
            case TAB:
                if (crsl>=0&&crsl<itC) { setValue(crsl); }
                hdChc();
                break;
            case ALT:
            case SHIFT:
                break;
            default:
                setValue(-1);
        }
    }
    else { return false; }
}
function disEnter(event)
{
    if (event.keyCode == 13 && enEnt) { event.returnValue=false; event.cancel = true; return false; }
}
function keyDown(e)
{
    var pK = document.all? window.event.keyCode:e.which; var pK2 = String.fromCharCode(pK).toLowerCase();  lastKey=pK; 
    if(who!=null) { who(pK, pK2); }
}
function keysInit(callback)
{ 
    document.onkeydown = keyDown; who=callback;
    if (document.layers) { document.captureEvents(Event.KEYPRESS); } 
}
function cnIS()
 {  
     keysInit(null); clIS();
 }
function clIS() 
{    
    if (tg!=null) {tg.style.display = 'none'; tg.innerHTML = ""; }
    if (tBG!=null) {tBG.style.display = 'none'; }    
    _stop = true;
}
function iDsIS()
{
    cnIS(); var body = _$e("body")[0]; _val = 'D'; tg = _$('destDiv');
    if (!tg)  { tg = crE("div"); tg.id = "destDiv"; tg.style.zIndex = 51; tg.style.position = 'absolute'; tg.style.display = 'none'; tg.style.width = 'auto'; body.appendChild(tg); }
    tBG = _$('destIFrame');
    if (!tBG) { tBG = crE("destIFrame"); tBG.id = "destIFrame"; tBG.style.zIndex = 50; tBG.setAttribute('scrolling', 'no'); tBG.setAttribute('frameborder', '0'); tBG.style.position = "absolute"; tBG.style.display = "none"; body.appendChild(tBG);}
    keysInit(keypressed); _ls = ""; crsl=-1; psl=-1; _stop = false;
}
function destfocus()
{    
    if(_$("ctl00_plhBody_txtDestination").value == "e.g. Paris" || _$("ctl00_plhBody_txtDestination").value == "Destination" || _$("ctl00_plhBody_txtDestination").value=="e.g. Costa Del Sol")
        _$("ctl00_plhBody_txtDestination").value = "";
    iDsIS();    
}

function conDate(d) { var x=d.split("-"); return x[1] + "/" + x[0] + "/" + x[2]; }
function hpCal(f)
{
    try{
    var ct = "ctl00_plhBody_"; var ci = "hotelCheckin"; var co = "hotelCheckout"; var cic = "checkinCalContainer";var coc = "checkoutCalContainer";
    var cio = "checkinValue";var coo = "checkoutValue";
    if(f!=undefined&&f!=''&&f!='0'){ci=ci+f;cio=ct+cio+f;co=co+f;coo=ct+coo+f;cic=cic+f;coc=coc+f;}
    else{ci=ct+ci+f;co=ct+co+f;cio=ct+cio+f;coo=ct+coo+f;}   
    setupCal(conDate(_$(cio).value), conDate(_$(coo).value), ci, co, cic, coc,2,f);}
    catch(e){}
}
function GFD(df)
{
    var f = _$("ctl00_Header1_hidDate").value; var mArr=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var dArr=['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
	var x = df.split("-"); var d = x[0]; var m = x[1]; var y = x[2]; var dt = new Date(); dt.setFullYear(y,m-1,d); var fD;
    switch(f) {
        case "dd/MM/yy": fD = d + '/' + m+ '/'+ y.substring(2,4); break;
        case "dd/MM/yyyy": fD = d + '/' + m+ '/'+ y; break;
        case "ddd MMM dd": var ddd = dArr[dt.getDay()]; var MMM = mArr[m-1]; fD = ddd + ' '+ MMM + ' '+ d; break;
        case "MM/dd/yy": fD = m+ '/' + d + '/'+ y.substring(2,4); break;
        case "MM/dd/yyyy": fD = m+ '/' + d + '/'+ y; break;
        case "MMM dd yy": var MMM = mArr[m-1]; fD = MMM + ' ' + d + ' '+ y.substring(2,4); break;
        default: return df;
    }
    return fD;
}
// For Destination section
function dRf()
{
    if(_$("ctl00_plhBody_txtDestVideo").value == "e.g. Paris")
        _$("ctl00_plhBody_txtDestVideo").value = "";
    iDRIS();
}
// For Hotel section
function hRf()
{
    if(_$("ctl00_plhBody_txtHotelVideo").value == "e.g. Napoleon Hotel Paris")
        _$("ctl00_plhBody_txtHotelVideo").value = "";
    iHRIS();
}
function iDRIS()
{
    cnIS(); var body = _$e("body")[0]; _val = 'DR'; tg = _$('destRevDiv');
    if (!tg) { tg = crE("div"); tg.id = "destRevDiv"; tg.style.zIndex = 51; tg.style.position = 'absolute'; tg.style.display = 'none'; tg.style.width = 'auto'; body.appendChild(tg); }
    tBG = _$('destRevIFrame');
    if (!tBG) { tBG = crE("destRevIFrame"); tBG.id = "destRevIFrame"; tBG.style.zIndex = 50; tBG.setAttribute('scrolling', 'no'); tBG.setAttribute('frameborder', '0'); tBG.style.position = "absolute"; tBG.style.display = "none"; body.appendChild(tBG); }
    keysInit(keypressed); _ls = ""; crsl=-1; psl=-1; _stop = false;
}
function iHRIS()
{
    cnIS(); var body = _$e("body")[0]; _val = 'HR'; tg = _$('hotelRevDiv');
    if (!tg) { tg = crE("div"); tg.id = "hotelRevDiv"; tg.style.zIndex = 51; tg.style.position = 'absolute'; tg.style.display = 'none'; tg.style.width = 'auto'; body.appendChild(tg); }
    tBG = _$('hotelRevIFrame');
    if (!tBG) { tBG = crE("hotelRevIFrame"); tBG.id = "HotelRevIFrame"; tBG.style.zIndex = 50; tBG.setAttribute('scrolling', 'no'); tBG.setAttribute('frameborder', '0'); tBG.style.position = "absolute"; tBG.style.display = "none"; body.appendChild(tBG);}
    keysInit(keypressed); _ls = ""; crsl=-1; psl=-1; _stop = false;
}
function ReplaceAll(text, strA, strB) 
{
    while ( text.indexOf(strA) != -1) { text = text.replace(strA,strB); } return text;
}
function CrFl(_val)
{
   var arrVal;   
   //_$("ctl00_Header1_hidCurKey").value = _val; 
   var ddlCur = _$("ctl00_Header1_ddlCur");   
   /*var arrVal=_val.split('||');
   _$("ctl00_Header1_hidCurKey").value = arrVal[0];
   sCurSn(_val);*/  
                        
   if(ddlCur.options.selectedIndex!=2)
   {
        if (_$("ctl00_Header1_showFnH").value== "1" && ddlCur.options.selectedIndex==1)
        {       
             arrVal=_val.split('||');
             _$("ctl00_Header1_hidCurKey").value = arrVal[0];
              sCurSn(_val);
             IntVer();
        }
        if (_$("ctl00_Header1_showFnH").value== "1" && ddlCur.options.selectedIndex!=1)        
             RstCrnIndex();
         
            
        if (_$("ctl00_Header1_showFnH").value!= "1")
        {
            if(ddlCur.options.selectedIndex==0)
            {            
                arrVal=_val.split('||');
                _$("ctl00_Header1_hidCurKey").value = arrVal[0];
                sCurSn(_val);
                FnHVer();
            }
            else if(ddlCur.options.selectedIndex==1)   
                 RstCrnIndex();
            else if(ddlCur.options.selectedIndex>2)
            {
                arrVal=_val.split('||');
                _$("ctl00_Header1_hidCurKey").value = arrVal[0];
                sCurSn(_val);    
             }                
         }          
    }
    else
        RstCrnIndex();
    
 }
 
function sCurSn(cKey)
{
    var arrVal=cKey.split('||');
    try { erCk("CurKey"); crCk("CurKey", arrVal[0], 0.0416); sCurVHome(cKey);}
    //try { erCk("CurKey"); crCk("CurKey", cKey, 0.0416); sCurVHome(cKey); _$("hidCur").value = cKey; }
    catch(e) { } 
}
function erCk(name) { crCk(name, "", -1); return false; }
function crCk(name, value, days)
{
   if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); }
   else  var expires = "";
   document.cookie = name+"="+value+expires+"; path=/"; return false;
}
function sCurVHome(cKey)
{
    if(cKey != "") 
    {
      var arrVal=cKey.split('||');
     _$("hidCur").value = arrVal[0];     
     _$("ctl00_Header1_imgCur").setAttribute('src',arrVal[1]);       
     //_$("hidCur").value = cKey; _$("ctl00_Header1_imgCur").setAttribute('src',cKey);
    }
}
// For analytics
function DCS(v1,v2,v3,v4,v5,v6) {try{
    var dt = new Date(); var v = v3+"|_|"+v4;
    if(_cObj(v5))v += "|_|"+v5;if(_cObj(v6)){v6 = v6+"|_|"+dt.getTime();v += "|_|"+v6;}else{v6 = dt.getTime();v += "|_|"+v6;}
    hAnalytics(v);
    saleTrack.addSaleItem(v1,v2,v3,v4,v5,v6); saleTrack.logSale(1); 
    gAnalytics(v);}catch(e){}
}
function hAnalytics(_v){
    try {
         var tD = new Date();var rU = "/Search/AjaxImpl.aspx?analytics=hotelly&v="+_v+"&dt="+ tD.getTime();
         var XmlHttp = CreateXmlHttp();
         if(XmlHttp) { XmlHttp.open("GET", rU, true); XmlHttp.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); XmlHttp.send(null); }
    }
    catch(e){}
}
function gAnalytics(v){
try{pageTracker._trackPageview(v);}catch(e){}
}
// For Video Popup
var bName = navigator.appName;
function _popup()
{
    document.body.scroll = "no";document.onscroll = function () { window.scrollTo(0,0); };
    if (bName == "Microsoft Internet Explorer")  document.body.scrollTop;
    //else { document.body.style.overflow = "hidden"; window.pageYOffset; }
    var dvFade = _$("divFade"); dvFade.style.display = "block"; dvFade.style.top = "0px"; dvFade.style.left = "0px"; dvFade.style.height = _$("main_content").offsetHeight;
    if(screen.width <1010) dvFade.style.width = _$("main_content").offsetWidth-20;
    else dvFade.style.width = screen.width;
    if (bName == "Microsoft Internet Explorer") {
        var dvFIF = _$("destFadeIFrame"); dvFIF.style.display = 'block'; dvFIF.style.top = "0px"; dvFIF.style.left = "0px";
        dvFIF.style.width = dvFade.offsetWidth-5; dvFIF.style.height = dvFade.offsetHeight-5;
    }
}
function _videoPopUp()
{
    _popup(); var dvVP = _$("_divVideoPopUp"); dvVP.style.display="block"
    var _top = ( (window.screen.availHeight) - (530/2) ) + "px"; var _left = ( (window.screen.availWidth/2) - (800/2) ) + "px";
    dvVP.style.top = "50px"; dvVP.style.left = _left; dvVP.className = "pop";
    if (bName == "Microsoft Internet Explorer") {
        var eIF = _$("destEmailIFrame"); eIF.style.display = 'block'; eIF.style.width = dvVP.offsetWidth-5;
        eIF.style.height = dvVP.offsetHeight-5; eIF.style.left = dvVP.style.left; eIF.style.top = dvVP.style.top;
    }
    dvVP.focus();
}
function VideoPop(hid)
{
  LoadPopup();
  var dvDM = _$("ctl00_plhBody_divDefaultMovie"); dvDM.innerHTML=''; dvDM.style.backGroundColor = "#FFFCE3"; 
  _$("divVideoPopUp").innerHTML='';
 _videoPopUp();
 var theDate = new Date(); var rU = "/Search/AjaxHome.aspx?hid="+hid+"&f="+hRV+"&dt="+ theDate.getTime();
 var XmlHttp = CreateXmlHttp();
 if(XmlHttp){ XmlHttp.onreadystatechange = function () {
        if(XmlHttp.readyState == 4) {
            if(XmlHttp.status == 200) { ShowPOP(XmlHttp.responseText); } }
    }
    XmlHttp.open("GET", rU, true); XmlHttp.send(null);		
 }
  DCS(1, 0, 'Home Page', 'Video Popup', hid, '');
}
function ShowPOP(tbl)
{
 var arData=tbl.split('|##|');
 var _dvVP = _$("divVideoPopUp");
 _dvVP.style.width="780px";
 _dvVP.innerHTML=arData[0];
 
 if(arData[1]!=null)
 {
    //crPly1("'" + arData[1] + "'",293,396,_$('ctl00_plhBody_dvVideo'),'true');
    //crPly1(arData[1],293,396,"_$('ctl00_plhBody_dvVideo')",'true');
    crPly1(arData[1],293,396,'dvVideo','true');
 }
 var emTD = _$('EmailTD'),arEM= emTD.innerHTML.split('|@|');
 var a = document.createElement("A"); a.href = "javascript:void(0);";a.onclick = function(){PopupEmail(arEM[0],arEM[1],3,'HP')};
 var i = document.createElement("IMG"); i.src = '/Search/images/1/email_to_friend.gif';a.appendChild(i);
 emTD.innerHTML='';emTD.appendChild(a);
}
function cPop(dv)
{
    if (bName != "Microsoft Internet Explorer") { document.body.style.overflow = "auto"; document.onscroll = true; }
    document.onscroll = true; dv.style.display="none"; _$("destEmailIFrame").style.display="none"; _$("destFadeIFrame").style.display="none"; _$("divFade").style.display = "none";
}     
function _closeVideoPopUp(f) {if(f!=0)crHPlyr(); cPop(_$("_divVideoPopUp")); }
function cDCS(_flag, _dcPrm, _dNm)
{
    if(_flag == "1") { DCS(1, 0, 'Home Page', 'Compare Prices', _dNm, _dcPrm ); }
    if(_flag == "6") { DCS(1, 0, 'Home Page', 'Compare Prices FnH', _dNm, _dcPrm ); }
    if(_flag == "7") { DCS(1, 0, 'FSRP', 'Compare Prices', _dNm, _dcPrm ); }
}
function urlUnEx(_p)
{
    _p = ReplaceAll(_p, " ", "_"); _p = ReplaceAll(_p, "&amp;", "and"); _p = ReplaceAll(_p, "&", "and");
    _p = ReplaceAll(_p, ",", ""); _p = ReplaceAll(_p, ":", ""); _p = ReplaceAll(_p, '"', "");
    _p = ReplaceAll(_p, "'", ""); _p = ReplaceAll(_p, "!", ""); _p = ReplaceAll(_p, "#", "");
    _p = ReplaceAll(_p, "$", ""); _p = ReplaceAll(_p, "%", ""); _p = ReplaceAll(_p, "*", "");
    _p = ReplaceAll(_p, ";", ""); _p = ReplaceAll(_p, "<", ""); _p = ReplaceAll(_p, ">", "");
    _p = ReplaceAll(_p, "=", ""); _p = ReplaceAll(_p, "?", ""); _p = ReplaceAll(_p, "@", "");
    _p = ReplaceAll(_p, "^", ""); _p = ReplaceAll(_p, "|", "");
    return _p;
}

function validatePriceSearch(_flag)
{  
    _rqDest += 1;
    if(_$("divDestMessage").style.display != "none") _$("divDestMessage").style.display = "none";
    if(_cObj(_$("divDestRevMessage"))) if(_$("divDestRevMessage").style.display != "none") _$("divDestRevMessage").style.display = "none";
    if(_cObj(_$("divHotelRevMessage"))) if(_$("divHotelRevMessage").style.display != "none") _$("divHotelRevMessage").style.display = "none";
    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2')
    {
         if(_$("ctl00_plhBody_txtDestination").value=="" || _$("ctl00_plhBody_txtDestination").value=="e.g. Paris" || _$("ctl00_plhBody_txtDestination").value=="e.g. Costa Del Sol")  {
            _$("divDidYouMeanDest").style.display = "none"; _$("divDestMessage").style.display = "block";_$("divDestMessage").style.height = "22px";_$("lblDestErrMessage").innerHTML = "Please enter a destination first!"; _$("lblHotelsCount").innerHTML = ""; return false;  }
        
        if(_$("ctl00_plhBody_hidDestValue").value =="" && _$("divHlnk").style.display == "none"){_$("divHlnk").style.display = "block";rstArRe();return false;}             
        
        if(_$("ctl00_plhBody_hidDestValue").value =="" && _$("divHlnk").style.display == "block")
            {_$("divDidYouMeanDest").style.display = "none"; _$("divDestMessage").style.display = "block";_$("divDestMessage").style.height = "22px";_$("lblDestErrMessage").innerHTML = "Please enter valid destination!"; _$("lblHotelsCount").innerHTML = ""; return false;  }
    }
    else
    {
        if(_$("ctl00_plhBody_txtDestination").value=="" || _$("ctl00_plhBody_txtDestination").value=="e.g. Paris" || _$("ctl00_plhBody_txtDestination").value=="e.g. Costa Del Sol")  {
        _$("divDidYouMeanDest").style.display = "none"; _$("divDestMessage").style.display = "block";_$("divDestMessage").style.height = "22px"; _$("lblDestErrMessage").innerHTML = "Please enter a destination first!"; _$("lblHotelsCount").innerHTML = ""; return false;  }
        if(_$("ctl00_plhBody_hidDestValue").value =="") { _$("divDestMessage").style.display = "none";
            if(_$("ctl00_plhBody_txtDestination").value!="")  {
            _$("ctl00_plhBody_hidDestSearchQuery").value = _$("ctl00_plhBody_txtDestination").value;
            gDstSQ(_$("ctl00_plhBody_txtDestination").value); }
        _$("ctl00_plhBody_txtDestination").focus(); _$("divDestMessage").style.display = "none"; return false;}  
    }
    
    if(_$("ctl00_plhBody_hotelCheckin").value=="") 
    {
        if(_cObj(_$('hidFnH')) && _$('hidFnH').value == '2')
            alert("Departure date can not be blank!"); 
         else       
            alert("Check-in date can not be blank!"); 
        return false; 
    }
    if(_$("ctl00_plhBody_hotelCheckout").value=="") 
    {
        if(_cObj(_$('hidFnH')) && _$('hidFnH').value == '2')
            alert("Return date can not be blank!"); 
        else        
            alert("Check-out date can not be blank!"); 
        return false;
    }
    if(_cObj(_$("txtEmail")) && _$("txtEmail").value != "" && _$("txtEmail").value != "Please enter your email") {
        if(!echeck(_$("txtEmail").value)) { alert("Please enter valid email address!"); return false; }
        else { saveSearchEmail(_$("txtEmail").value); }
    }
    if(_$("ctl00_plhBody_ddlRooms") != null) { var _rooms = _$("ctl00_plhBody_ddlRooms").value; var _rmV;
        if(_rooms>1) {  var _adultV = _$("ctl00_plhBody_ddlAdult").value;
            for(var _rmC=1; _rmC<_rooms; _rmC++) { var _adN = "ddlAdult" + _rmC; var _adV = _$(_adN).value; _adultV += ":" + _adV }
            var _chV = _$("ctl00_plhBody_ddlChildren").value;
            for(var _rmC=1; _rmC<_rooms; _rmC++) { var _adN = "ddlChildren" + _rmC; var _adV = _$(_adN).value; _chV += ":" + _adV }
            var _infantValue = _$("ctl00_plhBody_ddlInfants").value;
            for(var _rmC=1; _rmC<_rooms; _rmC++) { var _adN = "ddlInfants" + _rmC; var _adV = _$(_adN).value; _infantValue += ":" + _adV }
            _rmV = _adultV + ";" + _chV + ";" + _infantValue; _$("ctl00_plhBody_hidRoomValues").value = _rmV;
        }
    }
    var _dsN, _dsV, _rsN, _rsV, _cInV, _cOutV ; 
    if(_$("ctl00_plhBody_hidDestText").value == "") { _dsN = _$("ctl00_plhBody_hidDestText").value; _dsV = _$("ctl00_plhBody_hidDestValue").value; }
    if(_$("ctl00_plhBody_hidResortName").value == "") { _rsN = _$("ctl00_plhBody_hidDestText").value; _rsV = _$("ctl00_plhBody_hidDestValue").value; }
    _cInV = _$("ctl00_plhBody_checkinValue").value; _cOutV = _$("ctl00_plhBody_checkoutValue").value;
    var _adsV, _chdV, _infV, _drV, _rtV, _bdV, _rV;
    _adsV = _$("ctl00_plhBody_ddlAdult").value; _chdV = _$("ctl00_plhBody_ddlChildren").value; _infV = _$("ctl00_plhBody_ddlInfants").value;
    _rtV = _$("ctl00_plhBody_ddlRating").value; _bdV = _$("ctl00_plhBody_ddlBoard").value; _drV = _$("ctl00_plhBody_ddlDuration").value; _rV = _$("ctl00_plhBody_ddlRooms").value;
    _$("ctl00_plhBody_hidOptionValues").value = _drV + "|" + _bdV + "|" + _rtV + "|" + _rV + "|" + _adsV + "|" + _chdV + "|" + _infV;
    //Create QueryString for Price Result Page
    var _dsV, _cid, _sid, _cityid, _locId, _hId, _type, _dId, _rsId, _airId, _cInD, _cOutD, _lrN, _aid, _dstN, _board;
    _dstN = _$("ctl00_plhBody_hidDestText").value; var _dVal = _dstN.split(", ");
    if(_$("ctl00_plhBody_hidDestValue").value != "") {       
        _dsV = _$("ctl00_plhBody_hidDestValue").value.split(',');
        /*_cid = _dsV[0]; _sid = _dsV[1]; _cityid = _dsV[2]; _locId = _dsV[3]; _hId = _dsV[4]; _type = _dsV[5];
        if (_type != "C") { _dId = _locId; _locId = "0"; _rsId = _$("ctl00_plhBody_hidResortId").value; }
        else { _dId = "0"; _locId = _$("ctl00_plhBody_hidResortId").value; _rsId = "0"; }*/
        if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2')
        {
           _hId=0; _cid = _dsV[0]; _sid = _dsV[1]; _cityid = _dsV[2]; _dId = "0"; _locId = _dsV[4]; _type = _dsV[5];_rsId = "0";            
        }
        else
        {
           _hId=0; _cid = _dsV[0]; _sid = _dsV[1]; _cityid = _dsV[2]; _dId = "0";_locId = _$("ctl00_plhBody_hidResortId").value; _rsId = "0";_type = _dsV[5];
           _dstN=_dVal[1]+", "+_dVal[0]; _dVal=_dstN.split(', '); 
        }
        
    }
    _airId = "0";
    _cInD = _$("ctl00_plhBody_checkinValue").value; _cOutD = _$("ctl00_plhBody_checkoutValue").value;
    _lrN = _$("ctl00_plhBody_hidResortName").value; _aid = _$("ctl00_plhBody_hidAffiliateId").value;
    var _iataC,ddlApt=_$("ctl00_plhBody_ddlAirport"); if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2' && _cObj(ddlApt)) _iataC = ddlApt.value;if(_iataC =='-1'){alert('Please select a departure airport'); return false; } 
    _board = _$("ctl00_plhBody_ddlBoard").value; if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2' && _board =='-1'){alert('Please select a board basis'); return false; } 
    var _dNm = _$("ctl00_plhBody_hidDestText").value; 
    var _hNm = "",hdHotel=_$("ctl00_plhBody_hidHotelname"); if(_cObj(hdHotel)) if(hdHotel.value != "") _hNm = hdHotel.value
    var _dcPrm = "City Name : " + _dNm +" ; City Id : "+_dsV+" ; ";
    if(_hNm!= "") var _dcPrm = "Hotel Name : " + _hNm +" ; ";
    if(_cObj(_rsN)) if(_rsN != "") _dcPrm += "Location Name : " + _rsN +" ; Location Id : "+_rsV+" ; ";
    _dcPrm += "Check In : "+_cInV+" ; Check Out : "+_cOutV+" ; Duration : "+_drV+ " ; ";
    _dcPrm += "Rating : "+_rtV+" ; Adults : "+_adsV+" ; Childrens : " +_chdV+ " ; Infants : "+_infV;
    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') _dcPrm += "Airport : "+_iataC;
    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2'&& _flag=='1') _flag = "6";
    if(_cObj(_flag)) cDCS(_flag, _dcPrm, _dNm)
    // For Price Page Request
    if(_locId==' ' || _locId=='')_locId='0';if(_adsV=='')_adsV='2';if(_chdV=='')_chdV='0';
//    var _sb = _cid; _sb += "||"; _sb += _sid; _sb += "||"; _sb += _cityid; _sb += "||"; _sb += _locId; _sb += "||"; _sb += _dId; _sb += "||"; _sb += _type; _sb += "||"; _sb += _rsId; _sb += "||"; _sb += _airId; _sb += "||"; 
//    _sb += _hId; _sb += "||"; _sb += _cInD; _sb += "||";  _sb += _cOutD; _sb += "||"; _sb += _drV; _sb += "||"; _sb += _bdV; _sb += "||"; _sb += _board; _sb += "||"; _sb += _adsV; _sb += "||"; _sb += _chdV; _sb += "||"; 
//    _sb += _infV; _sb += "||"; _sb += _rV; _sb += "||"; _sb += _rtV; _sb += "||"; _sb += _aid; _sb += "||"; _sb += _lrN; _sb += "||"; _sb += _dstN; _sb += "||"; _sb += _dsV; _sb += "||"; _sb += _hNm;
    var _sb = _cid+"||"+_sid+"||"+_cityid+"||"+_locId+"||"+_dId+"||"+_type+"||"+_rsId+"||"+_airId+"||"+_hId+"||"+_cInD+"||"+_cOutD+"||"+_drV+"||"+_bdV;
    _sb +="||"+_board+"||"+_adsV+"||"+_chdV+"||"+_infV+"||"+_rV+"||"+_rtV+"||"+_aid+"||"+_lrN+"||";
    var tmp_sb=_sb;
    _sb+=_dstN+"||"+_dsV+"||"+_hNm;
    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') { _sb += "||"+_iataC+"||"+ddlApt.options[ddlApt.selectedIndex].text;  }
    
    //Create Cookie Items
    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') crCk("FnHHotelly", _sb, 1)
    else {var cVal=tmp_sb+_dVal[1]+", "+_dVal[0]+"||"+_dsV+"||"+_hNm; crCk("Hotelly", cVal, 1);}
    _$("hidPriceRequestValues").value = _sb;
    var _rName = _$("ctl00_plhBody_hidResortName").value; var _rsVal = _$("ctl00_plhBody_hidResortId").value;
    if(_rsVal == "") _rsVal = "0";
    var _postPage = "";      
    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2')
    {
     _postPage = "/Search/FlightHotelResult/";
     _postPage += _dVal[0] + "/"+_dVal[1] + "/"+_dVal[2] + "/";
    }
    else
    {
     _postPage = "/Search/HotelResult/";
     _postPage += _dVal[0] + "/"+_dVal[1] + "/";
     if(_lrN == "" || _lrN == "-- Any --") _lrN = "Any"; _postPage += _lrN + "/"; 
    }
    _postPage += _cInV + "/"; _postPage += _cOutV + "/";
    _postPage += _cid + "_" + _cityid + "_" + _locId + "_" + _drV + "_" + _adsV  + "_" + _chdV; 
    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') _postPage += "_" + _iataC;
    _postPage = ReplaceAll(_postPage, ".", ""); _postPage += ".aspx"; _postPage = urlUnEx(_postPage);
    //return false;
    if(_cObj(_$("hidSearchBoxVal"))) {
        try {
            if(_cObj(window.parent.document.getElementById("ctl00_plhBody_hidAId"))) {
                window.parent.document.myformPrice.target='_self'; window.parent.document.myformPrice.hidPriceResult.value = _sb; 
                window.parent.document.myformPrice.method = "POST"; window.parent.document.myformPrice.action = _postPage; window.parent.document.myformPrice.submit();
            }
            else { 
                document.myformPrice.target='_blank'; document.myformPrice.hidPriceResult.value = _sb; 
                document.myformPrice.method = "POST"; document.myformPrice.action = _postPage; document.myformPrice.submit();
            }
        }
        catch(e) {
            document.myformPrice.target='_blank'; document.myformPrice.hidPriceResult.value = _sb;   
            document.myformPrice.method = "POST"; document.myformPrice.action = _postPage; document.myformPrice.submit();
        }
    }
    else {
        document.myformPrice.target='_self'; document.myformPrice.hidPriceResult.value = _sb; 
        document.myformPrice.method = "POST"; document.myformPrice.action = _postPage; document.myformPrice.submit();
    }
    return false;
}
function validateDestRev()
{    
    _rqDestRev += 1;
    if(_cObj(_$("divDestMessage"))) if(_$("divDestMessage").style.display != "none") _$("divDestMessage").style.display = "none";
    if(_cObj(_$("divDestRevMessage"))) if(_$("lblDestRevErrMessage").innerHTML != "Coming Soon...") if(_$("divDestRevMessage").style.display != "none") _$("divDestRevMessage").style.display = "none";
    if(_cObj(_$("divHotelRevMessage"))) if(_$("divHotelRevMessage").style.display != "none") _$("divHotelRevMessage").style.display = "none";
    if(_$("ctl00_plhBody_txtDestVideo").value=="" || _$("ctl00_plhBody_txtDestVideo").value=="e.g. Paris") {
        _$("divDidYouMeanDestRev").style.display = "none"; _$("divDestRevMessage").style.display = "block";
        _$("divDestMessage").style.height = "22px";_$("lblDestRevErrMessage").innerHTML = "Please enter a destination first!"; return false;
    }
    if(_$("ctl00_plhBody_hidDestRevValue").value == "") {
        if(_$("ctl00_plhBody_txtDestVideo").value!="") {
            _$("ctl00_plhBody_hidDestRevSearchQuery").value = _$("ctl00_plhBody_txtDestVideo").value;
            gDRBSQ(_$("ctl00_plhBody_txtDestVideo").value);
        }
        _$("ctl00_plhBody_txtDestVideo").focus();
        return false;
    } 
    var _dsRV = _$("ctl00_plhBody_hidDestRevValue").value.split(',');
    var _dsVV =_dsRV[3];var _DV=_$("ctl00_plhBody_txtDestVideo").value.split(", "); var _dsVN = _DV[1]+', '+_DV[0];
    var _aid = _$("ctl00_plhBody_hidAffiliateId").value;
    DCS(1, 0, 'Home Page', 'Dest Search', _dsVV, _dsVN);
    var _sb = _dsRV + "||" + _dsVV;
    crCk("HotellyDestination", _sb, 1)
    var _psV = _dsVV + "||" + _aid; var _psP = "/Search/Destination/";
    if(_cObj(_$("hidDestSeoValues"))) _psP += _$("hidDestSeoValues").value;
    _psP = ReplaceAll(_psP, ".", ""); _psP += _dsVV + ".aspx"; _psP = urlUnEx(_psP);
    document.myformHotelDL.target='_self'; document.myformHotelDL.hidHotelReq.value = _psV; 
    document.myformHotelDL.method = "POST"; document.myformHotelDL.action = _psP; document.myformHotelDL.submit();
    return false;
}
function validateHotelRev()
{
    _rqHotelRev += 1;
    if(_cObj(_$("divDestMessage"))) if(_$("divDestMessage").style.display != "none") _$("divDestMessage").style.display = "none";
    if(_cObj(_$("divDestRevMessage"))) if(_$("divDestRevMessage").style.display != "none") _$("divDestRevMessage").style.display = "none";
    if(_cObj(_$("divHotelRevMessage"))) if(_$("divHotelRevMessage").style.display != "none") _$("divHotelRevMessage").style.display = "none";
    if(_$("ctl00_plhBody_txtHotelVideo").value=="" || _$("ctl00_plhBody_txtHotelVideo").value == "e.g. Napoleon Hotel Paris") {
        _$("divDidYouMeanHotelRev").style.display = "none"; _$("divHotelRevMessage").style.display = "block";
        _$("lblHotelRevErrMessage").innerHTML = "Please enter a hotel first!";
        return false;
    }
    if(_$("ctl00_plhBody_hidHotelRevValue").value == "") {
        if(_$("ctl00_plhBody_txtHotelVideo").value!="") {
            _$("ctl00_plhBody_hidHotelRevSearchQuery").value = _$("ctl00_plhBody_txtHotelVideo").value;
            gHRBSQ(_$("ctl00_plhBody_txtHotelVideo").value);
        }
        _$("ctl00_plhBody_txtHotelVideo").focus(); return false;
    }
    var _hRV, _hVV, _hVN, _cId, _sId, _cityId, _lId, _hId, _dId, _ty, _aid, _sq;
    _hRV = _$("ctl00_plhBody_hidHotelRevValue").value.split(','); _hVV = _hRV[4];
    _hVN = _$("ctl00_plhBody_txtHotelVideo").value; _aid = _$("ctl00_plhBody_hidAffiliateId").value;
    DCS(1, 0, 'Home Page', 'Hotel Search', _hVV, _hVN);
    var _sb = _hRV + "||" + _hVN;
    crCk("HotellyHotel", _sb, 1)
    var _psV = _hVV + "||" + _aid;
    var _psP = "/Search/Hotel/"; if(_cObj(_$("hidSeoValues"))) _psP += _$("hidSeoValues").value;
    _psP = ReplaceAll(_psP, ".", ""); _psP += _hVV  + ".aspx"; _psP = urlUnEx(_psP);
    document.myformHotelDL.target='_self'; document.myformHotelDL.hidHotelReq.value = _psV; 
    document.myformHotelDL.method = "POST"; document.myformHotelDL.action = _psP; document.myformHotelDL.submit();
    return false;
}
function cOutDate(_dur)
{    
    var one_day=1000*60*60*24;
    if(_dur != '--' && _dur != 0) {
        if(_$("ctl00_plhBody_hotelCheckin").value=="" && _$("ctl00_plhBody_hotelCheckin").value != "Check-In") 
         {           
            if(_cObj(_$('hidFnH')) && _$('hidFnH').value == '2')
                alert("Departure date can not be blank!"); 
            else       
                alert("Check-in date can not be blank!"); 
            var _duration = _$("ctl00_plhBody_ddlDuration"); _duration.value = 1; return false;
         }
        else 
        { 
            //alert("Check In Date " + _$("ctl00_plhBody_checkinValue").value);
            var _cIn = _$("ctl00_plhBody_checkinValue").value;
            var x=_cIn.split("-");  var d1=new Date(x[2],(x[1]-1),x[0]); var totalDate = new Date(d1.getTime()+(_dur*one_day));
            var _d = totalDate.getDate().toString(); if(_d.length ==1) _d = 0+_d;
            var _m = totalDate.getMonth(); _m= (_m+1).toString(); if(_m.length ==1) _m = 0+(_m);
            var _y = totalDate.getFullYear();            
            _$("ctl00_plhBody_hotelCheckout").value = GFD(_d + "-" + _m + "-" + _y); _$("ctl00_plhBody_checkoutValue").value = _d + "-" + _m + "-" + _y;
            hpCal('');
        }
    }
    else { _$("ctl00_plhBody_hotelCheckout").value = ""; _$("ctl00_plhBody_checkoutValue").value = ""; }
}

function setFnHDate(_dur)
{
    var _currentDate = new Date();
    var _day = _currentDate.getDay();
    var _month = _currentDate.getMonth() + 1;
    var _date = _currentDate.getDate();
    var _year = _currentDate.getFullYear();
    var _newdt=_date + "-" + _month + "-" + _year;
    var _newChkIndt;  
//    if (parseInt(_day)==5)          
//             setDfDt("ctl00_plhBody_hotelCheckin", 7, "ctl00_plhBody_checkinValue")   
//    else if(parseInt(_day)>5)         
//          setDfDt("ctl00_plhBody_hotelCheckin", 13, "ctl00_plhBody_checkinValue")   
//    else
//    {      
//         setDfDt("ctl00_plhBody_hotelCheckin", (7+(5-parseInt(_day))), "ctl00_plhBody_checkinValue")   
//    }
   setDfDt("ctl00_plhBody_hotelCheckin", 21, "ctl00_plhBody_checkinValue");    
   cOutDate(_dur);      
}

function getNewDate(_dt,_dur)//_dt in dd-mm-yyyy
{
    var one_day=1000*60*60*24;
    var _cIn = _dt;
    var x=_cIn.split("-");  var d1=new Date(x[2],(x[1]-1),x[0]); var totalDate = new Date(d1.getTime()+(_dur*one_day));
    var _d = totalDate.getDate().toString(); if(_d.length ==1) _d = 0+_d;
    var _m = totalDate.getMonth(); _m= (_m+1).toString(); if(_m.length ==1) _m = 0+(_m);
    var _y = totalDate.getFullYear();
    return GFD(_d + "-" + _m + "-" + _y);
}

function pDur(_dur) 
{ 
    //alert('in pDur '+ _dur);
    var dr = _$("ctl00_plhBody_ddlDuration");    
//    if(_cObj(_$('hidFnH')) && _$('hidFnH').value==2) 
//    {
//       dr.value=7;      
//    }
//    else
        dr.value = _dur; 
 }
// new function added for cookies
function rCk(name)
{   
    var ca = document.cookie.split(';'); var nEQ = name + "=";    
    for(var i=0; i < ca.length; i++) 
     {
        var c = ca[i]; while (c.charAt(0)==' ')  c = c.substring(1, c.length);
        if (c.indexOf(nEQ) == 0) 
        {
            var _cValues = c.substring(nEQ.length, c.length).split("||");            
            if(_cValues.length > 0) 
            {               
                setSrchParams(_cValues);
            }    
        }//end of c.indexOf(nEQ)
    }
    return false;
}
function setSrchParams(_cValues)
{
    _$("ctl00_plhBody_txtDestination").value = _cValues[21]; _$("ctl00_plhBody_hidDestText").value  = _cValues[21];
    _$("ctl00_plhBody_hidDestValue").value = _cValues[22];_$("ctl00_plhBody_hotelCheckin").value = GFD(_cValues[9]);
    _$("ctl00_plhBody_checkinValue").value = _cValues[9]; _$("ctl00_plhBody_hotelCheckout").value = GFD(_cValues[10]);
    _$("ctl00_plhBody_checkoutValue").value = _cValues[10];_$("ctl00_plhBody_ddlDuration").value = _cValues[11] ;
    _$("ctl00_plhBody_ddlRating").value = _cValues[18]; _$("ctl00_plhBody_ddlAdult").value = _cValues[14];
    _$("ctl00_plhBody_ddlChildren").value = _cValues[15]; _$("ctl00_plhBody_ddlInfants").value = _cValues[16];
    _$("ctl00_plhBody_hidResortName").value = _cValues[20]; _$("ctl00_plhBody_hidResortId").value = _cValues[3];
    var  _destType = _cValues[5]; _$("ctl00_plhBody_hidDestType").value = _destType;
    var _dVal = _cValues[22].split(","); var _bType = _dVal[6]; _$("ctl00_plhBody_hidBType").value = _bType;              
//    if(_destType =="C")
//    {
        
        if(_bType != "True") 
        { 
            pDr("1", _$("ctl00_plhBody_ddlDuration"));                        
            if(_$("ctl00_plhBody_hotelCheckin").value != "") { setTimeout("pDur('"+_cValues[11]+"')" , 500); }
        }
        else 
        { 
            if(_cObj(_$('hidFnH')) && _$('hidFnH').value == '2')
                pDr("0", _$("ctl00_plhBody_ddlDuration"));
            else
                pDr("1", _$("ctl00_plhBody_ddlDuration"));
//            if(_cValues[13]=='')_$("ctl00_plhBody_ddlBoard").value = "HB"; 
//            else _$("ctl00_plhBody_ddlBoard").value = _cValues[13];                        
//            _$("ctl00_plhBody_ddlBoard").disabled=false;
            if(_$("ctl00_plhBody_hotelCheckin").value != "") { setTimeout("pDur('"+_cValues[11]+"')" , 500); }
        }
//    }
//    else 
//    { 
//        pDr("1", _$("ctl00_plhBody_ddlDuration"));                   
//        if(_$("ctl00_plhBody_hotelCheckin").value != "") {  setTimeout("pDur('"+_cValues[11]+"')" , 500); }
//    }
    _$("ctl00_plhBody_hidResortId").value = _cValues[3];
    if(_cObj(_$('hidFnH')) && _$('hidFnH').value != '2')
        fRsCk(_cValues[22]); // To populate resort/Location dropdown of hotel Only Section
    else
        IATAbyDestn(_dVal[2],_dVal[4],_cValues[24],_cValues[13]);  // To populate IATA dropdown of FnH Section  
    hpCal('');
}
function pDr(_value, ddlResort)
{
    var opI;
    try{
        for (var count = ddlResort.options.length-1; count >-1; count--) { ddlResort.options[count] = null; }
        if(_value == "0") 
        { 
//            for(var _p=7; _p<=28; _p+=7) 
//            {
                var _op1 = crOp("7"); 
                ddlResort.appendChild(_op1); 
                var _op2 = crOp("10"); 
                ddlResort.appendChild(_op2);
                var _op3= crOp("14"); 
                ddlResort.appendChild(_op3);
//             } 
        }
        else
        {
            for(var i=1; i<=30; i++)
            { 
                var op = crOp(i); ddlResort.appendChild(op); 
            }
        }          
        if(_cObj(_$('hidFnH')) && _$('hidFnH').value == '2')
        {
            if (bName == "Microsoft Internet Explorer")                
                setTimeout("pDur(7)" , 1);
             else
                 pDur(7);  
        }
        else
        {            
            if (bName == "Microsoft Internet Explorer")                
                setTimeout("pDur(2)" , 1);
             else
                 pDur(2);             
         }  
     }
     catch(e){}          
             
}
function crOp(_val)
{
    var op = document.createElement('OPTION'); op.value = _val; op.appendChild(document.createTextNode(_val));  return op;
}
function fRsCk(_dId)
{ 
    if(_dId!="") {
         var theDate = new Date(); var rU = "/Search/AjaxHome.aspx?page=Loc&DName="+_dId +"&dt="+ theDate.getTime();
         var XmlHttp = CreateXmlHttp();
         if(XmlHttp) {
		    XmlHttp.onreadystatechange = function () {
	            if(XmlHttp.readyState == 4) {
	            if(XmlHttp.status == 200) { sRsI(XmlHttp.responseText, "COOKIE"); }		
	            }
	        }
	        XmlHttp.open("GET", rU,  true); XmlHttp.send(null);		
	     }
    }
}
function sRsI(lcData, _flag)
{
    var ddlResort = _$("ctl00_plhBody_ddlResort"); 
    for (var count = ddlResort.options.length-1; count >-1; count--) { ddlResort.options[count] = null; }
    var op = new Option( "-- Any --", "",  false, false); ddlResort.options[ddlResort.length] = op; 
    if(lcData!="") 
    {  
        var arLc=lcData.split('|##'),lcItm,lid,ckLid=_$("ctl00_plhBody_hidResortId").value,lcIdx=0;
        if(arLc.length>0){
            ddlResort.disabled=false;
            for(var i=0; i < arLc.length; i++) {
               lcItm = arLc[i].split('|@');  
               lid = lcItm[0]+ "||" + lcItm[2]; 
               var op = new Option(lcItm[1], lid); ddlResort.options[ddlResort.length] = op;
               if(ckLid == lcItm[0])lcIdx=i+1;
            }
            if(_flag == "COOKIE") { ddlResort.options.selectedIndex = lcIdx;}
        }
        else { ddlResort.disabled=true; }  
    }
    _$("imgLoading").style.display = "none";
}
function emailFocus() { if(_$("txtEmail").value == "Please enter your email") _$("txtEmail").value = ""; }
function cancelEmail() { if(_$("txtEmail").value == "") _$("txtEmail").value = "Please enter your email"; }
function setHomePageDefaultVideo(){}
function setDfDt(c, d, cv)
{   
    var one_day=1000*60*60*24; var _yy = new Date().getYear(); if(_yy < 1900) _yy += 1900;
    var _mm = new Date().getMonth() + 1; var _dd = new Date().getDate();
    var date=new Date(_yy,(_mm-1),_dd); var tD = new Date(date.getTime()+(d*one_day));
    var _d = tD.getDate().toString(); if(_d.length ==1) _d = 0+_d;
    var _m = tD.getMonth(); _m= (_m+1).toString(); if(_m.length ==1) _m = 0+(_m);
    var _y = tD.getFullYear(); var _t = _d + "-" + _m + "-" + _y; if(_cObj(c)) _$(c).value = GFD(_t);
    if(_cObj(cv)) _$(cv).value = _t; return false;
}
function FnHVer()
{       
    //alert('in home main '+ _$("ctl00_Header1_FnHURL").value);
    //window.location.href = "http://hotelly.co.uk?ReFnH=FnH"; 
    window.location.href ="http://"+ _$("ctl00_Header1_FnHURL").value +"/Search/HomePage.aspx?ReFnH=FnH";
}

function IntVer()
{   
    //window.location.href = "http://hotelly.com?ReFnH=false";   
    //alert('in home main '+_$("ctl00_Header1_IntURL").value);
    //alert("http://"+ _$("ctl00_Header1_IntURL").value +"/Search/HomePage.aspx?ReFnH=false");
    location.href ="http://"+ _$("ctl00_Header1_IntURL").value +"/Search/HomePage.aspx?ReFnH=false";
    return true;
}

function RstCrnIndex()
{
     var ddlCur = _$("ctl00_Header1_ddlCur");
     if (_$("ctl00_Header1_showFnH").value== "1")
     {
        if(ddlCur.options.selectedIndex !=1)
        {
            ddlCur.options.selectedIndex=3;
        } 
      }
      else if ( _$("ctl00_Header1_showFnH").value!= "1" ) 
      {
        if(ddlCur.options.selectedIndex ==1 || ddlCur.options.selectedIndex ==2)
        {
            var curId,key,_arr;    
            curId = _$("ctl00_Header1_hidCurKey").value;                                                            
            for (i = 3; i < ddlCur.length; i++)
            {
                   _arr = ddlCur.options[i].value.split('||');
                   if (_arr[0].indexOf(curId) == 0)
                    {                     
                         ddlCur.options.selectedIndex = i;                     
                         break;
                    }   
            }           
         }
      }     
}
function clearVal(_ch)
{
    _$("divDestMessage").style.display = "none"; _$("divDidYouMeanDest").style.display = "none"; 
    _$("ctl00_plhBody_txtDestination").value=""; _$("ctl00_plhBody_txtDestination").value= _ch; _$("lblDestErrMessage").innerHTML = "";
    _$("lblHotelsCount").innerHTML = ""; _$("ctl00_plhBody_hidDestValue").value =""; _$("ctl00_plhBody_hidDestSearchQuery").value = "";
    _$("ctl00_plhBody_hotelCheckin").value=""; _$("ctl00_plhBody_hotelCheckout").value=""; _$("ctl00_plhBody_hidDestText").value = "";
    _$("ctl00_plhBody_hidResortName").value = ""; _$("ctl00_plhBody_hidOptionValues").value = "";
    _$("ctl00_plhBody_hidResortId").value =""; _$("ctl00_plhBody_checkinValue").value = ""; _$("ctl00_plhBody_checkoutValue").value = "";
    _$("ctl00_plhBody_hidPriceReqValues").value = ""; _$("hidPriceRequestValues").value = "";
    if(_$("hidFnH").value == '2')   
    { setFnHDate(7);}
    else
    {setDfDt("ctl00_plhBody_hotelCheckin", 7, "ctl00_plhBody_checkinValue");setDfDt("ctl00_plhBody_hotelCheckout", 9, "ctl00_plhBody_checkoutValue");}        
    var ddlResort = _$("ctl00_plhBody_ddlResort");    
    var _opI;  for (var count = ddlResort.options.length-1; count >-1; count--){ ddlResort.options[count] = null; }
    _opI = new Option( "-- Any --", "",  false, false); ddlResort.disabled=false; ddlResort.options[ddlResort.length] = _opI;     
    return false;
}
