﻿// For Home Page Price Section, By Gourav Kumar, RateGain IT Solution
//function dIS(_page, _chr, _rq)
//{
//    //alert(_page);

//    if(_chr!="") { var _fnh = '1';
//        if(_cObj(_$('hidFnH')) && _$('hidFnH').value != "") _fnh = _$('hidFnH').value;
//         var theDate = new Date();
//         var rU = "/Search/AjaxImpl.aspx?page="+_page+"&chr="+_chr +"&rq="+_rq+"&fnh="+_fnh+"&dt="+ theDate.getTime();
//         var XmlHttp = CreateXmlHttp();
//         if(XmlHttp) { XmlHttp.onreadystatechange = function() { 
//                if(XmlHttp.readyState == 4) {
//	                if(XmlHttp.status == 200) {
//	                    switch (_page) {
//                            case 'destIntelli': dIXDB(XmlHttp.responseText);  break;
//	                        case 'hotelRevIntelli': HRISX(XmlHttp.responseText); break;
//	                        case 'destRevIntelli': DRISX(XmlHttp.responseText); break;
//	                        case 'IATA': IataX(XmlHttp.responseText, ""); break;
//	                    }
//	                }
//                }
//	        }
//		    XmlHttp.open("GET", rU, true); XmlHttp.send(null);		
//	     }
//    }
//}
function dIS(_page, _chr, _rq)
{   
    if(_chr!="") { var _fnh = '1';
        if(_cObj(_$('hidFnH')) && _$('hidFnH').value != "") _fnh = _$('hidFnH').value;
         var theDate = new Date();
         var rU = "/Search/AjaxHome.aspx?page="+_page+"&chr="+_chr +"&rq="+_rq+"&fnh="+_fnh+"&dt="+ theDate.getTime();
         var XmlHttp = CreateXmlHttp();
         if(XmlHttp) { XmlHttp.onreadystatechange = function() { 
                if(XmlHttp.readyState == 4) {
	                if(XmlHttp.status == 200) {
	                    switch (_page) {
                            case 'destIntelli': ShowIntelliMS_UV(XmlHttp.responseText,_fnh);  break;
	                        //case 'hotelRevIntelli':HRISX(XmlHttp.responseText); break;
	                        //case 'destRevIntelli': DRISX(XmlHttp.responseText); break;
	                        //case 'IATA':IataX(XmlHttp.responseText, ""); break;
	                    }
	                }
                }
	        }
		    XmlHttp.open("GET", rU, true); XmlHttp.send(null);		
	     }
    }
}

//function dIXDB(rX)
//{
//    if(rX!=""){ var _sQ = _$("ctl00_plhBody_txtDestination").value;
//        var xD =crXD(rX);
//        if(_cObj(xD.selectNodes("ISD/UL/li"))) {
//            var ndD = xD.selectNodes("ISD/UL/li");
//            if(_cObj(ndD)) {
//                if(xD.selectSingleNode("ISD").getAttribute("RCntr")!=null){
//                    if(xD.selectSingleNode("ISD").getAttribute("RCntr") == _rqDest) {
//                        if(ndD.length > 0) {
//                            var dv = _$("destDiv"); dv.style.display = 'block'; cldv(dv); var _ul = crE('UL');
//                                for(var _rCt=0; _rCt < ndD.length; _rCt++) {
//                                    var _tV = GIH(ndD[_rCt]); _tV = ReplaceAll(_tV,"|", ", ");
//                                    var _dId = ndD[_rCt].getAttribute("id"); var _li = crDLI(_dId, _tV); _ul.appendChild(_li);
//                                }
//                                itC = ndD.length; dv.style.display = "inline"; dv.zIndex = "1000"; dv.appendChild(_ul);
//                                var _destDivCon =  _$("destDivContainer"); _destDivCon.style.display = 'block';
//                                var bName = navigator.appName;
//                                if (bName == "Microsoft Internet Explorer") {
//                                    var _iFrame = _$("destIFrame"); _iFrame.style.display = 'block'; _iFrame.style.width = dv.offsetWidth-2;
//                                    _iFrame.style.height = dv.offsetHeight-2; _iFrame.style.left = _$("destDivContainer").style.left; _iFrame.style.top = _$("destDivContainer").style.top;
//                                }
//                                selChc(0)
//                        }
//                        else { _$("destIFrame").style.display = 'none'; _$("destDiv").style.display = 'none'; }
//                    }
//                }
//                else { _$("destIFrame").style.display = 'none'; _$("destDiv").style.display = 'none'; }
//            }
//        }
//    }
//}
function ShowIntelliMS_UV(IData,_fnh)
{     
    var arrData=IData.split('|##');
    try{
    if(arrData[0]==_rqDest)
    {   
        var dv=_$("destDiv"); dv.innerHTML=''; dv.style.display='block';var _ul = crE('UL');
        if(arrData[1].length>0)
        {                               
            var JObj = eval('(' + arrData[1] + ')'); 
            var _tV,_dId,_li;              
            for(var i = 0; i < JObj.InSe.length; i++) 
            {
                _tV = JObj.InSe[i].INm;              
                _dId = JObj.InSe[i].IKy;                                         
                _li = crDLI(_dId, _tV);
                _ul.appendChild(_li);
            }
            itC = JObj.InSe.length;dv.style.display = "inline"; dv.zIndex = "1000"; dv.appendChild(_ul);
            var _destDivCon =  _$("destDivContainer"); _destDivCon.style.display = 'block';if(_fnh==2){_$("divHlnk").style.display = "none"};
            var bName = navigator.appName;
            if (bName == "Microsoft Internet Explorer") 
            {
                var _iFrame = _$("destIFrame"); _iFrame.style.display = 'block'; _iFrame.style.width = dv.offsetWidth-2;
                _iFrame.style.height = dv.offsetHeight-2; _iFrame.style.left = _$("destDivContainer").style.left; _iFrame.style.top = _$("destDivContainer").style.top;
            } 
            selChc(0)    
        }
        else 
        { 
            _$("destIFrame").style.display = 'none';_$("destDiv").style.display = "none";if(_fnh==2){if(_$("ctl00_plhBody_txtDestination").value.length>0) {_$("divHlnk").style.display = "block";} }
        }
    }
    }
    catch(e)
    {
        alert(e.message)
    }
}
function crDLI(_dId, _tV)
{
    var _li = crE('LI'); _li.id = _dId; _li.innerHTML = _tV;
   _li.onmousedown = function() { dLS(_dId,_tV); };
   _li.onmouseover = function() { crsl = -1; selChc(-1); _li.className = 'listItem'; };
   _li.onmouseout = function() { _li.className = ''; };
   return _li
}
function dLS(_dId, _tV)
{
     _tV=ClrSPN(_tV);
    _$("destIFrame").style.display = 'none'; _$("destDiv").style.display = 'none'; _$("ctl00_plhBody_txtDestination").value = _tV;
    _$("divDestMessage").style.display = "none"; _$("divDidYouMeanDest").style.display = "none";
    _$("ctl00_plhBody_hidDestValue").value = _dId; _$("ctl00_plhBody_hidDestText").value = _tV;
    var _dId = _$("ctl00_plhBody_hidDestValue").value; _$("ctl00_plhBody_hidResortId").value = "0"; _$("ctl00_plhBody_hidResortName").value = "";
    dSr(_dId); if(_cObj(_$('ctl00_plhBody_ddlHotelName')))hSr(_dId,"-1");
    var _dsVs = _dId.split(","); var _destType = _dsVs[5]; var _bType = _dsVs[6]; var _hCount = _dsVs[7]; _$("hidHcount").value = _hCount;
    if(_hCount > 0) _$("lblHotelsCount").innerHTML = "for " + _hCount + " Hotels"; 
    else _$("lblHotelsCount").innerHTML = "";
    if(_cObj(_$("hidFnH"))) if(_$("hidFnH").value == '2') _$("lblHotelsCount").innerHTML = "";
    _$("ctl00_plhBody_hidDestType").value = _destType; _$("ctl00_plhBody_hidBType").value = _bType;
    if(_cObj(_$('ctl00_plhBody_ddlDuration')))
    {
          if(_destType == "C") { if(_bType != "True") { pDr("1", _$("ctl00_plhBody_ddlDuration"));           
                if(_cObj(_$('ctl00_plhBody_hotelCheckin')) && _$("ctl00_plhBody_hotelCheckin").value != "" && _$("ctl00_plhBody_hotelCheckin").value != "Check-In") {
                    cOutDate("2"); setTimeout("pDur(2)" , 500);}
            }
            else
            {
                if(_cObj(_$('hidFnH')) && _$('hidFnH').value == '2')
                    pDr("0", _$("ctl00_plhBody_ddlDuration"));
                else
                   pDr("1", _$("ctl00_plhBody_ddlDuration"));
                _$("ctl00_plhBody_ddlBoard").value = "HB"; _$("ctl00_plhBody_ddlBoard").disabled=false;
                if(_cObj(_$('ctl00_plhBody_hotelCheckin')) && _$("ctl00_plhBody_hotelCheckin").value != "" && _$("ctl00_plhBody_hotelCheckin").value != "Check-In") {
                    cOutDate("7"); setTimeout("pDur(7)" , 500); }
            }
        }
        else { pDr("1", _$("ctl00_plhBody_ddlDuration"));        
            if(_cObj(_$('ctl00_plhBody_hotelCheckin')) && _$("ctl00_plhBody_hotelCheckin").value != "" && _$("ctl00_plhBody_hotelCheckin").value != "Check-In") {
                cOutDate("7"); setTimeout("pDur(7)" , 500); }
        }  
    }    
    return false;
}
function gPSX(_aid)
{
     var _hsrpIds = _$("ctl00_plhBody_hidPriceReqValues").value; var theDate = new Date();
     var rU = "/Search/AjaxImpl.aspx?pagedlp=HomePrice&aid="+_aid+"&v="+_hsrpIds+"&dt="+ theDate.getTime();
     var XmlHttp = CreateXmlHttp();
     if(XmlHttp) { XmlHttp.open("GET", rU, false); XmlHttp.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); XmlHttp.send(null); }
}
// Amit: Can be removed after testing completed
//function validatePriceSearch_Old(_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(_$("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"; _$("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=="") { alert("Check-in date can not be blank!"); return false; }
//    if(_$("ctl00_plhBody_hotelCheckout").value=="") { 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;
//    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"; }
//    }
//    _airId = "0";
//    _cInD = _$("ctl00_plhBody_checkinValue").value; _cOutD = _$("ctl00_plhBody_checkoutValue").value;
//    _lrN = _$("ctl00_plhBody_hidResortName").value; _aid = _$("ctl00_plhBody_hidAffiliateId").value;
//    _dstN = _$("ctl00_plhBody_hidDestText").value; _board = _$("ctl00_plhBody_ddlBoard").value;
//    var _iataC; if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2' && _cObj(_$("ctl00_plhBody_ddlAirport"))) _iataC = _$("ctl00_plhBody_ddlAirport").value;if(_iataC =='-1'){alert('Please select a departure airport'); return false; } 
//    var sb = _cid;  sb += "|"; sb += _sid; sb += "|"; sb += _cityid; sb += "|"; sb += _locId; sb += "|"; sb += _dId; 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 += _rtV; sb += "|"; sb += _rV; sb += "|"; sb += _adsV; sb += "|"; sb += _chdV; sb += "|"; sb += _infV;
//    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') {sb += "|"; sb += _iataC; }
//    _$("ctl00_plhBody_hidPriceReqValues").value = sb;
//    //var theDate = new Date(); var rU;
//    //if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') rU= "/Search/ManipPriceResultFnH.aspx?pagedlp=HomePrice&aid="+_aid+"&v="+sb+"&dt="+ theDate.getTime();
//    //else rU= "/Search/AjaxImpl.aspx?pagedlp=HomePrice&aid="+_aid+"&v="+sb+"&dt="+ theDate.getTime();
//    //var XmlHttp = CreateXmlHttp();
//    //if(XmlHttp) { XmlHttp.open("GET", rU, false); XmlHttp.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); XmlHttp.send(null); var responseText = XmlHttp.responseText; }
//    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 = "F";
//    if(_cObj(_flag)) cDCS(_flag, _dcPrm, _dNm)
//    // For Price Page Request
//    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;
//    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') { _sb += "||"; _sb += _iataC;  }
//    _$("hidPriceRequestValues").value = _sb;
//    //Create Cookie Items
//    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') crCk("FnHHotelly", _sb, 1)
//    else crCk("Hotelly", _sb, 1)
//    var _dVal = _$("ctl00_plhBody_hidDestText").value.split(", "); 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/";
//    else _postPage = "/Search/HotelResult/";
//    _postPage += _dVal[1] + "/"; _postPage += _dVal[0] + "/";
//    if(_lrN == "" || _lrN == "-- Any --") _lrN = "Any";
//    _postPage += _lrN + "/"; _postPage += _cInV + "/"; _postPage += _cOutV + "/";
//    _postPage += _cid + "_" + _cityid + "_" + _rsVal + "_" + _drV + "_" + _adsV  + "_" + _chdV; 
//    if(_cObj(_$("hidFnH")) && _$('hidFnH').value == '2') _postPage += "_" + _iataC;
//    _postPage = ReplaceAll(_postPage, ".", ""); _postPage += ".aspx"; _postPage = urlUnEx(_postPage);
//    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 cDCS(_flag, _dcPrm, _dNm)
{
//    if(_flag == "1") { DCS(1, 0, 'Home Page', 'Compare Prices', _dNm, _dcPrm ); }
    if(_flag == "2") { DCS(1, 0, 'Search Results', 'Compare Prices', _dNm, _dcPrm ); }
    if(_flag == "3") { DCS(1, 0, 'Dynamic Results', 'Compare Prices', _dNm, _dcPrm ); }
    if(_flag == "4") { DCS(1, 0, 'Search Box', 'Compare Prices', _dNm, _dcPrm ); }
    if(_flag == "5") { DCS(1, 0, 'DDLP', 'Compare Prices', _dNm, _dcPrm ); }
//    if(_flag == "F") { DCS(1, 0, 'Home Page', 'FnH Compare Prices', _dNm, _dcPrm ); }
//    if(_flag == "FH"){ DCS(1, 0, 'FnH Search Results', 'Compare Prices', _dNm, _dcPrm ); }
}
function dMDS()
{
    var ddlDidYouMean = _$("ctl00_plhBody_ddlDidYouMeanDest"); _$("divDestMessage").style.display = "none"; var w = _$("ctl00_plhBody_ddlDidYouMeanDest").selectedIndex;
    _$("ctl00_plhBody_hidDestText").value = _$("ctl00_plhBody_ddlDidYouMeanDest").options[w].text;  _$("ctl00_plhBody_txtDestination").value = _$("ctl00_plhBody_hidDestText").value;
    _$("ctl00_plhBody_hidDestValue").value = ddlDidYouMean.value;
    var _dId = _$("ctl00_plhBody_hidDestValue").value; _$("ctl00_plhBody_hidResortId").value = "0"; _$("ctl00_plhBody_hidResortName").value = "";
    dSr(_dId); if(_cObj(_$('ctl00_plhBody_ddlHotelName')))hSr(_dId,"-1");var _dsVs = _dId.split(","); var _destType = _dsVs[5]; var _bType = _dsVs[6]; var _hCount = _dsVs[7];
    if(_hCount > 0) _$("lblHotelsCount").innerHTML ="for " + _hCount + " Hotels";
    else _$("lblHotelsCount").innerHTML = "";
    if(_cObj(_$("hidFnH"))) if(_$("hidFnH").value == '2') _$("lblHotelsCount").innerHTML = "";
    _$("ctl00_plhBody_hidDestType").value = _destType; _$("ctl00_plhBody_hidBType").value = _bType;
    if(_cObj(_$('ctl00_plhBody_ddlDuration')))
    {
           if(_destType == "C") {
            if(_bType != "True") { pDr("1", _$("ctl00_plhBody_ddlDuration"));           
                if(_cObj(_$('ctl00_plhBody_hotelCheckin')) &&_$("ctl00_plhBody_hotelCheckin").value != "" && _$("ctl00_plhBody_hotelCheckin").value != "Check-In") { cOutDate("2"); setTimeout("pDur(2)" , 500); }
            }
            else { pDr("1", _$("ctl00_plhBody_ddlDuration"));
                _$("ctl00_plhBody_ddlBoard").value = "HB"; _$("ctl00_plhBody_ddlBoard").disabled=false;
                if(_cObj(_$('ctl00_plhBody_hotelCheckin')) && _$("ctl00_plhBody_hotelCheckin").value != "" && _$("ctl00_plhBody_hotelCheckin").value != "Check-In") { cOutDate("7"); setTimeout("pDur(7)" , 500); }
            }
        }
        else { pDr("1", _$("ctl00_plhBody_ddlDuration"));  
            if(_cObj(_$('ctl00_plhBody_hotelCheckin')) && _$("ctl00_plhBody_hotelCheckin").value != "" && _$("ctl00_plhBody_hotelCheckin").value != "Check-In") { cOutDate("7"); setTimeout("pDur(7)" , 500); }
        } 
    }    
    _$("divDidYouMeanDest").style.display = "none"; return false;
}
function didYouMeanDestSelected() { dMDS() }

function gRLId(_rsId)
{
    var _resId = _rsId.split("||"); _$("ctl00_plhBody_hidResortId").value = _resId[0];
    var _hCount = _resId[1]; var w = _$("ctl00_plhBody_ddlResort").selectedIndex;
    _$("ctl00_plhBody_hidResortName").value = _$("ctl00_plhBody_ddlResort").options[w].text;
    if(_resId != 0) {
        if(_hCount > 0) { _$("lblHotelsCount").innerHTML = "for " + _hCount + " Hotels"; }
        else { _$("lblHotelsCount").innerHTML = ""; }
    }
    else {
        if(_$("hidHcount").value != "") _$("lblHotelsCount").innerHTML = "for " + _$("hidHcount").value + " Hotels";
        else _$("lblHotelsCount").innerHTML = "";
    }
    if(_cObj(_$("hidFnH"))) if(_$("hidFnH").value == '2') _$("lblHotelsCount").innerHTML = "";
}

function gDDf()
{
    var one_day=1000*60*60*24;  var cInV = _$("ctl00_plhBody_checkinValue").value; var cOutV = _$("ctl00_plhBody_checkoutValue").value;
    var x=cInV.split("-"); var y=cOutV.split("-");
    var d1=new Date(x[2],(x[1]-1),x[0]); var d2=new Date(y[2],(y[1]-1),y[0]);
    var month1=x[1]-1; var month2=y[1]-1;
    var _Diff=Math.ceil((d2.getTime()-d1.getTime())/(one_day)); 
    if(_Diff != "NaN") {
        if(_Diff <1) {
            alert("Check-out date must be greater than Check-in date"); _$("ctl00_plhBody_hotelCheckout").value="";
            var _cIn = _$("ctl00_plhBody_checkinValue").value; var x=_cIn.split("-");     
            var d1=new Date(x[2],(x[1]-1),x[0]); var totalDate;
            if(_$("ctl00_plhBody_hidDestType").value !="C") totalDate = new Date(d1.getTime()+(7*one_day));
            else totalDate = new Date(d1.getTime()+(2*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;
            var _bType = "False"; if(_cObj(_$("ctl00_plhBody_hidBType"))) _bType = _$("ctl00_plhBody_hidBType").value;
            if(_$("ctl00_plhBody_hidDestType").value !="C") { cOutDate("7"); setTimeout("pDur(7)" , 300); }
            else { if(_bType != "True") { cOutDate("2"); setTimeout("pDur(2)" , 300); }
                else { cOutDate("7");setTimeout("pDur(7)" , 300);}
            }
            hpCal(''); return false;
        }
        else { if(_Diff >30) {
                    alert("Check out date can not be vary from selected duration values!"); _$("ctl00_plhBody_hotelCheckout").value="";
                    var _cIn = _$("ctl00_plhBody_checkinValue").value; var x=_cIn.split("-");     
                    var d1=new Date(x[2],(x[1]-1),x[0]); var totalDate;
                    if(_$("ctl00_plhBody_hidDestType").value !="C") totalDate = new Date(d1.getTime()+(7*one_day));
                    else totalDate = new Date(d1.getTime()+(2*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;
                    var _bType = "False"; if(_cObj(_$("ctl00_plhBody_hidBType"))) _bType = _$("ctl00_plhBody_hidBType").value;
                    if(_$("ctl00_plhBody_hidDestType").value !="C") { cOutDate("7"); setTimeout("pDur(7)" , 300); }
                    else { if(_bType != "True") { cOutDate("2"); setTimeout("pDur(2)" , 300); }
                        else { cOutDate("7"); setTimeout("pDur(7)" , 300); } 
                    }
                    hpCal(''); return false;
            }
            else { var _duration = _$("ctl00_plhBody_ddlDuration"); _duration.value = _Diff; return true; }
        }
    }
    else { var _duration = _$("ctl00_plhBody_ddlDuration"); _duration.value = 2; return true; }
}
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")  {
            alert("Check-in date can not be blank!"); var _duration = _$("ctl00_plhBody_ddlDuration"); _duration.value = 1; return false; }
        else { 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 setDates()
{
    var _dType = _$("ctl00_plhBody_hidDestType").value; _$("ctl00_plhBody_hotelCheckout").value = "";
    var one_day=1000*60*60*24; var _cIn = _$("ctl00_plhBody_checkinValue").value;
    var x=_cIn.split("-"); var d1=new Date(x[2],(x[1]-1),x[0]); var totalDate;
    var _duration = _$("ctl00_plhBody_ddlDuration"); var _bType = "False";
    if(_cObj(_$("ctl00_plhBody_hidBType"))) _bType = _$("ctl00_plhBody_hidBType").value;
    if(_dType != "C" && _dType != "") { cOutDate("7"); setTimeout("pDur(7)" , 500); }
    else { if(_bType != "True") { cOutDate("2"); setTimeout("pDur(2)" , 500); } else { cOutDate("7"); setTimeout("pDur(7)" , 500); } }   
    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('');
}
//function gDstSQ(_sQr)
//{
//    _$("imgLoading").style.display = "inline"; 
//    var _fnh = '1'; if(_cObj(_$('hidFnH')) && _$('hidFnH').value != "") _fnh = _$('hidFnH').value;
//    if(_sQr != "") {
//        var theDate = new Date(); var rU = "/Search/AjaxImpl.aspx?page=ind&sq="+_sQr +"&fnh="+_fnh+"&dt="+ theDate.getTime();
//         var XmlHttp = CreateXmlHttp();
//         if(XmlHttp) { XmlHttp.onreadystatechange = function(){
//	            if(XmlHttp.readyState == 4) {
//		            if(XmlHttp.status == 200) { sMDst(XmlHttp.responseText); }		
//	            }
//            }
//		    XmlHttp.open("GET", rU,  true);
//		    XmlHttp.send(null);		
//	     }
//    }
//}
function gDstSQ(_sQr)
{
    _$("imgLoading").style.display = "inline"; 
    var _fnh = '1'; if(_cObj(_$('hidFnH')) && _$('hidFnH').value != "") _fnh = _$('hidFnH').value;
    if(_sQr != "") {
        var theDate = new Date(); var rU = "/Search/AjaxHome.aspx?page=ind&sq="+_sQr +"&fnh="+_fnh+"&dt="+ theDate.getTime();
         var XmlHttp = CreateXmlHttp();
         if(XmlHttp) { XmlHttp.onreadystatechange = function(){
	            if(XmlHttp.readyState == 4) {
		            if(XmlHttp.status == 200) { sMDst(XmlHttp.responseText); }		
	            }
            }
		    XmlHttp.open("GET", rU,  true);
		    XmlHttp.send(null);		
	     }
    }
}
//function sMDst(rX)
//{
//    if(rX!="") {  
//        var xD =crXD(rX); var ndD, _ndCity, _ndR;
//        if(_cObj(xD.selectNodes("ISD/UL/li"))) {
//            ndD = xD.selectNodes("ISD/UL/li");
//            if(_cObj(ndD)) {
//                if(ndD.length > 0) {
//                    if(ndD.length == 1) {
//                        var _did = ndD[0].getAttribute("id"); var _tVal = GIH(ndD[0]);
//                        _tVal = ReplaceAll(_tVal,"|", ", "); dLS(_did, _tVal)
//                    }
//                    else {
//                        if(_cObj(_$("divDidYouMeanDest"))) _$("divDidYouMeanDest").style.display = "block";
//                        if(_cObj(_$("destDivContainer"))) _$("destDivContainer").style.display = "none";
//                        if(_cObj(_$("divDestMessage"))) _$("divDestMessage").style.display = "none";
//                        var ddlDidYouMeanDest = _$("ctl00_plhBody_ddlDidYouMeanDest");
//                        var _sQ = _$("ctl00_plhBody_hidDestSearchQuery").value; var _opI;
//                        for (var count = ddlDidYouMeanDest.options.length-1; count >-1; count--) { ddlDidYouMeanDest.options[count] = null; }
//                        _opI = new Option( "-- Please Select --", "",  false, false);
//                        ddlDidYouMeanDest.options[ddlDidYouMeanDest.length] = _opI; 
//                        for(var _rCt=0; _rCt < ndD.length; _rCt++) {
//                            var _tV = GIH(ndD[_rCt]); _tV = ReplaceAll(_tV,"|", ", ");
//                            var _dId = ndD[_rCt].getAttribute("id"); var _opI = new Option(_tV, _dId);
//                            ddlDidYouMeanDest.options[ddlDidYouMeanDest.length] = _opI;
//                        }
//                    }
//                }
//                else {
//                    _$("divDidYouMeanDest").style.display = "none"; _$("divDestMessage").style.display = "block";
//                    _$("lblDestErrMessage").innerHTML = "Please enter valid destination!"; _$("lblHotelsCount").innerHTML = "";
//                }
//            }
//        }
//        else if(_cObj(xD.selectNodes("IATA/UL/li"))) {
//            ndD = xD.selectNodes("IATA/UL/li");
//            if(_cObj(ndD)) {
//                if(ndD.length > 0) {
//                    for(var _rCt=0; _rCt < ndD.length; _rCt++) {
//                        var _tV = GIH(ndD[_rCt]); _tV = ReplaceAll(_tV,"|", ", ");
//                        var _dId = ndD[_rCt].getAttribute("id"); var _opI = new Option(_tV, _dId);
//                        ddlDidYouMeanDest.options[ddlDidYouMeanDest.length] = _opI;
//                    }
//                }
//            }
//        }
//    }
//    _$("imgLoading").style.display = "none";
//    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 --", "0",  false, false); ddlResort.options[ddlResort.length] = _opI; 
//}
function sMDst(rX)
{
    if(rX!="") 
    { 
        var arrData=rX.split('|##');    
        if(arrData[1].length>0)
        {    
            var _opI,_tV,_dId;      
            var JObj = eval('(' + arrData[1] + ')');             
            if(_cObj(_$("divDidYouMeanDest"))) _$("divDidYouMeanDest").style.display = "block";
            if(_cObj(_$("destDivContainer"))) _$("destDivContainer").style.display = "none";
            if(_cObj(_$("divDestMessage"))) _$("divDestMessage").style.display = "none";
            var ddlDidYouMeanDest = _$("ctl00_plhBody_ddlDidYouMeanDest");
            if(_cObj(_$("ctl00_plhBody_hidDestSearchQuery")))
            var _sQ = _$("ctl00_plhBody_hidDestSearchQuery").value; 
            for (var count = ddlDidYouMeanDest.options.length-1; count >-1; count--) { ddlDidYouMeanDest.options[count] = null; }
            _opI = new Option( "-- Please Select --", "",  false, false);
            ddlDidYouMeanDest.options[0] = _opI;               
            for(var i = 0; i < JObj.InSe.length; i++) 
            {
                _tV = JObj.InSe[i].INm;              
                _dId = JObj.InSe[i].IKy;         
                _opI = new Option(_tV, _dId);
                ddlDidYouMeanDest.options[i+1] = _opI;
            }            
        }
        else 
        {
            _$("divDidYouMeanDest").style.display = "none"; _$("divDestMessage").style.display = "block";
            _$("lblDestErrMessage").innerHTML = "Please enter valid destination!"; _$("lblHotelsCount").innerHTML = "";
        }
    }
    _$("imgLoading").style.display = "none";
    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 --", "0",  false, false); ddlResort.options[ddlResort.length] = _opI; 
}
function clearDestValues()
{
    _$("ctl00_plhBody_hidDestValue").value = ""; _$("ctl00_plhBody_hidDestText").value = ""; _$("ctl00_plhBody_hidResortId").value = ""; _$("ctl00_plhBody_hidResortName").value = ""; return false;
}
function dstKeyDwn(event)
{
    if(_cObj(_$("divDestMessage"))) _$("divDestMessage").style.display = "none";
    if(_cObj(_$("divDestRevMessage"))) _$("divDestRevMessage").style.display = "none";
    if(_cObj(_$("divHotelRevMessage"))) _$("divHotelRevMessage").style.display = "none";
    if (event.keyCode == 8 || event.keyCode == 127) { _$("ctl00_plhBody_hidDestValue").value = ""; }
    if (event.keyCode == 13) { event.returnValue=false; event.cancel = true; _$("ctl00_plhBody_compare_btn").focus(); _$("ctl00_plhBody_compare_btn").click(); }
}
function dSr(_dId)
{   
    _$("imgLoading").style.display = "inline";
    if(_dId!="") {
        var _fnh = '1'; if(_cObj(_$('hidFnH')) && _$('hidFnH').value != "") _fnh = _$('hidFnH').value;
         var theDate = new Date(); var rU = "/Search/AjaxImpl.aspx?page=d&DName="+_dId+"&fnh="+_fnh+"&dt="+ theDate.getTime();
         var XmlHttp = CreateXmlHttp();
         if(XmlHttp) { XmlHttp.onreadystatechange = function() { 
                if(XmlHttp.readyState == 4) {
	                if(XmlHttp.status == 200) { sRsI(XmlHttp.responseText, "DEST"); }		
                }
	        }
    		XmlHttp.open("GET", rU,  true); XmlHttp.send(null);		
	     }
    }
}
function sRsI(_rsX, _flag)
{
    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.options[ddlResort.length] = _opI; 
    if(_rsX!="") {  
        var xD =crXD(_rsX);
        var _ndRs, _ndR; _ndRs = xD.selectNodes("DR/R");
        if(_cObj(_ndRs)) {
            if(_ndRs.length > 0) { ddlResort.disabled=false;
                for(var _rCt=0; _rCt < _ndRs.length; _rCt++) {
                   var _tV = _ndRs[_rCt].getAttribute("n");  var _rsId = _ndRs[_rCt].getAttribute("id") + "||" + _ndRs[_rCt].getAttribute("HCount"); 
                   var _opI = new Option(_tV, _rsId); ddlResort.options[ddlResort.length] = _opI;
                }
                if(_flag == "COOKIE") {
                    for(var _rCD=0; _rCD < _ndRs.length; _rCD++) {
                        if(_$("ctl00_plhBody_hidResortId").value == _ndRs[_rCD].getAttribute("id"))  { ddlResort.options.selectedIndex = _rCD+1; }
                    } 
                }
            } 
            else { _ndRs = xD.selectNodes("C/L");
                if(_cObj(_ndRs)) { if(_ndRs.length > 0) { ddlResort.disabled=false;
                        for(var _rCt=0; _rCt < _ndRs.length; _rCt++) {
                           var _tV = _ndRs[_rCt].getAttribute("n");  var _rsId = _ndRs[_rCt].getAttribute("id") + "||" + _ndRs[_rCt].getAttribute("HCount"); 
                           var _opI = new Option(_tV, _rsId); ddlResort.options[ddlResort.length] = _opI;
                        }
                        if(_flag == "COOKIE") {
                            for(var _rC=0; _rC < _ndRs.length; _rC++) {
                                if(_$("ctl00_plhBody_hidResortId").value == _ndRs[_rC].getAttribute("id"))  { ddlResort.options.selectedIndex = _rC+1; }
                            }
                        }
                    }
                    else { ddlResort.disabled=true; }   
                }
                else { ddlResort.disabled=true; }
            }  
        }
        else { ddlResort.disabled=true; }
    }
    _$("imgLoading").style.display = "none";
}

function fRsCk(_dId)
{
    if(_dId!="") {
         var theDate = new Date(); var rU = "/Search/AjaxImpl.aspx?page=d&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 fIaCk(_dId)
{    
    if(_dId!="") {
         var theDate = new Date(); var rU = "/Search/AjaxImpl.aspx?page=IATA&chr="+_dId +"&rq=0&fnh=2&dt="+ theDate.getTime();
         var XmlHttp = CreateXmlHttp();
         if(XmlHttp) { XmlHttp.onreadystatechange = function () {
		    if(XmlHttp.readyState == 4) {
		            if(XmlHttp.status == 200) { IataX(XmlHttp.responseText, "COOKIE"); }		
	            }
	        }
    		XmlHttp.open("GET", rU,  true); XmlHttp.send(null);		
	     }
    }
}

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) {
                _$("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];
                if(_cObj(_$('hidFnH')) && _$('hidFnH').value == '2') if(_cObj(_$("ctl00_plhBody_ddlAirport"))) _$("ctl00_plhBody_ddlAirport").value = _cValues[24];
                var  _destType = _cValues[5]; _$("ctl00_plhBody_hidDestType").value = _destType;
                var _dVal = _cValues[22].split(","); var _bType = _dVal[6]; _$("ctl00_plhBody_hidBType").value = _bType;
                if(_cObj(_$('ctl00_plhBody_ddlDuration')))
                {
                  if(_destType =="C") {
                        if(_bType != "True") { pDr("0", _$("ctl00_plhBody_ddlDuration"));                     
                            if(_cObj(_$('ctl00_plhBody_hotelCheckin')) && _$("ctl00_plhBody_hotelCheckin").value != "") { setTimeout("pDur('"+_cValues[11]+"')" , 500); }
                        }
                        else { pDr("1", _$("ctl00_plhBody_ddlDuration"));
                            _$("ctl00_plhBody_ddlBoard").value = "HB"; _$("ctl00_plhBody_ddlBoard").disabled=false;
                            _$("ctl00_plhBody_ddlBoard").value = _cValues[13];
                            if(_cObj(_$('ctl00_plhBody_hotelCheckin')) && _$("ctl00_plhBody_hotelCheckin").value != "") { setTimeout("pDur('"+_cValues[11]+"')" , 500); }
                        }
                    }
                    else { pDr("1", _$("ctl00_plhBody_ddlDuration"));                 
                        if(_cObj(_$('ctl00_plhBody_hotelCheckin')) && _$("ctl00_plhBody_hotelCheckin").value != "") {  setTimeout("pDur('"+_cValues[11]+"')" , 500); }
                    }
                }                
                _$("ctl00_plhBody_hidResortId").value = _cValues[3];
                fRsCk(_cValues[22]); erCk(name)
            }    
        }
    }
    return false;
}
function crDVSec()
{
     var _afId = _$("ctl00_plhBody_hidAffiliateId").value;// var divDefMovie = _$("ctl00_plhBody_divDefaultMovie");
     _$("ctl00_plhBody_divDefaultMovie").innerHTML = '<embed type="application/x-shockwave-flash" src="http://s1.slipstreamvideo.com/player/vidplayer_ssv20.swf?v=1.0.9" style="" id="ssvplayer_48464" name="ssvplayer_48464" quality="high" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" flashvars="stage_width=396&amp;stage_height=294&amp;sname=2560&amp;location=http://localhost:3597/Search/HomePage.aspx&amp;ssv_skin=thin&amp;ssv_autoPlay=false" align="middle" height="294" width="396">';
     //var ssvplayer = new SSVPlayer(); ssvplayer.vwidth = 396; ssvplayer.vheight = 270; ssvplayer.video = 2560; ssvplayer.player_interface = 1; ssvplayer.skin = "thin"; ssvplayer.autoPlay = false; ssvplayer.load(divDefMovie);
//     var _vdU = document.getElementById("ctl00_HtlyVidDir").value + "/HotellyHomePage.flv";
//     WVE(_vdU,_$("ctl00_plhBody_divDefaultMovie"),"293", "396" , "0" , "/Search/Images/"+_afId+"/HotellyHomePlayer.gif"); 
}
function crDfPly(vURL, height, width,dv,vDir)
{
    try{
        if(_cObj(dv)){ cldv(dv); }
        var dvChild = crE('DIV'); dvChild.id="divC"; dv.appendChild(dvChild);
        var s1 = new SWFObject("/Search/Player/player.swf?skin=/Search/Player/skin.swf","ply",width,height,"9","#FFFFFF");
        s1.addParam("allowfullscreen","true"); s1.addParam("allowscriptaccess","always"); s1.addParam("flashvars","logo=Player/watermark_logo_bw.gif&file="+vURL); s1.write('divC');
   }catch(e){}
}
function homeTab(_v)
{
    if(_cObj(_$('hidFnH'))) _$('hidFnH').value = _v
    if(_v == '1') {
        _$('hotel_label').className = "selected"; _$('flightandhotel_label').className = "";
        _$('lblCin').innerHTML = "Check-in date:"; _$('lblCout').innerHTML = "Check-out date:";
        _$('divAir').style.display = "none"; clearVal("e.g. Paris"); rCk("Hotelly");
    }
    else {
        _$('hotel_label').className = ""; _$('flightandhotel_label').className = "selected";
        _$('lblCin').innerHTML = "Departure dates:"; _$('lblCout').innerHTML = "Return dates:";
        _$('divAir').style.display = "block"; clearVal("e.g. Costa Del Sol"); dIS('IATA', '184', '0'); rCk("FnHHotelly");
    }
}
function clearVal(_ch)
{
    _$("divDestMessage").style.display = "none"; _$("divDidYouMeanDest").style.display = "none"; _$("divDestMessage").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_hidDestValue").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 = "";
    setDfDt("ctl00_plhBody_hotelCheckin", 7, "ctl00_plhBody_checkinValue"); _$("ctl00_plhBody_ddlDuration").selectedIndex = "7";  setDfDt("ctl00_plhBody_hotelCheckout", 14, "ctl00_plhBody_checkoutValue");
    var ddlResort; var ddlAirport;var ddlBoard;
    if(_cObj(_$("ctl00_plhBody_ddlResort"))) ddlResort = _$("ctl00_plhBody_ddlResort");
    if(_cObj(_$("ctl00_plhBody_ddlAirport"))) ddlAirport = _$("ctl00_plhBody_ddlAirport"); 
    if(_cObj(_$("ctl00_plhBody_ddlBoard"))) ddlBoard = _$("ctl00_plhBody_ddlBoard");
    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; 
    var _optionAir; for (var count = ddlAirport.options.length-1; count >-1; count--) { ddlAirport.options[count] = null; }
    _optionAir = new Option( "--Select--", "-1",  false, false); ddlAirport.disabled=false; ddlAirport.options[ddlAirport.length] = _optionAir; 
    var _optionBrd; for (var count = ddlBoard.options.length-1; count >-1; count--) { ddlBoard.options[count] = null; }
    _optionBrd = new Option( "--Select---", "-1",  false, false); ddlBoard.disabled=false; ddlBoard.options[ddlAirport.length] = _optionAir; 
    return false;
}
function saveSearchEmail(_email)
{
    var _aid = _$("ctl00_plhBody_hidAffiliateId").value;
    var theDate = new Date(); var rU = "/Search/AjaxImpl.aspx?analytics=email&aid="+_aid+"&e="+_email+"&dt="+ theDate.getTime();
    var XmlHttp = CreateXmlHttp();
    if(XmlHttp) { XmlHttp.open("GET", rU, false); XmlHttp.setRequestHeader("Content-Type", "application/xml; charset=utf-8"); XmlHttp.send(null); }    
}

// Amit: For FnH change
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"; _$("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"; _$("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"; _$("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 = "F";
    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 ClrSPN(_tV)
{
     _tV = ReplaceAll(_tV, "<b>","");     
     _tV = ReplaceAll(_tV, "</b>","");    
     _tV = ReplaceAll(_tV, "<B>","");     
     _tV = ReplaceAll(_tV, "</B>","");  
   return _tV;       
}
function pDr(_value, ddlResort)
{
    var opI;
    try{
        for (var count = ddlResort.options.length-1; count >-1; count--) { ddlResort.options[count] = null; }
        if(_value == "0") 
        { 
                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){}          
             
}
