﻿/**
JavaScript files for homepage
*/

// Global variable declaration
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])
var className = '';
var currentPageName = unescape(window.location.pathname);
var overlaysKeys =
   {
       parking: "", gyms: "", pubs: "", schools: "", hospitals: "", railwayStation: "", underground: "",
       localShops: "", cinemas: "", libraries: "", wikipedia: "", publicTransport: ""
   };

/* Function Used to fix the Alpha transparency for a png image */
function fixPNG(myImage) {
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) {
        var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
        var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
        var imgTitle = (myImage.title) ?
                                             "title='" + myImage.title + "' " : "title='" + myImage.alt + "' "
        var imgStyle = "display:inline-block;" + myImage.style.cssText
        var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width
                  + "px; height:" + myImage.height
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
        myImage.outerHTML = strNewHTML
    }
}

/* Function used to open the help link page */
function OpenHelpPage() {
    window.open("http://money.uk.msn.com/MSN-Local/help.aspx");
} 

/* Function used to open the help link page  for Properties for sale or rent */
function OpenPreferencesHelpPage() {
    window.open("http://money.uk.msn.com/MSN-Local/help.aspx#M");
}

function showHelpText()
{
    document.getElementById("imgPreference").alt='';
    document.getElementById("myPrefHelpTextdiv").style.display = "";
    
}

function hideHelpText()
{
    document.getElementById("myPrefHelpTextdiv").style.display = "none";
     document.getElementById("imgPreference").alt='My preferences';
}
/* Function used to open the property finder site */
function OpenPropertyFinderWebSite() {
    window.open("http://www.propertyfinder.com/");
}

// function used for disabling the Property under offer on click 
// of buy or rent radio buttons used in the HomePageProperty search control
// and property search control

function disableListItems(checkBoxListId, chkArray, disable) {
    // Get the checkboxlist object.
    objCtrl = checkBoxListId.id;

    // Does the checkboxlist not exist?
    if (objCtrl == null)
        return;

    var i = 0;
    objItem = document.getElementById(objCtrl + '_' + chkArray); // Object of the Price under offer ListItem

    // Disable/Enable the checkbox.
    objItem.disabled = disable;

    // Should the checkbox be disabled?
    objItem.checked = false;
}

/* Function used to show the amenities options for map result in HomePropertySearchControl.ascx */
function showPointsOfInterestDiv(rdbSelectedId) {   
    var selection = rdbSelectedId.getElementsByTagName("input");
    for (var i = 0; i < selection.length; i++) {
        if (selection[i].checked) {
            if (i == 0) {
                document.getElementById("AmenitiesChoices").className = "hide homesrchcrtl";
            }
            else if (i == 1) {
                document.getElementById("AmenitiesChoices").className = "show homesrchcrtl";
            }
        }
    }
}
/////////////////////Get the server side control reference///

/* Returns the container prefix as all controls have that on their ids */
function getCrtlPrefix(hiddenFieldID) {
    var prefix;
    var objCrtlPrefix = document.getElementById(hiddenFieldID);
    if (objCrtlPrefix)
        prefix = objCrtlPrefix.value;
    return prefix;
}

/* This function is used to read server side control values */
function readValue(ctrlName, hiddenFieldID) {
    var prefix = getCrtlPrefix(hiddenFieldID);
    var objCrtl = document.getElementById(prefix + ctrlName);
    return objCrtl;

}


/* This function is used to read the telerik control values */
function readTelerikControlValue(ctrlName, hiddenFieldID) {
    var prefix = getCrtlPrefix(hiddenFieldID);
    var objCrtl = $find(prefix + ctrlName);
    return objCrtl;

}

//////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////

var selectSale = false;
var selectLease = false;

//This function is used to show/hide the price dropdown values according to buy/rent option.
function showHidePriceDiv(rdolistId) {
   
    var elem = rdolistId.getElementsByTagName("input");
    var chkParkingOption = readValue("chkParkingOption", "ctrlPrefixForHomeSearchControl"); // document.getElementById("<%=chkParkingOption.ClientID  %>");

    for (var i = 0; i < elem.length; i++) {
        if (elem[i].checked) {
            if (i == 0)//sale div selected
            {
                disableListItems(chkParkingOption, "3", false); // Enable Property Under Offer List Item Index=3
                document.getElementById("saleDiv").className = "show";
                document.getElementById("leaseDiv").className = "hide";
                selectSale = true;
                selectLease = false;
            }
            else if (i == 1) //lease div selected 
            {
                disableListItems(chkParkingOption, "3", true); // Disable Property Under Offer List Item Index=3
                document.getElementById("saleDiv").className = "hide";
                document.getElementById("leaseDiv").className = "show";
                selectLease = true;
                selectSale = false;
            } //end of the if block
        } // end of the outer if loop
    } //end of the forloop     
}


/* This function is used to validate the price values.   */
function validateCombo() {
    //var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
    var iChars = "!@#$%^&*()+=[]\\;,./{}|\":<>?";
    var emptySearhtext = "E.g. London or W6";
    var dvErrorDetail = document.getElementById("dvErrorDetails");
    var divLocationMsgtext = document.getElementById("divLocationMsg");
    var searchtext = readValue("txtSearch", "ctrlPrefixForHomeSearchControl").value.replace(/(^\s*)|(\s*$)/g, "");  //document.getElementById("<%=txtSearch.ClientID %>").value.replace(/(^\s*)|(\s*$)/g, "");
    searchtext = unescape(searchtext);    

    //if search text is empty
    if ((searchtext == '') || (emptySearhtext == searchtext)) {
        dvErrorDetail.style.display = 'block';
        dvErrorDetail.style.visibility = 'visible';
        divLocationMsgtext.innerHTML = "Enter location, areacode, postcode, county or city."
        readValue("txtSearch", "ctrlPrefixForHomeSearchControl").focus();
        return false;
    }

    //Check for special chars
    for (var i = 0; i < searchtext.length; i++) {
        if (iChars.indexOf(searchtext.charAt(i)) != -1) {
            dvErrorDetail.style.display = 'block';
            dvErrorDetail.style.visibility = 'visible';
            divLocationMsgtext.innerHTML = "Special characters are not allowed in the search"
            readValue("txtSearch", "ctrlPrefixForHomeSearchControl").focus();
            return false;
        }
    }
    dvErrorDetail.style.display = 'none';
    dvErrorDetail.style.visibility = 'hidden';    
   return true;
}


/* Get the querystring parameters */
function GetQueryString(buyOrRentParameter) {
    if (validateCombo()) {
       
       var searchIndicator = document.getElementById('searchIndicator');
        var queryStringParameter = ""; //new StringBuilder();
        var searchtext = readValue("txtSearch", "ctrlPrefixForHomeSearchControl").value.replace(/(^\s*)|(\s*$)/g, ""); //document.getElementById("ctl00_TopSearchControl1_SearchControlTop_i0_i0_txtSearch").value.replace(/(^\s*)|(\s*$)/g, "");
        searchtext = escape(searchtext);
        queryStringParameter = "loc=" + searchtext
        //check with buy or rent options rntorbuy
        queryStringParameter = queryStringParameter + "&rntorbuy=" + buyOrRentParameter;
        //check with list or map options
        var redirectPageUrl = "properties-" + buyOrRentParameter + "-" + searchtext + "/list?" + queryStringParameter;
      
        searchIndicator.style.display = '';
        GetPlaceNameSearch(redirectPageUrl, "list", queryStringParameter);
        return false;
    } //end of validation if loop
    else
     {return false;
    }
}


//handling ajax request for placename search

/* This function is used to get the additional record of property according to page number and page size .*/
function GetPlaceNameSearch(redirectPageUrl, display, queryStringParameter) {
  
    var xmlHttp;
    var resultReturned;
    try {
        // Firefox, Opera 8.0+, Safari 
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer 
        try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e) {
            try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
            catch (e) { alert("Your browser does not support AJAX!"); return; }
        }
    }

    // Declare a ready state change event
    xmlHttp.onreadystatechange = function() {
        if ((xmlHttp.readyState == 4) && (xmlHttp.status == 200)) {
            resultReturned = xmlHttp.responseText;
            HandleRetrievedData(resultReturned, redirectPageUrl)
        }
    };
    xmlHttp.open("GET", "Default.aspx?" + queryStringParameter);
    xmlHttp.send(null);
}

/* This function handle the reterived data */
function HandleRetrievedData(result, redirectPageUrl) {

    var searchIndicator = document.getElementById('searchIndicator');
    // Parse if ajax returned data, otherwise stop calling it
    if (result == "same"){
        window.location.href = redirectPageUrl;
        return false;
        }
    else if (result != "" && result != "same") { 
        searchIndicator.style.display = 'none';      
        document.getElementById("regionsDiv").innerHTML = result;
        document.getElementById("searchPropertiesDiv").style.display = 'none';
        document.getElementById("placeNameSearchDiv").style.display = 'block';
        var innerdivHeight = document.getElementById("dtlistPlaceNameSearch").offsetHeight;
        if(innerdivHeight > 250){
            document.getElementById("regionsDiv").className = "ofscroll";}
        else{
            document.getElementById("regionsDiv").className = "ofhidden";}
        return false ;
    }
    else{
         window.location.href = redirectPageUrl+"&IsSame=1"; 
         return false;
     }
}

/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////Validate local info text box///////////////////////////////////

function ValidateLocalInfoTextBox() 
{

    var defaultSearchText="E.g. London or W6";
    var iChars = "!@#$%^&*()+=[]\\;,./{}|\":<>?";
    var searchTextBox = readValue("localinfoSearch", "ctrlPrefixForLocalInfo");
    var searchText = searchTextBox.value.replace(/(^\s*)|(\s*$)/g, "");
    var dvErrorDetail = document.getElementById("dvLocalInfoErrorDetails");
    var divLocationMsgtext = document.getElementById("divLocalInfoLocationMsg");

    if (searchText == '' || searchText == defaultSearchText){
        dvErrorDetail.style.display = 'block';
        dvErrorDetail.style.visibility = 'visible';
        divLocationMsgtext.innerHTML = "Enter location, areacode, postcode, county or city."
        searchTextBox.focus();
        return false;
    }

    //Check for special chars
    for (var i = 0; i < searchText.length; i++) {
        if (iChars.indexOf(searchText.charAt(i)) != -1) {
            dvErrorDetail.style.display = 'block';
            dvErrorDetail.style.visibility = 'visible';
            divLocationMsgtext.innerHTML = "Special characters are not allowed in the search"
            searchTextBox.focus();
            return false;
        }
    }
         searchText  = escape(searchText );
         var url = "localinformation-" + searchText +"/map?loc=" + searchText +"&rntorbuy=sale&search=3";
         url = url + "#schools=all&overlays=crime";
         window.location.href = url; 
         return false;
}     


function showSerachmodule(){
    document.getElementById("placeNameSearchDiv").style.display = 'none';
    document.getElementById("searchPropertiesDiv").style.display = 'block';
}

function hideLocalInfoErrorDiv(){
 document.getElementById('dvLocalInfoErrorDetails').style.display ='none';
}

function hidePropertyErrorDiv(){
 document.getElementById('dvErrorDetails').style.display ='none';
}﻿////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////Advertisemt(Used for dap.js (http://ads1.msn.com/library/dap.js)//
////////////////////////////////////////////////////////////////////////////////////////////////////


var _daprr = new Array('http://rad.msn.com/ADSAdClient31.dll?GetSAd=', 'http://a.rad.msn.com/ADSAdClient31.dll?GetSAd=', 'http://b.rad.msn.com/ADSAdClient31.dll?GetSAd='); var _daprs = 0; if (location.hostname.toLowerCase().indexOf('.live.com') != -1)
{ _daprr = new Array('http://rad.live.com/ADSAdClient31.dll?GetSAd=', 'http://a.rad.live.com/ADSAdClient31.dll?GetSAd=', 'http://b.rad.live.com/ADSAdClient31.dll?GetSAd='); }
var _daplp = 'http://ads1.msn.com/library'; var acbMinWdth = 160; var acbAdBarH = 22; var acbDwnLdSt = false; var DPJS_BSC = 0; var DPJS_ACB = 1; var DPJS_4TH = 2; var DPJS_ADV = 4; function dap(qs, fw, fh, ob) {
    var rs = _daprr[_daprs++]; if (_daprs >= _daprr.length) _daprs = 0; var dapIfs = ""; if (typeof (ob) != 'undefined') {
        ob = true; if (rs.length > 0)
        { rs += '&DPJS=' + (DPJS_BSC + DPJS_4TH); }
    }
    else {
        ob = false; if (rs.length > 0)
        { rs += '&DPJS=' + DPJS_BSC; }
    }
    if (_dapUtils.is_ie5up && _dapUtils.is_win && !ob)
    { dapIfs = 'dapIf' + (parseInt(parent.frames.length) + 1); document.write('<iframe id="' + dapIfs + '" src="about:blank" width="' + fw + '" height="' + fh + '" frameborder="0" scrolling="no"></iframe>'); document.frames[dapIfs].document.open("text/html", "replace"); document.frames[dapIfs].document.write('<html><head><title>Advertisement</title></head><body id="' + dapIfs + '" leftmargin="0" topmargin="0"><scr' + 'ipt type="text/javascript">var inDapIF=true;</scr' + 'ipt><scr' + 'ipt type="text/javascript" src="' + rs + qs + '" onreadystatechange="startTimer();"></scr' + 'ipt><scr' + 'ipt type="text/javascript">function startTimer(){if (event.srcElement.readyState == "complete") {window.setTimeout("document.close();", 2000);}}</scr' + 'ipt></body></html>'); }
    else
    { document.write('<scr' + 'ipt src="' + rs + qs + '" type="text/javascript" language="JavaScript"></scr' + 'ipt>'); }
}
function verifyDapResize(idx) {
    if (!adCont[idx].resizeCalled && adCont[idx].acbObj.enabled)
    { dap_Resize(adCont[idx].ifrmid, adCont[idx].w, adCont[idx].h); }
}
function dap_Resize(fid, fw, fh) {
    document.getElementById(fid).width = fw; document.getElementById(fid).height = fh; if (fw > 0 && fh > 0)
    { acbAdResize(fid, fw, fh); }
}
function dapOAF(qs, oa, fw, fh)
{ dap(qs, fw, fh); }
_dapUtilClass = function() {
    var ua = navigator.userAgent.toLowerCase(); var av = navigator.appVersion.toLowerCase(); this.minorVer = parseFloat(av); this.majorVer = parseInt(this.minorVer); this.is_opera = (ua.indexOf("opera") != -1); this.is_mac = (ua.indexOf("mac") != -1); this.is_ff = (ua.indexOf("firefox") != -1); var iePos = av.indexOf('msie'); if (iePos != -1) {
        if (this.is_mac)
        { var iePos = ua.indexOf('msie'); this.minorVer = parseFloat(ua.substring(iePos + 5, ua.indexOf(';', iePos))); }
        else
        { this.minorVer = parseFloat(av.substring(iePos + 5, av.indexOf(';', iePos))); }
        this.majorVer = parseInt(this.minorVer);
    }
    this.is_ie = ((iePos != -1) && (!this.is_opera)); this.is_ie3 = (this.is_ie && (this.majorVer < 4)); this.is_ie4 = (this.is_ie && this.majorVer == 4); this.is_ie4up = (this.is_ie && this.minorVer >= 4); this.is_ie5 = (this.is_ie && this.majorVer == 5); this.is_ie5up = (this.is_ie && this.minorVer >= 5); this.is_ie5_5 = (this.is_ie && (ua.indexOf("msie 5.5") != -1)); this.is_ie5_5up = (this.is_ie && this.minorVer >= 5.5); this.is_ie6 = (this.is_ie && this.majorVer == 6); this.is_ie6up = (this.is_ie && this.minorVer >= 6); this.is_webtv = (ua.indexOf("webtv") != -1); this.is_msn = (av.indexOf("msn") >= 0); this.is_win = ((ua.indexOf("win") != -1) || (ua.indexOf("16bit") != -1)); this.is_mac = (ua.indexOf("mac") != -1); if (this.is_mac) { this.is_win = !this.is_mac; }
    if (this.is_ff) {
        this.ffPos = ua.indexOf("firefox"); if (ua.length > this.ffPos + 8)
        { this.majorVer = parseInt(ua.substring(this.ffPos + 8)); }
        if (ua.length > this.ffPos + 10)
        { this.minorVer = parseInt(ua.substring(this.ffPos + 10)); }
        this.is_ff1_5up = (this.is_ff && ((this.majorVer >= 1 && this.minorVer >= 5) || (this.majorVer >= 2))); this.is_ff_closeIfrm = this.is_ff1_5up && this.majorVer < 3;
    }
    this.has_Flash = false; this.FlashVer = 0; this.detectFlash = function() {
        if (this.is_win && this.is_ie4up)
        { var dynaFrame = '<iframe id="flashDetect" src="about:blank" width="1" height="1" frameborder="0" scrolling="no" style="display:none;"></iframe>'; document.body.insertAdjacentHTML("afterBegin", dynaFrame); winObject = window["flashDetect"]; docObject = winObject.document; top.isFlashVersion = 0; top.isFlash = false; docObject.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); docObject.write('Dim hasPlayer, playerversion \n'); docObject.write('playerversion = 10 \n'); docObject.write('Do While playerversion > 0 \n'); docObject.write('On Error Resume Next \n'); docObject.write('hasPlayer = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & playerversion))) \n'); docObject.write('If hasPlayer = true Then Exit Do \n'); docObject.write('playerversion = playerversion - 1 \n'); docObject.write('Loop \n'); docObject.write('top.isFlashVersion = playerversion \n'); docObject.write('top.isFlash = hasPlayer \n'); docObject.write('</SCR' + 'IPT\>'); docObject.close(); this.has_Flash = top.isFlash; this.FlashVer = top.isFlashVersion; document.all["flashDetect"].removeNode(true); }
    }
    this.hasCookie = function(cookieName) {
        var bHasCookie = false, sCookie = document.cookie, aCookie = sCookie.split(";"); for (var i = 0; i < aCookie.length; i++) {
            while (aCookie[i].substr(0, 1) == ' ')
            { aCookie[i] = aCookie[i].substr(1); }
            if (aCookie[i].indexOf(cookieName + '=') == 0)
            { bHasCookie = true; break; }
        }
        return bHasCookie;
    }
    this.rendMode = function() {
        var m = document.compatMode; if (m) {
            if (m == "BackCompat")
            { return "Q"; }
            else if (m == "CSS1Compat")
            { return "S"; }
        }
        return "U";
    }
    this.getCurrentStyle = function(e) {
        if (window.getComputedStyle) {
            if (window.getComputedStyle(e, null))
            { return window.getComputedStyle(e, null); }
            else
            { return document.defaultView.getComputedStyle(e, null); }
        }
        else
        { return e.currentStyle; }
    }
    this.brLanguage = ""; if (this.is_ie5up)
    { this.brLanguage = navigator.browserLanguage; }
    else
    { this.brLanguage = navigator.language; }
    this.acbEvtH = false;
}
var _dapUtils = new _dapUtilClass(); var adCont = new Array(); var dapAd = new Object(); dapAd = function(qs, divid, fid, fw, fh, iA, adid, th, wc, acbO)
{ this.qs = qs; this.divid = divid; this.ifrmid = fid; this.w = fw; this.h = fh; this.isActive = iA; this.adid = adid; this.threshold = th; this.wc = wc; this.acbObj = acbO; this.documentClosed = false; this.resizeCalled = false; }
var AdControlBar = new Object(); AdControlBar = function(enabled)
{ this.enabled = enabled; this.shAcbLbl = false; this.fbFmShwn = false; this.fbSbmted = false; this.G = null; this.nS = null; this.pid = null; this.fn = null; this.mX = -1; this.xY = -1; this.noacb = false; this.lblCls = false; this.winCls = false; }
var eventType = new function()
{ this.click = 1; }; var eventPriority = new function()
{ this.special = 2; this.regular = 1; }; var dapMgr = new function() {
    this.threshold = eventType.click; this.MAX_AD_NUM = 100; this.dtRefresh = new Date().getTime(); this.REFESH_ELAPSE = 2000; this.MAX_ITR_FF = 5; this.TIME_EACH_ITR = 2000; this.renderAd = function(divid, qs, fw, fh) {
        var idx = this.getAdItemIndex(divid); if (idx > -1)
        { adCont[idx].qs = qs; adCont[idx].divid = divid; adCont[idx].w = fw; adCont[idx].h = fh; }
        else {
            if (adCont.length < this.MAX_AD_NUM) {
                var aO = new dapAd(qs, divid, 'dapIfM' + adCont.length, fw, fh, false, -1, this.threshold, 0, new AdControlBar(true)); if (_dapUtils.is_ie5)
                { adCont[adCont.length] = aO; }
                else
                { adCont.push(aO); }
            }
            else
            { return; }
            idx = adCont.length - 1;
        }
        this.displayAd(idx);
    }
    this.enableACB = function(divid, acb) {
        var idx = this.getAdItemIndex(divid); if (idx > -1)
        { adCont[idx].acb = acb; }
        else {
            if (adCont.length < this.MAX_AD_NUM) {
                var aO = new dapAd("", divid, 'dapIfM' + adCont.length, 0, 0, false, -1, this.threshold, 0, new AdControlBar(acb)); if (_dapUtils.is_ie5)
                { adCont[adCont.length] = aO; }
                else
                { adCont.push(aO); }
            }
        }
    }
    this.getAdItemIndex = function(divid) {
        var i; for (i = 0; i < adCont.length; i++) {
            if (adCont[i].divid == divid)
            { return i; }
        }
    }
    this.displayAd = function(idx) {
        var rs = _daprr[_daprs++]; if (_daprs >= _daprr.length)
        { _daprs = 0; }
        var elm = document.getElementById(adCont[idx].divid); if (!elm)
        { return; }
        if (!adCont[idx].qs || adCont[idx].qs.length == 0)
        { return; }
        if (adCont[idx].isActive)
        { return; }
        if (adCont[idx].acbObj != null && adCont[idx].acbObj.fbFmShwn)
        { return; }
        for (var i = (elm.childNodes.length - 1); i >= 0; i--) {
            var fChd = elm.childNodes[i]; if (_dapUtils.is_ff1_5up && (fChd.id == adCont[idx].ifrmid)) {
                if (fChd.contentDocument.body) {
                    while (fChd.contentDocument.body.firstChild)
                    { fChd.contentDocument.body.removeChild(fChd.contentDocument.body.firstChild); }
                }
                fChd.id = null; fChd.name = null; fChd.style.display = 'none'; fChd = null;
            }
            else {
                if (fChd.nodeName == "IFRAME" && !_dapUtils.is_ie5_5)
                { fChd.contentWindow.document.location.replace("about:blank"); }
                elm.removeChild(fChd); if (_dapUtils.is_ie5up)
                { fChd.removeNode(true); }
                else
                { fChd = null; }
            }
        }
        var elmCS = _dapUtils.getCurrentStyle(elm); if (elmCS) {
            var elmStyle = elmCS.display; if (elmStyle == "none" || elmStyle == "hidden")
            { return; }
        }
        if ((_dapUtils.is_ie5_5up || _dapUtils.is_ff1_5up) && _dapUtils.is_win) {
            var dapIfs = adCont[idx].ifrmid; var ifrm = document.createElement("IFRAME"); ifrm.id = dapIfs; ifrm.name = dapIfs; ifrm.src = "about:blank"; ifrm.width = adCont[idx].w; ifrm.height = adCont[idx].h; ifrm.scrolling = "no"; ifrm.frameBorder = "0"; ifrm.allowTransparency = true; elm.insertBefore(ifrm, elm.firstChild); if (rs.length > 0) {
                if (adCont[idx].acbObj.enabled)
                { rs += '&DPJS=' + (DPJS_ADV + DPJS_ACB); }
                else
                { rs += '&DPJS=' + DPJS_ADV; }
            }
            var str = this.getDapOutput(rs + adCont[idx].qs, dapIfs, idx); if (_dapUtils.is_ie5_5up)
            { ifrm.src = "javascript:void(document.write('" + str + "'));"; }
            else {
                ifrm.contentDocument.write(str); ifrm.contentDocument.onload = verifyDapResize(idx); if (_dapUtils.is_ff_closeIfrm)
                { window.setTimeout("checkIFrameClosed(" + idx + ",1)", this.TIME_EACH_ITR); }
                else
                { ifrm.contentDocument.close(); }
            }
            if (adCont[idx].acbObj.enabled)
            { initACB(adCont[idx].divid, idx); }
        }
        else {
            if (rs.length > 0)
            { rs += '&DPJS=' + DPJS_ADV; }
            var _dapdownlevel = true; if (parent.frames) {
                var dapIfs = adCont[idx].ifrmid; elm.innerHTML += '<iframe id="' + dapIfs + '" src="about:blank" width="' + adCont[idx].w + '" height="' + adCont[idx].h + '" frameborder="0" scrolling="no"></iframe>'; var doc; if (document.frames) {
                    if (document.frames[dapIfs])
                    { doc = document.frames[dapIfs].document; }
                }
                else {
                    if (document.getElementById(dapIfs))
                    { doc = document.getElementById(dapIfs).contentDocument; }
                }
                if (doc) {
                    _dapdownlevel = false; doc.open("text/html", "replace"); doc.write(this.getDapOutput(rs + adCont[idx].qs, dapIfs, idx)); if (_dapUtils.is_ff_closeIfrm)
                    { window.setTimeout("checkIFrameClosed(" + idx + ",1)", this.TIME_EACH_ITR); }
                    else if (!_dapUtils.is_ie)
                    { doc.close(); }
                }
            }
            if (_dapdownlevel)
            { document.write('<scr' + 'ipt src="' + rs + adCont[idx].qs + '" type="text/javascript" language="JavaScript"></scr' + 'ipt>'); adCont[idx].ifrmid = null; }
        }
    }
    this.getDapOutput = function(rs, dapIfs, idx) {
        var s = '<html><head><title>Advertisement</title></head><body id="' + dapIfs + '" leftmargin="0" topmargin="0" style="background-color:transparent"><scr' + 'ipt type="text/javascript">var inDapIF=true; var inDapMgrIf=true;'; if (document.domain && location.hostname != document.domain)
        { s += 'document.domain="' + document.domain + '";'; }
        if (_dapUtils.is_ff_closeIfrm)
        { s += 'var fnPtr=document.close;document.close=function(){parent.adCont[' + idx + '].documentClosed = true;document.close=fnPtr};'; }
        s += '</scr' + 'ipt><scr' + 'ipt type="text/javascript"  src="' + rs + '" onreadystatechange="startTimer();"></scr' + 'ipt><scr' + 'ipt type="text/javascript">function startTimer()' + '{if (event.srcElement.readyState == "complete") {parent.verifyDapResize(' + idx + ');window.setTimeout("document.close();", 2000);}}</scr' + 'ipt></body></html>'; return s;
    }
    this.trackEvent = function(evtType, evtPr) {
        var i; var isRef; if (!evtPr)
        { evtPr = eventPriority.regular; }
        for (i = 0, isRef = false; i < adCont.length; i++) {
            adCont[i].wc += (evtType * evtPr); var tElp = (new Date()).getTime() - this.dtRefresh; if ((adCont[i].wc >= adCont[i].threshold) && (tElp > this.REFESH_ELAPSE)) {
                adCont[i].wc = 0; if (adCont[i].threshold > -1 && adCont[i].ifrmid != null) {
                    this.displayAd(i); isRef = true; if (adCont[i].acbObj.enabled && adCont[i].acbObj.fbSbmted)
                    { adCont[i].acbObj.fbSbmted = false; }
                }
            }
        }
        if (isRef)
        { this.dtRefresh = (new Date()).getTime(); }
    }
}; function checkIFrameClosed(idx, iterations) {
    var ifrm = document.getElementById(adCont[idx].ifrmid); if (ifrm) {
        if (iterations >= dapMgr.MAX_ITR_FF && !adCont[idx].documentClosed)
        { ifrm.contentDocument.close(); }
        if (adCont[idx].documentClosed) {
            try
{ ifrm.contentDocument.close(); }
            catch (e) { }
        }
        else
        { window.setTimeout("checkIFrameClosed(" + idx + "," + (iterations + 1) + ")", dapMgr.TIME_EACH_ITR); }
    }
}
function acbAdResize(df, w, h) {
    for (var i = 0; i < adCont.length; i++) {
        if (adCont[i].ifrmid == df) {
            if (w < acbMinWdth) {
                adCont[i].acbObj.noacb = true; if (_dapUtils.acbEvtH)
                { _acb.removeACBLabel(i); }
            }
            else {
                if (_dapUtils.acbEvtH)
                { _acb.showACBLabel(i); }
            }
            adCont[i].w = w; adCont[i].h = h; var o = document.getElementById(adCont[i].divid); if (o) {
                o.style.width = w + "px"; if (_dapUtils.is_ff1_5up && _dapUtils.rendMode() == "S" && h > 1) {
                    var dh = h; if (!adCont[i].acbObj.noacb && adCont[i].acbObj.enabled)
                    { dh += acbAdBarH; }
                    o.style.height = dh + "px";
                }
            }
            var ol = document.getElementById("acbLblfrm" + i); if (ol)
            { ol.style.width = w + "px"; }
            adCont[i].resizeCalled = true; return;
        }
    }
}
function initACB(divid, Id) {
    if (!_dapUtils.acbEvtH) {
        if (!acbDwnLdSt)
        { acbDwnLdSt = true; var d = document.createElement("SCRIPT"); d.type = "text/javascript"; d.language = "javascript"; d.src = _daplp + "/ACB/acb.js"; document.body.insertBefore(d, document.body.firstChild); }
    }
    else
    { _acb.initACBLabel(Id); }
}
function ShowAcb(idStr, adId, W, H, G, nS, pid, fn) {
    var Id = acbGetIdFrmIdStr(idStr); if (Id > -1) {
        adCont[Id].adid = adId; adCont[Id].w = W; var acbO = adCont[Id].acbObj; acbO.shAcbLbl = true; acbO.fn = fn; acbO.G = G; acbO.nS = nS; acbO.pid = pid; if (_dapUtils.acbEvtH)
        { _acb.showACBLink(Id); }
        return;
    }
}
function acbGetIdFrmIdStr(s) {
    var id = s.substring(6, s.length); if (id >= 0)
    { return id; }
    else
    { return -1; }
}


///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////core.js//////////////////////////////////////////////////
Function.prototype.addMethod = function(a, b) { if (!this.prototype[a]) this.prototype[a] = b; return this };
Function.addMethod("as", function(e, f) {
  var b = e ? e.split(".") : []; if (b.length > 0)
  { var a = window; for (var d = 0; d < b.length - 1; ++d) { var c = b[d]; if (c) { if (!a[c]) a[c] = {}; a = a[c] } } a[b.last()] = f ? new this : this } return this
});
Function.addMethod("ns", function(a) { this.as(a, 1) }); String.addMethod("trim", function() { return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1") }); String.addMethod("collapse", function() { return this.replace(/\s+/g, " ").trim() }); String.addMethod("wrap", function(a) { var b, c = { "(": ")", "{": "}", "[": "]", "<": ">", "\u00c2\u00ab": "\u00c2\u00bb", "\u00e2\u20ac\u00b9": "\u00e2\u20ac\u00ba", "\u00e2\u20ac\u0153": "\u00e2\u20ac\u009d", "\u00e2\u20ac\u02dc": "\u00e2\u20ac\u2122" }; if (c[a]) b = c[a]; else { var d = /^<(\w+)(\s+\w+\s*=\s*"[^"]*")*\s*>$/.exec(a); if (d) b = "</" + d[1] + ">" } return a + this + (b ? b : a) }); String.addMethod("format", function() { var b = this; for (var a = 0; a < arguments.length; ++a) b = b.replace(new RegExp("\\{" + a + "\\}", "g"), arguments[a]); return b }); String.addMethod("encodeHtml", function() { var a = this.replace(/\>/g, "&gt;").replace(/\</g, "&lt;").replace(/\&/g, "&amp;").replace(/\'/g, "&#039;").replace(/\"/g, "&quot;"); return a }); String.addMethod("decodeHtml", function() { var a = this.replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&").replace(/&#039;/g, "'").replace(/&quot;/g, '"'); return a }); String.addMethod("encodeURIComponent", function() { return typeof encodeURIComponent != "undefined" ? encodeURIComponent(this) : escape(this) }); String.addMethod("decodeURIComponent", function() { return typeof decodeURIComponent != "undefined" ? decodeURIComponent(this) : unescape(this) }); Array.addMethod("last", function() { return this.length > 0 ? this[this.length - 1] : void 0 }); Array.addMethod("remove", function(b) { for (var a = this.length - 1; a >= 0; --a) if (this[a] === b) this.splice(a, 1); return this }); Array.addMethod("contains", function(b) { for (var a = 0; a < this.length; ++a) if (this[a] === b) return 1; return 0 }); Array.addMethod("push", function(a) { this[this.length] = a; return this.length }); Array.addMethod("shift", function() { return this.splice(0, 1)[0] }); Array.addMethod("splice", function(c, d) { var b, e = arguments.length - 2; if (c > this.length) c = this.length; if (c + d > this.length) d = this.length - c; var f = []; for (var a = 0; a < d; ++a) f.push(this[c + a]); if (e > d) { b = e - d; for (a = this.length + b - 1; a >= c + b; --a) this[a] = this[a - b] } else if (e < d) { b = d - e; for (a = c + e; a < this.length - b; ++a) this[a] = this[a + b]; for (; a < this.length - 1; ++a) delete this[a]; this.length -= b } for (a = 0; a < e; ++a) this[c + a] = arguments[2 + a]; return f }); (function() { var a = this; Function.addMethod("hook", function(d, e) { if (d) { var f = b(); if (!f && d.addEventListener) d.addEventListener(e, this, false); else if (!f && d.attachEvent) d.attachEvent("on" + e, this); else { var c = d["x" + e]; if (c && c.constructor == Array) if (c.contains(this)) c = null; else c.push(this); else c = d["x" + e] = [this]; if (c) { d["on" + e] = function(d) { var f = true; d = a.Event(d); for (var b = 0; b < c.length; ++b) { var e = c[b](d); if (typeof e != "undefined" && !e) f = false } return f }; d = null } } } return this }); Function.addMethod("unhook", function(a, c) { if (a) { var e = b(); if (!e && a.removeEventListener) a.removeEventListener(c, this, false); else if (!e && a.detachEvent) a.detachEvent("on" + c, this); else { var d = a["x" + c]; if (d && d.constructor == Array) d.remove(this); else a["on" + c] = null } } return this }); a.CancelEvent = function(b) { b = a.Event(b); if (b) { b.cancelBubble = true; if (b.stopPropagation) b.stopPropagation(); b.returnValue = false; if (b.preventDefault) b.preventDefault() } return false }; a.Event = function(a) { return a ? a : window.event }; a.Target = function(c) { c = a.Event(c); var b = c.target ? c.target : c.srcElement; if (b && b.nodeType != 1) b = a.ParentElem(b); return b }; a.InnerText = function(e) { var c = ""; for (var d = 0; d < e.childNodes.length; d++) { var b = e.childNodes[d]; if (b.nodeType == 1) c += a.InnerText(b); else if (b.nodeType == 3) c += b.data } return c }; a.NextElem = function(c, b) { var a = c.nextSibling; while (a && (a.nodeType != 1 || b && a.nodeName != b)) a = a.nextSibling; return a }; a.PrevElem = function(c, b) { var a = c.previousSibling; while (a && (a.nodeType != 1 || b && a.nodeName != b)) a = a.previousSibling; return a }; a.ParentElem = function(c, b) { var a = c.parentNode; while (a && (a.nodeType != 1 || b && a.nodeName != b)) a = a.parentNode; return a }; a.ChildElem = function(e, f, g) { var d = null, b; for (var c = 0; !d && c < e.childNodes.length; ++c) { b = e.childNodes[c]; if (b.nodeType == 1) if (!f || b.nodeName == f) d = b } if (!g) for (c = 0; !d && c < e.childNodes.length; ++c) { b = e.childNodes[c]; if (b.nodeType == 1) d = a.ChildElem(b, f) } return d }; a.ForEach = function(e, d, c) { for (var b = 0; b < d.childNodes.length; ++b) { var a = d.childNodes[b]; if (a.nodeType == 1 && (!c || a.nodeName == c)) if (e(a)) break } }; a.ChildCount = function(d, c) { var e = 0, a, b; for (a = 0; a < d.childNodes.length; ++a) { b = d.childNodes[a]; e += b.nodeType == 1 && (!c || b.nodeName == c) ? 1 : 0 } return e }; a.AddClass = function(a, e) { var c = a.className; if (c) { var g = c.collapse().split(" "), d = e.collapse().split(" "); for (var b = 0; b < d.length; ++b) { var f = d[b]; if (!g.contains(f)) a.className += " " + f } } else a.className = e; return a.className }; a.DelClass = function(b, g) { var a = b.className; if (a) { var f = a.collapse().split(" "), d = g.collapse().split(" "); for (var c = 0; c < d.length; ++c) f.remove(d[c]); var e = f.join(" "); if (e != a) b.className = e } return b.className }; a.HasClass = function(b, a) { return b.className.collapse().split(" ").contains(a) }; a.Updated = function() { if (a.Access && typeof a.Access.Updated == "function") a.Access.Updated() }; function b() { return navigator.userAgent.indexOf("Safari") >= 0 } }).ns("Msn.DOM"); (function() { var a = this, c = []; Function.addMethod("bind", function(b, h) { var d; switch (typeof b) { case "object": d = b.nodeType == 1 || b.nodeType == 9 ? [b] : b.length ? b : null; break; case "string": d = a.Select(b) } if (d) for (var g = 0; g < d.length; ++g) { var e = d[g], f = new this(e, h); if (e.bindings) e.bindings.push(f); else e.bindings = [f]; c.push(f) } return this }); a.Unbind = function(d, f) { var b; if (d.bindings && d.bindings.length) { for (b = 0; b < d.bindings.length; ++b) { var e = d.bindings[b]; if (e && typeof e.dispose == "function") e.dispose(); c.remove(e) } d.bindings = null } if (f) for (b = 0; b < d.childNodes.length; ++b) { var g = d.childNodes[b]; if (g.nodeType == 1) a.Unbind(g, f) } }; a.Select = function(c) { function i() { var d = null; if (c) if (c.charAt(a) == "*") d = "*"; else while (a < c.length) { var b = c.charAt(a); if ("a" <= b && b <= "z" || "A" <= b && b <= "Z" || "0" <= b && b <= "9" || b == "-") { d = d ? d + b : b; ++a } else break } return d } function j() { while (a < c.length && c.charAt(a) == " ") ++a } function m() { var b = null; j(); switch (c.charAt(a)) { case "+": case ">": b = c.charAt(a); ++a; j() } return b } function h() { ++a; return i() } function g() { var b = null, d = i(); if (d !== null) b = new e(d); while (c && a < c.length) { var f = c.charAt(a); if (f == "#") { if (!b) b = new e; b.setID(h()) } else if (f == ".") { if (!b) b = new e; b.addClass(h()) } else break } return b } function n() { var d = [], b = g(); if (b) { d.push(b); while (a < c.length) { var e = m(); b = g(); if (b) { if (e) b.setComb(e); d.push(b) } else break } } return d } function e(a) { var g = this, e = "", f = null, d = null; g.setID = function(a) { e = a }; g.setComb = function(a) { f = a }; g.addClass = function(a) { if (d) d.push(a); else d = [a] }; g.getNodes = function(i) { var d, g, j, k = []; if (e) { switch (f) { case ">": for (d = 0; d < i.childNodes.length; ++d) if (i.childNodes[d].nodeType == 1 && i.childNodes[d].id == e) { g = i.childNodes[d]; break } break; case "+": j = b(i); if (j && j.id == e) g = j; break; default: g = i.getElementById(e) } if (g && (!a || a == "*" || a.toLowerCase() == g.nodeName.toLowerCase()) && c(g)) k.push(g) } else if (a && a != "*") switch (f) { case ">": for (d = 0; d < i.childNodes.length; ++d) { g = i.childNodes[d]; if (g.nodeType == 1 && g.nodeName.toLowerCase() == a && c(g)) k.push(g) } break; case "+": j = b(i); if (j && j.nodeName.toLowerCase() == a && c(j)) k.push(j); break; default: var l = i.getElementsByTagName(a); for (d = 0; d < l.length; ++d) if (c(l[d])) k.push(l[d]) } else switch (f) { case ">": for (d = 0; d < i.childNodes.length; ++d) { g = i.childNodes[d]; if (g.nodeType == 1 && c(g)) k.push(g) } break; case "+": j = b(i); if (j && c(j)) k.push(j); break; default: h(i, k) } return k }; function h(d, e) { for (var b = 0; b < d.childNodes.length; ++b) { var a = d.childNodes[b]; if (a.nodeType == 1) { if (c(a)) e.push(a); h(a, e) } } } function c(f) { var a = 1; if (d) { var c = f.className; if (c) { var e = c.collapse().split(" "); for (var b = 0; b < d.length; ++b) if (!e.contains(d[b])) { a = 0; break } } else a = 0 } return a } } function l(c, d) { var a = []; for (var b = 0; b < c.length; ++b) a = a.concat(d.getNodes(c[b])); return a } var a = 0, k = n(), d = [document]; for (var f = 0; f < k.length && d.length > 0; ++f) d = l(d, k[f]); return d }; function b(b) { var a = b.nextSibling; while (a && a.nodeType != 1) a = a.nextSibling; return a } (function() { a.Unbind(document, 1); c = [] }).hook(window, "unload") }).ns("Msn.Bind"); (function(j, e) { if (!e) e = {}; var g = Msn.DOM, d = document, k = window, c = d.getElementById("more"); c.style.display = "none"; var f = d.getElementById("xnav"), b = d.createElement("li"), a = d.createElement("a"); a.href = "#"; a.className = "expand"; a.innerHTML = h(e.more, "more"); b.appendChild(a); f.appendChild(b); i.hook(a, "click"); function i(f) { var d = c.style.display, e; if (d == "block") { d = "none"; e = "expand"; b.className = "" } else { d = "block"; e = "collapse"; b.className = "last" } c.style.display = d; a.className = e; f = g.Event(f); return g.CancelEvent(f) } this.dispose = function() { j = null; c = null; f = null; b = null; a = null }; function h(a, b) { return typeof a != "undefined" ? a : b } }).as("Msn.Header"); (function(p, b) { if (!b) b = {}; var d = Msn.DOM, e = document, q = window, k = c(b.searchParam, ""), g = c(b.searchParams, ""), h = c(b.searchSite, ""), m = c(b.searchUrl, ""), n = c(b.searchWeb, ""); if (h !== "") { var j = e.getElementById("sitesearch"), a = e.createElement("input"); a.className = "button"; a.id = "site"; a.name = "site"; a.type = "submit"; a.value = h; j.appendChild(a); var l = e.getElementById("web"); l.value = n; f.hook(a, "click"); var i = e.getElementById("q"); o.hook(i, "keypress") } function o(a) { if (a.keyCode == 13) { f(null); a = d.Event(a); return d.CancelEvent(a) } } function f(a) { if (a !== null) if (d.Target(a).id != "site") return; var c = encodeURIComponent(e.getElementById("q").value), b = m + "?" + k + "=" + c; if (g) b = b + "&" + g.replace(/&amp;/g, "&"); window.top.location.href = b; a = d.Event(a); return d.CancelEvent(a) } this.dispose = function() { p = null }; function c(a, b) { return typeof a != "undefined" ? a : b } }).as("Msn.SiteSearch")


