﻿// For DDLP, By Gourav Kumar, RateGain IT Solution
function pDDLP()
{  
    var dIds = _$("ctl00_plhBody_hidDestIds").value;
    if(dIds!="") {
         var theDate = new Date(); var rU = "/Search/AjaxImpl.aspx?pagedlp=DDLP&v="+dIds +"&dt="+ theDate.getTime();
         var XmlHttp = CreateXmlHttp();
         if(XmlHttp) {
		    XmlHttp.onreadystatechange = function(){
	            if(XmlHttp.readyState == 4) { if(XmlHttp.status == 200) { sDDLP(XmlHttp.responseText); }		
	            }
            }
            XmlHttp.open("GET", rU,  true); XmlHttp.send(null);		
	     }
    }
}
function sDDLP(dX)
{
    _$("htLoad").style.display = "none"; _$("htOther").style.display = "block"; _$("htReview").style.display = "block";
    _$("ctl00_plhBody_divCustRating").style.display = "block"; _$("filter_results_wrapper").style.display = "block"; _$("ctl00_Header1_ddlCur").disabled = false; _$("ctl00_plhBody_hidDestXml").value = dX;
    var dIds = _$("ctl00_plhBody_hidDestIds").value.split("||"); pDLP(dX);
}
function pDLP(dX)
{
    var xD = crXD(dX); var xDN = xD.selectSingleNode("D"); var nAH = xDN.selectSingleNode("AHs");
    if(_cObj(nAH)) _$("ctl00_plhBody_hdnOriginalXml").value = xS(nAH);
    pSM(xDN); pImG(xD); pVdG(xD); pCR(xD); pCWR(xD);
    if(_$("ctl00_plhBody_hidDestXml").value =="") {
       _$("search_results_wrapper").style.display = "none"; _$("filter_results_wrapper").style.display = "none";
       _$("ctl00_plhBody_divCheckPrices").style.display = "none"; _$("ctl00_plhBody_divLeadPrices").style.display = "none";
       setTimeout("window.location='/Search/homepage.aspx'", 3000);
    }
    var vd = _$("ctl00_plhBody_hdnVideos").value;
    if(vd == "1") {
        _$("video_label").className = "selected"; _$("video_option").checked = "checked"; _$("video_gallery").style.display = "block";
        _$("main_image_wrapper").style.display = "none"; _$("gallery_thumbs_wrapper").style.display = "none";
    }
    else  if(vd == "2") { 
        _$("photo_label").className = "selected"; _$("photo_option").checked = "checked"; _$("video_gallery").style.display = "none"; _$("main_image_wrapper").style.display = "block";
        _$("gallery_thumbs_wrapper").style.display = "block"; _$("video_label").style.visibility = "hidden"; _$("video_option").style.visibility = "hidden";
    }
    var ph = _$("ctl00_plhBody_hdnPhotos").value;
    if(ph == "2") {
        _$("main_image_wrapper").style.display = "none"; _$("gallery_thumbs_wrapper").style.display = "none";
        _$("photo_label").style.display = "none"; _$("photo_option").style.display = "none";
    }
    pRLDrpdn(xD);
    var dId = xDN.getAttribute("id"); var dN = xDN.getAttribute("n"); return false;
}

function pSM(xDN)
{
    _$("ctl00_plhBody_lblDestination").innerHTML = xDN.getAttribute("n"); _$("ctl00_plhBody_lblDesttitle").innerHTML = xDN.getAttribute("n");
    var dId = xDN.getAttribute("id"); _$("hidDestId").value = dId; _$("ctl00_plhBody_hiddestName").value = xDN.getAttribute("n");
    _$("ctl00_plhBody_destLink").innerHTML = "Offers"; _$("ctl00_plhBody_destLink").setAttribute('target','blank');
    var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    
    var cntN = "Country"; var ctN = "City";
    if(_cObj(xDN.getAttribute("CnName"))) cntN = xDN.getAttribute("CnName");
    if(_cObj(xDN.getAttribute("CtName"))) ctN = xDN.getAttribute("CtName");
    if(_cObj(_$("hidSeoValues"))) _$("hidSeoValues").value = cntN + "/" + ctN + "/";
    if(_cObj(_$("hidPopValues"))) _$("hidPopValues").value = ctN+ ", " + cntN ;
    if(_cObj(xDN.getAttribute("Iid"))) { _$("ctl00_plhBody_hidDestValue").value = xDN.getAttribute("Iid"); 
        var dV = xDN.getAttribute("Iid").split(","); _$("ctl00_plhBody_hidDestType").value = dV[5]; _$("ctl00_plhBody_hidBType").value = dV[6];
    }
    else {
        _$("dSrBox").style.display = "none"; _$("ctl00_plhBody_hidDestValue").value = "";  }
    //_$("ctl00_plhBody_hidDestText").value ="All Resorts, "+ ctN+ ", " + cntN; 
    _$("ctl00_plhBody_hidDestText").value =ctN+ ", " + cntN; 
    return false;
}
function pImG(xD)
{
    var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    if(_cObj(xD.selectNodes("D/Is/I"))) {
        var ndIG = xD.selectNodes("D/Is/I[@t='P']");
        if (ndIG.length > 0) {
            for (var imC = 0; imC < ndIG.length; imC++) {
                var _ha = crE("A"); _ha.className = "thumb_link"; _ha.href =  ndIG[imC].getAttribute("u");
                var _img = crE("IMG"); _img.src = ndIG[imC].getAttribute("u"); 
                if(_cObj(ndIG[imC].getAttribute("alttag"))) {
                    if(ndIG[imC].getAttribute("alttag") !="" ) { _img.alt = ndIG[imC].getAttribute("alttag");  }
                    else { if(_cObj(xD.selectSingleNode("D").getAttribute("n"))) _img.alt = xD.selectSingleNode("D").getAttribute("n"); }
                }
                else { if(_cObj(xD.selectSingleNode("D").getAttribute("n"))) _img.alt = xD.selectSingleNode("D").getAttribute("n"); }
                _img.width = '52'; _img.height = '39'; _ha.appendChild(_img); 
               _$("main_image_wrapper").style.display = "block"; _$("ctl00_plhBody_thumbnails").appendChild(_ha);
            }
           _$("ctl00_plhBody_hdnPhotos").value = "1";
        }
        else {
            var ndIG = xD.selectNodes("D/Is/I");
            if (ndIG.length > 0) {
                for (var imC = 0; imC < ndIG.length; imC++) {
                    var _ha = crE("A"); _ha.className = "thumb_link"; _ha.href =  ndIG[imC].getAttribute("u"); var _img = crE("IMG"); _img.src = ndIG[imC].getAttribute("u");
                    if(_cObj(ndIG[imC].getAttribute("alttag"))) {
                        if(ndIG[imC].getAttribute("alttag") !=""){ _img.alt = ndIG[imC].getAttribute("alttag"); }
                        else { if(_cObj(xD.selectSingleNode("D").getAttribute("n"))) _img.alt = xD.selectSingleNode("D").getAttribute("n"); }
                    }
                    else { if(_cObj(xD.selectSingleNode("D").getAttribute("n"))) _img.alt = xD.selectSingleNode("D").getAttribute("n"); }
                    _img.width = '52'; _img.height = '39'; _ha.appendChild(_img); 
                   _$("main_image_wrapper").style.display = "block"; _$("ctl00_plhBody_thumbnails").appendChild(_ha);
                }
               _$("ctl00_plhBody_hdnPhotos").value = "1";
            }
            else {
                _$("ctl00_plhBody_hdnPhotos").value = "2"; var _ha = crE("A"); _ha.className = "thumb_link"; _ha.href =  '/Search/images/'+afId+'/noimage.gif';
                var _img = crE("IMG"); _img.src = '/Search/images/'+afId+'/noimage.gif'; _img.width = '52'; _img.height = '39'; _ha.appendChild(_img); 
               _$("ctl00_plhBody_thumbnails").appendChild(_ha); _$("ctl00_plhBody_display_text").innerHTML = "No Image available";
            }
        }
        var headID = document.getElementsByTagName("head")[0];  var nS = crE('script');
        nS.type = 'text/javascript'; nS.src = '/Search/JavaScript/thumb_gallery.js'; headID.appendChild(nS);
    }
   return false;
}
function pVdG(xD)
{
    if(_cObj(xD.selectNodes("D/Vs/V"))) {
        var vU, dt, fN, lN, mN, tl, ds ; var ndVG = xD.selectNodes("D/Vs/V");
        if (ndVG.length > 0) {
            for (var vCt = 0; vCt < ndVG.length; vCt++) {
                if (ndVG[vCt].selectSingleNode("MD").getAttribute("c") == "D") {
                    vU = ndVG[vCt].getAttribute("dl");
                    vU = videoUrl(ndVG[vCt].getAttribute("p"), vU);
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("t"))) tl = ndVG[vCt].selectSingleNode("MD").getAttribute("t");
                    else tl = ndVG[vCt].getAttribute("n");
                    if (tl.length > 50) { tl = tl.substring(0, 50); }
                    _$("ctl00_plhBody_lblVideoTitle").innerHTML = tl;
                    if(_cObj(ndVG[vCt].getAttribute("cr"))) pVCR(ndVG[vCt].getAttribute("cr"));
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("d"))) {
                        ds = ndVG[vCt].selectSingleNode("MD").getAttribute("d"); if (ds.length > 50) { ds = ds.substring(0, 50); }
                        _$("ctl00_plhBody_lblVideoDesc").innerHTML = ds;
                    }
                    if(_cObj(ndVG[vCt].getAttribute("on"))) dt = ndVG[vCt].getAttribute("on");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("f"))) fN = ndVG[vCt].selectSingleNode("N").getAttribute("f");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("l"))) lN = ndVG[vCt].selectSingleNode("N").getAttribute("l");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("m"))) mN = ndVG[vCt].selectSingleNode("N").getAttribute("m");
                    _$("ctl00_plhBody_lblVideoMetaData").innerHTML = dt;
                    if(fN != "") _$("ctl00_plhBody_lblVideoMetaData").innerHTML += " | " + fN + " " + mN;
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("dur")))
                        if(ndVG[vCt].selectSingleNode("MD").getAttribute("dur")!= "") _$("ctl00_plhBody_lblVideoDur").innerHTML = " | Duration: " + ndVG[vCt].selectSingleNode("MD").getAttribute("dur");
                    break;
                }
                else if (ndVG[vCt].selectSingleNode("MD").getAttribute("c") == "C") {
                    vU = ndVG[vCt].getAttribute("dl"); vU = videoUrl(ndVG[vCt].getAttribute("p"), vU);
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("t"))) tl = ndVG[vCt].selectSingleNode("MD").getAttribute("t");
                    else tl = ndVG[vCt].getAttribute("n"); if (tl.length > 50) { tl = tl.substring(0, 50); }
                    _$("ctl00_plhBody_lblVideoTitle").innerHTML = tl;
                    if(_cObj(ndVG[vCt].getAttribute("cr"))) pVCR(ndVG[vCt].getAttribute("cr"));
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("d"))) {
                        ds = ndVG[vCt].selectSingleNode("MD").getAttribute("d"); if (ds.length > 50) { ds = ds.substring(0, 50); }
                        _$("ctl00_plhBody_lblVideoDesc").innerHTML = ds;
                    }
                    if(_cObj(ndVG[vCt].getAttribute("on"))) dt = ndVG[vCt].getAttribute("on");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("f"))) fN = ndVG[vCt].selectSingleNode("N").getAttribute("f");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("l"))) lN = ndVG[vCt].selectSingleNode("N").getAttribute("l");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("m"))) mN = ndVG[vCt].selectSingleNode("N").getAttribute("m");
                    _$("ctl00_plhBody_lblVideoMetaData").innerHTML = dt;
                    if(fN != "") _$("ctl00_plhBody_lblVideoMetaData").innerHTML += " | " + fN + " " + mN;
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("dur"))) if(ndVG[vCt].selectSingleNode("MD").getAttribute("dur")!="") _$("ctl00_plhBody_lblVideoDur").innerHTML = " | Duration: " + ndVG[vCt].selectSingleNode("MD").getAttribute("dur");
                    break;
                }
                else if (ndVG[vCt].selectSingleNode("MD").getAttribute("c") == "E") {
                    vU = ndVG[vCt].getAttribute("dl"); vU = videoUrl(ndVG[vCt].getAttribute("p"), vU);
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("t"))) tl = ndVG[vCt].selectSingleNode("MD").getAttribute("t");
                    else tl = ndVG[vCt].getAttribute("n"); 
                    if (tl.length > 50) { tl = tl.substring(0, 50); }
                    _$("ctl00_plhBody_lblVideoTitle").innerHTML = tl;
                    if(_cObj(ndVG[vCt].getAttribute("cr"))) pVCR(ndVG[vCt].getAttribute("cr"));
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("d"))) {
                        ds = ndVG[vCt].selectSingleNode("MD").getAttribute("d"); if (ds.length > 50) { ds = ds.substring(0, 50); }
                        _$("ctl00_plhBody_lblVideoDesc").innerHTML = ds;
                    }
                    if(_cObj(ndVG[vCt].getAttribute("on"))) dt = ndVG[vCt].getAttribute("on");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("f"))) fN = ndVG[vCt].selectSingleNode("N").getAttribute("f");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("l"))) lN = ndVG[vCt].selectSingleNode("N").getAttribute("l");
                    if(_cObj(ndVG[vCt].selectSingleNode("N").getAttribute("m"))) mN = ndVG[vCt].selectSingleNode("N").getAttribute("m");
                    _$("ctl00_plhBody_lblVideoMetaData").innerHTML = dt;
                    if(fN != "") _$("ctl00_plhBody_lblVideoMetaData").innerHTML += " | " + fN + " " + mN;
                    if(_cObj(ndVG[vCt].selectSingleNode("MD").getAttribute("dur")))
                        if(ndVG[vCt].selectSingleNode("MD").getAttribute("dur")!="") _$("ctl00_plhBody_lblVideoDur").innerHTML = " | Duration: " + ndVG[vCt].selectSingleNode("MD").getAttribute("dur");
                    break;
                }
                else { _$("ctl00_plhBody_video_object").style.display = "none"; _$("ctl00_plhBody_hdnVideos").value = "2"; }
            }
            var dNm = _$("ctl00_plhBody_hiddestName").value; _$("lblVideoSeo").value = ""; if(dNm != "") _$("lblVideoSeo").innerHTML += "Video of: " + dNm;
        }
        crDHDLPV(vU);
    }
    return false;
}
function crDHDLPV(vU)
{
    if(_cObj(vU) && vU != "") {
        _$("hidDefVideoXml").value = vU; WVE(vU,_$("ctl00_plhBody_video_object"), "242", "324", "0"); _$("ctl00_plhBody_hdnVideos").value = "1";
    }
    else { _$("ctl00_plhBody_video_object").style.display = "none"; _$("ctl00_plhBody_hdnVideos").value = "2"; }
    return false;
}
function pCR(xD)
{
    var hrCR = "0"; var cvrCR = "0"; var erCR = "0"; var cCt = 0; var hCt = 0; var eCt = 0; var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    if(_cObj(xD.selectNodes("D/Vs/V"))) { var xRL = xD.selectNodes("D/Vs/V");
        if (xRL.length > 0) { var vCt = 0;
            for (var rCt = 0; rCt < xRL.length; rCt++) {
                var imU; var _divR = crE("DIV"); var li = crE("li"); _divR.appendChild(li); li.style.border = "1";
                var _img = crRIm(xRL[rCt]); var _haImg = crE("A"); _haImg.href = "JavaScript:void(0)"; _haImg.appendChild(_img); li.appendChild(_haImg);
                var ul = crE("ul"); li.appendChild(ul); var li1 = crE("li"); li1.className = "quote";
                var strong = crE("strong");
                if(_cObj(xRL[rCt].selectSingleNode("MD").getAttribute("t"))) strong.innerHTML = xRL[rCt].selectSingleNode("MD").getAttribute("t");
                else strong.innerHTML = xRL[rCt].getAttribute("n");
                li1.appendChild(strong); ul.appendChild(li1);
                var li2 = crE("li"); var span = crE("span"); var Vds = xRL[rCt].selectSingleNode("MD").getAttribute("d") ;
                if(Vds.length > 60) li2.style.overflowX = "scroll";
                span.innerHTML = Vds; li2.appendChild(span); ul.appendChild(li2);
                var p = crE("p"); p.className =  "top"; li.appendChild(p);
                var stA = crE("span"); stA.style.color = "#cc0099"; stA.innerHTML = "Avg. Customer Rating"; p.appendChild(stA);
                var sCr = crE("span"); sCr.style.width = "180px"; var rt = xRL[rCt].getAttribute("cr"); var ct = 0;
                if(rt != 0) {
                    var span = crE("span"); span.innerHTML = rt; span.className = "cRating"; span.style.color = "#500023"; sCr.align = "center"; sCr.appendChild(span);
                    var imS = rateImage(rt); sCr.appendChild(imS);
                }
                else { var ap = crE('SPAN'); ap.align = "center"; ap.innerHTML += "<strong style='color:#500023; font-size:1.1em'>  Not Rated </strong>"; sCr.appendChild(ap); }
                p.appendChild(sCr); var sDt = crE("span"); sDt.style.width = "180px";
                var _dt = xRL[rCt].getAttribute("on"); sDt.innerHTML = _dt; p.appendChild(sDt);
                var sNm = crE("span"); var _sb = "";
                if (xRL[rCt].selectSingleNode("N").getAttribute("f") != "") { _sb +=xRL[rCt].selectSingleNode("N").getAttribute("f"); _sb += " "; }
                if (xRL[rCt].selectSingleNode("N").getAttribute("m") != "") { _sb += xRL[rCt].selectSingleNode("N").getAttribute("m"); _sb += " "; }
                if (xRL[rCt].selectSingleNode("N").getAttribute("l") != "") { _sb += xRL[rCt].selectSingleNode("N").getAttribute("l"); }
                sNm.innerHTML = _sb; p.appendChild(sNm); var sDur = crE("span");
                if(xRL[rCt].selectSingleNode("MD").getAttribute("dur")!="") sDur.innerHTML = "Duration: " + xRL[rCt].selectSingleNode("MD").getAttribute("dur");
                sDur.style.width = "180px"; p.appendChild(sDur);
                if (xRL[rCt].selectSingleNode("MD").getAttribute("c").toLowerCase().trim() == "c") {
                    cCt += 1; if( cCt<=3) _$("ctl00_plhBody_pnlCustomerReview").appendChild(_divR);
                    else { _$("ctl00_plhBody_MoreCustReview").style.display = "block"; _$("ctl00_plhBody_CustReviewPanel1").appendChild(_divR); }
                    if(_cObj(xD.selectSingleNode("D").getAttribute("vr"))) { cvrCR = xD.selectSingleNode("D").getAttribute("vr"); }
                    else { cvrCR = xD.selectSingleNode("D").getAttribute("cr"); }
                }
                else if (xRL[rCt].selectSingleNode("MD").getAttribute("c").toLowerCase().trim() == "e") {
                    eCt += 1; if( eCt<=3) _$("ctl00_plhBody_pnlExpertReview").appendChild(_divR);
                    else { _$("ctl00_plhBody_MoreExpertReview").style.display = "block"; _$("ctl00_plhBody_ExpertReviewPanel1").appendChild(_divR); }
                    if(_cObj(xD.selectSingleNode("D").getAttribute("er"))) { erCR = xD.selectSingleNode("D").getAttribute("er"); }
                    else { erCR = xD.selectSingleNode("D").getAttribute("cr"); }
                }
                else if (xRL[rCt].selectSingleNode("MD").getAttribute("c").toLowerCase().trim() == "d") {
                   hCt += 1; if( hCt<=3) _$("ctl00_plhBody_pnlDestinationReview").appendChild(_divR);
                    else { _$("ctl00_plhBody_MoreDestnReview").style.display = "block"; _$("ctl00_plhBody_DestnReviewPanel1").appendChild(_divR); }
                    if(_cObj(xD.selectSingleNode("D").getAttribute("vr"))) { hrCR = xD.selectSingleNode("D").getAttribute("vr"); }
                    else { hrCR = xD.selectSingleNode("D").getAttribute("cr"); }                
                }
            }
        }
    pHVRCR(hrCR); pCVRCR(cvrCR); pEVRCR(erCR);
    if (cCt == 0) {
        var liCS = crE("li"); var sCM = crE("span"); liCS.appendChild(sCM); var pCM = crE("p"); liCS.appendChild(pCM);   
        sCM.innerHTML = "Sorry! There are no Customer Video reviews currently available for this destination. We are adding new content to the site almost every day, please come back and check for updates. ";
        sCM.style.color = "#a32578"; sCM.style.fontSize = "12px"; _$("ctl00_plhBody_pnlCustomerReview").appendChild(liCS);
    }   
    if (hCt == 0) {
        var liHS = crE("li"); var sHM = crE("span"); liHS.appendChild(sHM); var pHM = crE("p"); liHS.appendChild(pHM);
        sHM.innerHTML = "Sorry! There are no Video reviews currently available for this destination. We are adding new content to the site almost every day, please come back and check for updates.";
        sHM.style.color = "#a32578"; sHM.style.fontSize = "12px"; _$("ctl00_plhBody_pnlDestinationReview").appendChild(liHS);
        if (cCt != 0) _$("hidTabDefault").value = "customer_video_content";
        else if (eCt != 0) _$("hidTabDefault").value = "expert_reviews_content";
    }
    else { _$("hidTabDefault").value = "destination_reviews_content"; }
    if (eCt == 0) {
        var liES = crE("li"); var sEM = crE("span"); liES.appendChild(sEM); var pEM = crE("p"); liES.appendChild(pEM);
        sEM.innerHTML = "Sorry! There are no Expert Video reviews currently available for this destination. We are adding new content to the site almost every day, please come back and check for updates.";
        sEM.style.color = "#a32578"; sEM.style.fontSize = "12px"; _$("ctl00_plhBody_pnlExpertReview").appendChild(liES);
    }
    return false;
   }
}
function pRLDrpdn(xD)
{
    var ndlB = xD.selectNodes("D/DR/R"); var ddlResort = _$("ctl00_plhBody_ddlResort"); var oIt, tV, rId;
    for (var count = ddlResort.options.length-1; count >-1; count--) { ddlResort.options[count] = null; }
    oIt = new Option( "-- Any --", "",  false, false); ddlResort.options[ddlResort.length] = oIt; 
    if(_cObj(ndlB)) {
        if(ndlB.length > 0) {
            for(var rCt=0; rCt < ndlB.length; rCt++) {
               tV = ndlB[rCt].getAttribute("n"); rId = ndlB[rCt].getAttribute("id"); 
               oIt = new Option(tV, rId); ddlResort.options[ddlResort.length] = oIt;
            }
        }
    }
}
function pCWR(xD)
{
    var cwrCR = "0"; var cwrCt = "0"; var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    var xWR = xD.selectNodes("D/RWs/RW");
    if (xWR.length > 0) {
        for (var rCt = 0; rCt < xWR.length; rCt++) {
            cwrCt = "1"; var liRw = crE("li"); var _imgRw = crE("IMG"); _imgRw.className = "logo";
            if(_cObj(xWR[rCt].getAttribute("im"))) { _imgRw.src = xWR[rCt].getAttribute("im");
                if(_cObj(xWR[rCt].getAttribute("alt"))) _imgRw.alt = xWR[rCt].getAttribute("alt");
            }
            else _imgRw.src = '/Search/images/'+afId+'/no_picture.jpeg';
            var pRw = crE("p"); pRw.className = "review_link_text"; var ha = crE("A"); ha.href = "javascript:void(0);";
            ha.onclick = function(){openReview(xWR[rCt].getAttribute("dl"))};
            if(parseInt(xWR[rCt].getAttribute("rc")) > 1) ha.innerHTML = xWR[rCt].getAttribute("rc") + " Reviews";
            else ha.innerHTML = xWR[rCt].getAttribute("rc") + " Review";
            pRw.appendChild(ha);
            var pRs = crE("p"); pRs.className = "review_score"; pRs.innerHTML = xWR[rCt].getAttribute("ar");
            liRw.appendChild(_imgRw); liRw.appendChild(pRw); liRw.appendChild(pRs); _$("ctl00_plhBody_CustWrittenReviewPanel").appendChild(liRw);
            if(_cObj(xD.selectSingleNode("D").getAttribute("cr"))) { cwrCR = xD.selectSingleNode("D").getAttribute("cr"); }
        }
    }
    pCWRCR(cwrCR);
    if (cwrCt == "0") {
        var liCWS = crE("li"); var sCWM = crE("span"); liCWS.appendChild(sCWM); var pCWM = crE("p"); liCWS.appendChild(pCWM);
        sCWM.innerHTML = "Sorry! There are no Written reviews currently available for this destination. We are adding new content to the site almost every day, please come back and check for updates. ";
        sCWM.style.color = "#a32578"; sCWM.style.fontSize = "12px"; _$("ctl00_plhBody_CustWrittenReviewPanel").appendChild(liCWS);
    }
    else { _$("hidTabDefault").value = "customer_written_content"; }
    tabOrder(); return false;
}
function openReview(_url) { window.open('/Search/Reviews.aspx?url=' + _url + '',DownloadForm,location=yes,status=no,toolbar=no,menubar=1); }
function pGM( xDN)
{
    _$("ctl00_plhBody_hidLat").value = xDN.getAttribute("x"); _$("ctl00_plhBody_hidLon").value = xDN.getAttribute("y"); _$("ctl00_plhBody_hidHotelName").value = xDN.getAttribute("n");
}
function pPS(xPD) { _$("ctl00_plhBody_hidPriceXml").value = xS(xPD); return false; }
function pVCR(vdR)
{
    var ct = 0; var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    if(vdR != 0) {
        var span = crE("span"); span.innerHTML = vdR; span.className = "cRating"; _$("ctl00_plhBody_tdVideoRating").appendChild(span);
        var imS = rateImage(vdR); _$("ctl00_plhBody_tdVideoRating").appendChild(imS);
    }
    else {
        var p = crE('SPAN'); p.align = "center"; p.innerHTML += "<strong style='color:#500023; font-size:1.1em'> Not Rated </strong>";
        _$("ctl00_plhBody_tdVideoRating").appendChild(p);
    }
    _$("ctl00_plhBody_tdVideoRating").align ="center"; return false;
}
function pHVRCR(vdR)
{
    var ct = 0; var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    if(vdR != 0) { var span = crE("span"); span.innerHTML = vdR; span.className = "cRating cWhite"; _$("ctl00_plhBody_tdHrCustRating").appendChild(span); var imS = rCIm(vdR); _$("ctl00_plhBody_tdHrCustRating").appendChild(imS); }
    else { var spanP = crE('Span'); spanP.align = "center"; spanP.innerHTML += "<strong style='color:#FFFFFF; font-size:1.1em'>  Not Rated </strong>"; _$("ctl00_plhBody_tdHrCustRating").appendChild(spanP); }
    _$("ctl00_plhBody_tdHrCustRating").align ="center"; return false;
}
function pCVRCR(vdR)
{
    var ct = 0; var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    if(vdR != 0) {
        var span = crE("span"); span.innerHTML = vdR; span.className = "cRating cWhite"; _$("ctl00_plhBody_tdCvrCustRating").appendChild(span);
        var imS = rCIm(vdR); _$("ctl00_plhBody_tdCvrCustRating").appendChild(imS);
    }
    else { var spanP = crE('Span'); spanP.align = "center"; spanP.innerHTML += "<strong style='color:#FFFFFF; font-size:1.1em'>  Not Rated </strong>"; _$("ctl00_plhBody_tdCvrCustRating").appendChild(spanP); }
    _$("ctl00_plhBody_tdCvrCustRating").align ="center"; return false;
}
function pEVRCR(vdR)
{
    var ct = 0; var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    if(vdR != 0) {
        var span = crE("span"); span.innerHTML = vdR; span.className = "cRating cWhite"; _$("ctl00_plhBody_tdErCustRating").appendChild(span);
        var imS = rCIm(vdR); _$("ctl00_plhBody_tdErCustRating").appendChild(imS);
    }
    else { var spanP = crE('Span'); spanP.align = "center"; spanP.innerHTML += "<strong style='color:#FFFFFF; font-size:1.1em'>  Not Rated </strong>"; _$("ctl00_plhBody_tdErCustRating").appendChild(spanP); }
    _$("ctl00_plhBody_tdErCustRating").align ="center"; return false;
}

function pCWRCR(vdR)
{
    var ct = 0; var afId = _$("ctl00_plhBody_hidAffiliateId").value;
    if(vdR != 0) {
        var span = crE("span"); span.innerHTML = vdR; span.className = "cRating cWhite"; _$("ctl00_plhBody_tdCwrCustRating").appendChild(span);
        var imS = rCIm(vdR); _$("ctl00_plhBody_tdCwrCustRating").appendChild(imS);
    }
    else { var sWP = crE('SPAN'); sWP.align = "center"; sWP.innerHTML += "<strong style='color:#FFFFFF; font-size:1.1em'>  Not Rated </strong>"; _$("ctl00_plhBody_tdCwrCustRating").appendChild(sWP); }
    _$("ctl00_plhBody_tdCwrCustRating").align ="center"; return false;
}
function crIm(ndIm)
{
    var imU; var afId = _$("ctl00_plhBody_hidAffiliateId").value; var _image = crE("IMG"); _image.className = "video_thumb";
    var VdNX = xS(ndIm); _image.onclick = function(){ SDVP(VdNX) };
    if(_cObj(ndIm.selectSingleNode("Is"))) {
        if(_cObj(ndIm.selectSingleNode("Is/I[@t='T']"))) {
            var ndIm = ndIm.selectSingleNode("Is/I[@t='T']"); imU = ndIm.getAttribute("u");
            _image.src = playIcon(afId, 1); _image.style.background = "url('"+imU+"')";
            if(_cObj(ndIm.getAttribute("alt"))) _image.alt = ndIm.getAttribute("alt");
        }
        else {
            if(_cObj(ndIm.selectSingleNode("Is/I"))) {
                var ndIm = ndIm.selectSingleNode("Is/I"); imU = ndIm.getAttribute("u");
                if(_cObj(ndIm.getAttribute("p"))) if(ndIm.getAttribute("p") == _YTID) if(imU.indexOf("http:")!= 0) imU = _YTIMG + "" + ndIm.getAttribute("dl") + "/" + imU;
                _image.src = playIcon(afId, 1); _image.style.background = "url('"+imU+"')";
                if(_cObj(ndIm.getAttribute("alt"))) _image.alt = ndIm.getAttribute("alt");
            }
            else { imU = '/Search/images/'+afId+'/no_picture.jpeg'; _image.style.background = "url('"+imU+"')"; }
        }
    }
    else { imU = '/Search/images/'+afId+'/no_picture.jpeg'; _image.style.background = "url('"+imU+"')"; }
    return _image;
}

function sTCI(tN)
{
    var dId = _$("hidDestId").value; var dN = _$("ctl00_plhBody_hiddestName").value;
    DCS(1, 0, 'DDLP', tN, dId, dN);
}
function SMCR()
{
    _$("ctl00_plhBody_MoreCustReview").style.display = "none"; _$("ctl00_plhBody_CustReviewPanel1").style.display = "block"; _$("ctl00_plhBody_CloseCustReview").style.display = "block";
}
function SCCR()
{
    _$("ctl00_plhBody_MoreCustReview").style.display = "block"; _$("ctl00_plhBody_CustReviewPanel1").style.display = "none"; _$("ctl00_plhBody_CloseCustReview").style.display = "none";
}
function SMDR()
{
    _$("ctl00_plhBody_MoreDestnReview").style.display = "none"; _$("ctl00_plhBody_DestnReviewPanel1").style.display = "block"; _$("ctl00_plhBody_CloseDestnReview").style.display = "block";
}
function SCDR()
{
    _$("ctl00_plhBody_MoreDestnReview").style.display = "block"; _$("ctl00_plhBody_DestnReviewPanel1").style.display = "none"; _$("ctl00_plhBody_CloseDestnReview").style.display = "none";
}
function SMCWR()
{
    _$("ctl00_plhBody_MoreCustWrittenReview").style.display = "none"; _$("ctl00_plhBody_CustWrittenReviewPanel1").style.display = "block"; _$("ctl00_plhBody_CloseCustWrittenReview").style.display = "block";
}
function SCCWR()
{
    _$("ctl00_plhBody_MoreCustWrittenReview").style.display = "block"; _$("ctl00_plhBody_CustWrittenReviewPanel1").style.display = "none"; _$("ctl00_plhBody_CloseCustWrittenReview").style.display = "none";
}
function SMER()
{
    _$("ctl00_plhBody_MoreExpertReview").style.display = "none"; _$("ctl00_plhBody_ExpertReviewPanel1").style.display = "block"; _$("ctl00_plhBody_CloseExpertReview").style.display = "block";
}
function SCER()
{
    _$("ctl00_plhBody_MoreExpertReview").style.display = "block"; _$("ctl00_plhBody_ExpertReviewPanel1").style.display = "none"; _$("ctl00_plhBody_CloseExpertReview").style.display = "none";
}
function crRIm(ndIm)
{
    var imU; var afId = _$("ctl00_plhBody_hidAffiliateId").value; var _image = crE("IMG"); _image.className = "video_thumb";
    var VdNX = xS(ndIm); _image.onclick = function(){ SDVP(VdNX) };
    if(_cObj(ndIm.selectSingleNode("Is"))) {
        if(_cObj(ndIm.selectSingleNode("Is/I[@t='T']"))) {
            var ndIm = ndIm.selectSingleNode("Is/I[@t='T']"); imU = ndIm.getAttribute("u"); _image.src = playIcon(afId, 1); _image.style.background = "url('"+imU+"')";
            if(_cObj(ndIm.getAttribute("alttag"))) _image.alt = ndIm.getAttribute("alttag");
        }
        else {
            if(_cObj(ndIm.selectSingleNode("Is/I"))) {
                var ndIm = ndIm.selectSingleNode("Is/I"); imU = ndIm.getAttribute("u");
                 if(_cObj(ndIm.getAttribute("p"))) if(ndIm.getAttribute("p") == _YTID) if(imU.indexOf("http:")!= 0) imU = _YTIMG + "" + ndIm.getAttribute("dl") + "/" + imU;
                _image.src = playIcon(afId, 1); _image.style.background = "url('"+imU+"')";
                if(_cObj(ndIm.getAttribute("alttag"))) _image.alt = ndIm.getAttribute("alttag");
            }
            else { imU = '/Search/images/'+afId+'/no_picture.jpeg'; _image.style.background = "url('"+imU+"')"; }
        }
    }
    else { imU = '/Search/images/'+afId+'/no_picture.jpeg'; _image.style.background = "url('"+imU+"')"; }
    return _image;
}
function SDVP(_xml)
{
    rvDDLP(); var xD=crXD(_xml); var _ndV,_tblV,_vc='', _ru; _ndV = xD.selectSingleNode("V"); _tblV = PVS(_ndV,3, "DDL");
    if(_cObj(_ndV)){    
        _$("hdnCurrentVideoXml").value = xS(_ndV);
        if(_cObj(_ndV.selectSingleNode("MD").getAttribute("c"))) { _vc = _ndV.selectSingleNode("MD").getAttribute("c"); }
        if(_cObj(_ndV.getAttribute("ru"))) { _ru = _ndV.getAttribute("ru"); } }
    var _dvVP = _$("divVideoPopUp"); cldv(_dvVP);
    var _xmlDestDoc =crXD(_$("ctl00_plhBody_hidDestXml").value);
    var hdID, hdN, hdAd, hdS;
    if(_cObj(_xmlDestDoc)){
        if(_cObj(_xmlDestDoc.selectSingleNode("D").getAttribute("id"))){
            hdID  = _xmlDestDoc.selectSingleNode("D").getAttribute("id"); hdN  = _xmlDestDoc.selectSingleNode("D").getAttribute("n");   hdAd = ""; hdS = ""; } }
    var _imgU; if(_cObj(_ndV.selectSingleNode("Is/I[@t='T']"))) _ndI = _ndV.selectSingleNode("Is/I[@t='T']");
    else _ndI = _ndV.selectSingleNode("Is/I");
    if(_cObj(_ndI)) {
        if(_cObj(_ndI.getAttribute("u"))) { _imgU = _ndI.getAttribute("u"); }
	    if(_cObj(_ndI.getAttribute("p"))) if(_ndI.getAttribute("p") == _YTID) if(_imgU.indexOf("http:")!= 0) _imgU = _YTIMG + "" + _ndV.getAttribute("dl") + "/" + _imgU;
    }
    _$("ctl00_plhBody_hidPopUpNodeXml").value = hdID + "||" + hdN + "||" + hdAd + "||" + hdS + "||" + _imgU;
    var tblHDInfo = VDSI(hdID, hdN, hdAd, hdS); var tbl,tbdy,tr,td;
    tbl=crE('TABLE'); tbl.border='0'; tbl.width='100%'; tbdy=crE('TBODY'); tbl.appendChild(tbdy);
    tr=crE('TR'); tbdy.appendChild(tr); td=crE('TD'); if(_cObj(tblHDInfo)) td.appendChild(tblHDInfo); tr.appendChild(td);
    td=crE('TD'); td.rowSpan = 2; td.vAlign="top"; td.innerHTML = _$("popupRightBanner").value; tr.appendChild(td);
    tr=crE('TR'); tbdy.appendChild(tr); td=crE('TD'); td.appendChild(_tblV); tr.appendChild(td);
    _dvVP.style.width="780px"; _dvVP.appendChild(tbl);
    var _dvVideo = _$("dvVideo"); var _url = _dvVideo.innerHTML;
    WVE(_url,_dvVideo,"293", "396" , "1" );  
    _videoPopUp();
    var _id, _type; _id = _ndV.getAttribute("id"); _type = "V"; uS(_id,_type, _vc);
    var _vI = "Video Info : "+_vc; DCS(1, 0, 'DDLP', _vI, hdID, _id);
}  
function DDLPEP()
{
    rvDDLP(); var _xmlDdlpDoc = crXD(_$("ctl00_plhBody_hidDestXml").value);
    if(_cObj(_xmlDdlpDoc)) { var dId = _xmlDdlpDoc.selectSingleNode("D").getAttribute("id"); PopupEmail(dId , 3, "DDL", "3"); }
}
function crHDLPV(_vUrl)
{
    if(_cObj(_vUrl) && _vUrl != "") {
        _$("hidDefVideoXml").value = _vUrl; WVE(_vUrl,_$("ctl00_plhBody_video_object"), "242", "324", "0"); _$("ctl00_plhBody_hdnVideos").value = "1";
    }
    else { _$("ctl00_plhBody_video_object").style.display = "none"; _$("ctl00_plhBody_hdnVideos").value = "2"; }
    return false;
}

// Amit: For Flight section
function GetDApt()
{    
    _page="IATA";//_chr="184";
    var _dsV = _$("ctl00_plhBody_hidDestValue").value.split(',');
     var theDate = new Date();
     //var rU = "/Search/AjaxHome.aspx?page="+_page+"&chr="+_chr +"&dt="+ theDate.getTime();
     var rU = "/Search/AjaxHome.aspx?page=IATA&cid="+_dsV[2] +"&lid=0&hotelID=0&dt="+ theDate.getTime();
     var XmlHttp = CreateXmlHttp();
     if(XmlHttp) 
     { XmlHttp.onreadystatechange = function() { if(XmlHttp.readyState == 4) {
        if(XmlHttp.status == 200) {PplDApt(XmlHttp.responseText);}}}
	    XmlHttp.open("GET", rU, true); XmlHttp.send(null);		
     }
}
function PplDApt(_JSONStr)
{    
    _$("ddSearch").style.display = "block"; 
    var ddlAirport = _$("ctl00_plhBody_ddlAirport"); var _opI,_tV,_dId;
    for (var count = ddlAirport.options.length-1; count >-1; count--) { ddlAirport.options[count] = null; }
    _opI = new Option( "--Select--", "-1",  false, false); ddlAirport.options[ddlAirport.length] = _opI;   
    if(_JSONStr.length>0 && _JSONStr.indexOf('<form')==-1) 
    {  
        var strArr = _JSONStr.split('*#*#*');
        var JObj = eval('(' + strArr[0] + ')');         
        for(var i = 0; i < JObj.IATA.length; i++){
            _tV = JObj.IATA[i].V; _dId = JObj.IATA[i].C; 
            _opI = new Option(_tV, _dId); ddlAirport.options[ddlAirport.length] = _opI;
        }
        PplDBrd(strArr[1]);           
    }
    else
    {
         //_$("ddSearch").style.display = "none"; 
         _$("rdH").style.display = "none";
         _$("ctl00_plhBody_lblFnH").style.display = "none";
    }
}
function PplDBrd(_brdStr)
{   
    var ddlBrd = _$("ctl00_plhBody_ddlBoard");
    var _opI,_tV,_dId;
    for (var count = ddlBrd.options.length-1; count >-1; count--) { ddlBrd.options[count] = null; }
    _opI = new Option( "--Select--", "-1",  false, false); ddlBrd.options[ddlBrd.length] = _opI;
    _opI = new Option( "Any", "ANY",  false, false); ddlBrd.options[ddlBrd.length] = _opI; 
    if(_brdStr.length>0 && _brdStr.indexOf('<form')==-1) 
    {  
        var JObj = eval('(' + _brdStr + ')');          
        for(var i = 0; i < JObj.BOARD.length; i++){
            _tV = JObj.BOARD[i].V; _dId = JObj.BOARD[i].C; 
            _opI = new Option(_tV, _dId); ddlBrd.options[ddlBrd.length] = _opI; }                   
    }
    else { _$("rdH").style.display = "none"; _$("ctl00_plhBody_lblFnH").style.display = "none"; }
}
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 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 
        { 
            //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 pDrDDLP(_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 == '1')
        {
            
            if(_$("ctl00_plhBody_hidBType").value.toUpperCase()=="TRUE")
            {
                setDfDt("ctl00_plhBody_hotelCheckin", 7, "ctl00_plhBody_checkinValue");    
                cOutDate(7);
                if (bName == "Microsoft Internet Explorer")                
                    setTimeout("pDur(7)" , 1);
                else
                    pDur(7);  
            }
            else
            {   
                setDfDt("ctl00_plhBody_hotelCheckin", 7, "ctl00_plhBody_checkinValue");    
                cOutDate(2);         
                if (bName == "Microsoft Internet Explorer")                
                    setTimeout("pDur(2)" , 1);
                else
                    pDur(2);             
            } 
        }
        else if(_cObj(_$('hidFnH')) && _$('hidFnH').value == '2')
        {
           if(_$("ctl00_plhBody_hidBType").value.toUpperCase()=="TRUE")
            {
                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){}          
             
}