function PageLoader() {
    void(null);
}
function GUnload() {
    void(null);
}
var PageCache = null;
try {
    document.execCommand("BackgroundImageCache", false, true);
} catch (err) {};
//if (window.location.href.indexOf('#') > -1) {
//    var SEOPath = window.location.href.substring(window.location.href.indexOf('#') + 1);
//    if (SEOPath.indexOf("/") > -1 && SEOPath.length > 3) {
//        window.location.href = "http://" + window.location.hostname + SEOPath;
//    }
//}
function trim(str) {
    if (str == null) {
        return "";
    }
    if (GetType(str) == "object") {
        return "";
    }
    return str.replace(/^\s*|\s*$/g, "");
}
function gE(objId) {
    if (document.getElementById(objId)) {
        return document.getElementById(objId);
    }
    return null;
}
function gEDisplay(objId, display) {
    gE(objId).style.display = display;
}
function ResizedPhoto(OriginalImageURL, IdListing, Width, Height, Quality) {
    return ImageProxyServerPath + "ImageReader.aspx?IDClient=102&IDListings=" + IdListing + "&H=" + Height + "&W=" + Width + "&ImageURL=" + OriginalImageURL;
}
//function ResizedPhotoPath(OriginalImageURL, Width, Height, NewImageFilename, NewImageDirectory, Quality) {
//    var BaseURL = "http://autoimages.gabriels.net/";
//    return String.format("{0}?q={1}&w={2}&mw={2}&h={3}&mh={3}&f={4}&s={5}&i={6}", BaseURL, Quality, Width, Height, escape(NewImageDirectory), escape(NewImageFilename), escape(OriginalImageURL));
//}
function DoReport(Data) {
    if (Data != "") {
        var URL = WebRoot + "Controls/AjaxCalls/DoReport.aspx?Data=" + Data;
        $AJAX.GetAsync(URL);
    }
}
function SetCookieState(CookieName, Key, Value) {
    var Query = String.format("CookieName={0}&Key={1}&Value={2}", CookieName, Key, Value);
    var URL = WebRoot + "Controls/AjaxCalls/SetCookieState.aspx?" + Query;
    $AJAX.GetAsync(URL);
}
var MousePosition = new Object();
MousePosition.X = 0;
MousePosition.Y = 0;

function captureMousePosition(e) {
    if (document.layers) {
        MousePosition.X = e.pageX + 25;
        MousePosition.Y = e.pageY - 25;
    } else if (document.all) {
        MousePosition.X = window.event.x + document.body.scrollLeft + 25;
        MousePosition.Y = window.event.y + document.body.scrollTop - 25;
    } else if (document.getElementById) {
        MousePosition.X = e.pageX + 25;
        MousePosition.Y = e.pageY - 25;
    }
}
function CaptureMouseXY() {
    if (document.layers) {
        document.captureEvents(Event.MOUSEMOVE);
        document.onmousemove = captureMousePosition;
    } else if (document.all) {
        document.onmousemove = captureMousePosition;
    } else if (document.getElementById) {
        document.onmousemove = captureMousePosition;
    }
}
function RecurseOffset(obj) {
    if (GetType(obj) == "string") {
        if (gE(obj) == null) {
            alert("RecurseOffset requires a valid DOM object");
        } else {
            obj = gE(obj);
        }
    }
    var ROO = new RecurseOffsetObject(obj);
    var Offsets = new Object();
    Offsets.offsetLeft = ROO.GetOffsetLeft();
    Offsets.offsetTop = ROO.GetOffsetTop();
    Offsets.offsetWidth = ROO.GetOffsetWidth();
    Offsets.offsetHeight = ROO.GetOffsetHeight();
    return Offsets;
}
function RecurseOffsetObject(obj) {
    this.ParentObj = null;
    this.CurrentObj = obj;
    this.offsetLeft = obj.offsetLeft;
    this.offsetTop = obj.offsetTop;
    this.offsetWidth = obj.offsetWidth;
    this.offsetHeight = obj.offsetHeight;
    RecurseOffsetObject.prototype.Init = function () {
        if (this.CurrentObj.offsetParent != null) {
            do {
                this.ParentObj = this.CurrentObj.offsetParent;
                this.offsetLeft += this.ParentObj.offsetLeft;
                this.offsetTop += this.ParentObj.offsetTop;
                this.CurrentObj = this.ParentObj;
            } while (this.CurrentObj.offsetParent != null);
        }
    };
    RecurseOffsetObject.prototype.GetOffsetLeft = function () {
        return this.offsetLeft;
    };
    RecurseOffsetObject.prototype.GetOffsetTop = function () {
        return this.offsetTop;
    };
    RecurseOffsetObject.prototype.GetOffsetWidth = function () {
        return this.offsetWidth;
    };
    RecurseOffsetObject.prototype.GetOffsetHeight = function () {
        return this.offsetHeight;
    };
    this.Init();
}
String.format = function () {
    if (arguments.length == 0) {
        throw ("String.format requires arguments");
    }
    var str = " " + arguments[0];
    for (var i = 1; i < arguments.length; i++) {
        var re = new RegExp('([^\\{]{1})(\\{' + (i - 1) + '\\}(?!\\}))', 'gm');
        str = str.replace(re, '\$1' + arguments[i]);
    }
    str = str.replace(new RegExp('\\{\\{', 'gm'), "{");
    str = str.replace(new RegExp('\\}\\}', 'gm'), "}");
    return str.substring(1);
};

function GetType(Element) {
    if (Element == null) {
        return "null";
    }
    if (Element.constructor == null) {
        return "object";
    } else {
        var Catches = Element.constructor.toString().toLowerCase().match(/([a-z0-9]+)(\(\))/i);
        if (Catches != null) {
            return Catches[1];
        } else {
            return "unknown";
        }
    }
}
function GetWindowBunds() {
    this.PageWidth = 0;
    this.PageHeight = 0;
    this.VisibleTop = 0;
    this.VisibleLeft = 0;
    this.VisibleWidth = 0;
    this.VisibleHeight = 0;
    this.isDefined = true;
    GetWindowBunds.prototype.Init = function () {
        if (window.innerHeight && window.scrollMaxY) {
            this.PageWidth = window.innerWidth + window.scrollMaxX;
            this.PageHeight = window.innerHeight + window.scrollMaxY;
        } else if (document.body.scrollHeight > document.body.offsetHeight) {
            this.PageWidth = document.body.scrollWidth;
            this.PageHeight = document.body.scrollHeight;
        } else {
            this.PageWidth = document.body.offsetWidth + document.body.offsetLeft;
            this.PageHeight = document.body.offsetHeight + document.body.offsetTop;
        }
        if (typeof(window.innerWidth) == 'number') {
            this.VisibleWidth = window.innerWidth;
            this.VisibleHeight = window.innerHeight;
        } else if (document.documentElement && document.documentElement.clientWidth) {
            this.VisibleWidth = document.documentElement.clientWidth;
            this.VisibleHeight = document.documentElement.clientHeight;
        } else if (document.body && document.body.clientWidth) {
            this.VisibleWidth = document.body.clientWidth;
            this.VisibleHeight = document.body.clientHeight;
        }
        if (!isNaN(window.pageYOffset)) {
            this.VisibleTop = window.pageYOffset;
            this.VisibleLeft = window.pageXOffset;
        } else if (document.body && (document.body.scrollTop || document.body.scrollLeft)) {
            this.VisibleTop = document.body.scrollTop;
            this.VisibleLeft = document.body.scrollLeft;
        } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
            this.VisibleTop = document.documentElement.scrollTop;
            this.VisibleLeft = document.documentElement.scrollLeft;
        } else {
            this.isDefined = false;
        }
        if (navigator.userAgent.indexOf('Safari') > -1) {
            this.VisibleHeight = window.innerHeight;
        }
    };
    this.Init();
}
function FormatNumber(NumberString) {
    NumberString += '';
    Parts = NumberString.split('.');
    Number1 = Parts[0];
    Number2 = Parts.length > 1 ? '.' + Parts[1] : '';
    var rgx = /(\d+)(\d{3})/;
    while (rgx.test(Number1)) {
        Number1 = Number1.replace(rgx, '$1' + ',' + '$2');
    }
    return Number1 + Number2;
}
function ImportJS(strFile, strTemplateName) {
    document.write('<scri' + 'pt language="javascript" type="text/javascript" src="http://www.househunting.ca/scripts/include.aspx?file=/themes/' + strTemplateName + '/' + strFile + '.inc"></scr' + 'ipt>');
}
function EmailAgentDir(IdAgentForeignKey, Agent, EmailLeadType) {
    if (EmailLeadType == '2' || EmailLeadType == '3') {
        tb_show('Email Agent', WebRoot + "Controls/AjaxCalls/EmailAgent.aspx?height=535&width=470&IdAgentForeignKey=" + IdAgentForeignKey + "&Agent=" + Agent + "&EmailLeadType=" + EmailLeadType, false);
    } else {
        tb_show('Email Agent', WebRoot + "Controls/AjaxCalls/EmailAgent.aspx?height=320&width=450&IdAgentForeignKey=" + IdAgentForeignKey + "&Agent=" + Agent + "&EmailLeadType=" + EmailLeadType, false);
    }
}
function EmailAgent(IdListing, Agent, EmailLeadType, Refer) {
    Refer = Refer.split('/')[0];
    if (EmailLeadType == '2' || EmailLeadType == '3') {
        tb_show('Email Agent', WebRoot + "Controls/AjaxCalls/EmailAgent.aspx?height=500&width=470&IdListing=" + IdListing + "&Agent=" + encodeURIComponent(Agent) + "&EmailLeadType=" + EmailLeadType + "&Refer=" + Refer + "&QueryString=LID%3D" + IdListing, false);
    } else {
        tb_show('Email Agent', WebRoot + "Controls/AjaxCalls/EmailAgent.aspx?height=500&width=470&IdListing=" + IdListing + "&Agent=" + encodeURIComponent(Agent) + "&EmailLeadType=" + EmailLeadType + "&Refer=" + Refer + "&QueryString=LID%3D" + IdListing, false);
    }
}
function EmailFriend(IdListing) {
    tb_show('Listing you are sharing:', WebRoot + "Controls/AjaxCalls/EmailFriend.aspx?height=320&width=450&IdListing=" + IdListing + "&PageFlag=L", false);
}
function SendEmail(emailstring) {
    if (emailstring.indexOf("emailto=agent") != -1) {
        tb_show('Success', WebRoot + "send_email_lead.aspx?" + emailstring.replace(/#/g, '%23') + "&height=540&width=750", false);
    } else {
        tb_show('Success', WebRoot + "send_email_lead.aspx?" + emailstring.replace(/#/g, '%23') + "&height=50&width=250", false);
    }
}
function ValidateEmailFriend(theForm) {
    if (theForm.flName.value == "") {
        alert("Please enter your name.");
        theForm.flName.focus();
        return (false);
    }
    if (theForm.EmailAddress.value == "") {
        alert("Please enter your email address.");
        theForm.EmailAddress.focus();
        return (false);
    }
    var addFlag = validEmailField(theForm.EmailAddress, "Please Enter valid E-mail address in the form: yourname@yourdomain.com");
    if (!addFlag) {
        return (false);
    }
    if (theForm.NameFriend.value == "") {
        alert("Please enter your Friend's name.");
        theForm.NameFriend.focus();
        return (false);
    }
    if (theForm.EmailFriendAddress.value == "") {
        alert("Please enter your Friend's email address.");
        theForm.EmailFriendAddress.focus();
        return (false);
    }
    var addrss = theForm.EmailFriendAddress.value;
    theForm.EmailFriendAddress.value = addrss.replace(";", ",");
    var faddFlag = validEmailFieldMultiple(theForm.EmailFriendAddress, ",", "Please Enter valid E-mail addresses in the form: yourname@yourdomain.com");
    if (!faddFlag) {
        return (false);
    }
    if (theForm.Message.value != "") {
        var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-@%:')(#_*&+!.$/ ,- ; <=^>\"\t\r\n\f~";
        var checkStr = theForm.Message.value;
        var allValid = true;
        var k = checkStr.length;
        var p = 0;
        for (i = 0; i < k; i++) {
            ch = checkStr.charAt(p);
            for (j = 0; j < checkOK.length; j++) {
                if (ch == checkOK.charAt(j)) {
                    p = p + 1;
                    break;
                }
                if (j == checkOK.length) {
                    checkStr = checkStr.substring(0, p) + checkStr.substring(p + 1);
                }
            }
        }
        theForm.Message.value = checkStr;
        if (!allValid) {
            alert("Please enter only letter, digit, whitespace and \"@%*$/:)(#_&-+!.;,<=^> \" characters in the \"Message\" field.");
            document.theForm.Message.focus();
            return (false);
        }
    }
    SendEmail("PageFlag=" + theForm.PageFlag.value + "&IdListing=" + theForm.IdListing.value + "&EmailAddress=" + theForm.EmailAddress.value + "&EmailFriendAddress=" + theForm.EmailFriendAddress.value + "&Message=" + theForm.Message.value + "&Name=" + theForm.flName.value + "&NameFriend=" + theForm.NameFriend.value + "&emailto=friend");
    OmPropertyActivity(this, 'send to friend');
    return (true);
}
function ValidateEmailAgent(theForm) {
    var EmailLeadType = theForm.EmailLeadType.value;
    var GUID = theForm.guid.value;
    if (theForm.FirstName.value == "") {
        alert("Please enter your first name.");
        theForm.FirstName.focus();
        return (false);
    }
    if (theForm.LastName.value == "") {
        alert("Please enter your last name.");
        theForm.LastName.focus();
        return (false);
    }
    if (theForm.EmailAddress.value == "") {
        alert("Please enter your email address.");
        theForm.EmailAddress.focus();
        return (false);
    }
    var addFlag = validEmailField(theForm.EmailAddress, "Please enter valid email address in the format: yourname@yourdomain.com", 1);
    if (!addFlag) return (false);
    if (EmailLeadType == "3" || EmailLeadType == "2") {
        addFlag = validateUSPhone(theForm.Phone, "Please enter valid phone number", 2);
        if (!addFlag) return (false);
    }
    if (EmailLeadType == "3") {
        if (theForm.Zip.value == "") {
            alert("Please enter your postal code.");
            theForm.Zip.focus();
            return (false);
        }
    }
    if (theForm.Message.value != "") {
        var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒ0123456789-@%:')(#_*&+!.$/ ,- ; <=^>\"\t\r\n\f~";
        var checkStr = theForm.Message.value;
        var allValid = true;
        var k = checkStr.length;
        var p = 0;
        for (i = 0; i < k; i++) {
            ch = checkStr.charAt(p);
            for (j = 0; j < checkOK.length; j++) {
                if (ch == checkOK.charAt(j)) {
                    p = p + 1;
                    break;
                }
                if (j == checkOK.length) {
                    checkStr = checkStr.substring(0, p) + checkStr.substring(p + 1);
                }
            }
        }
        theForm.Message.value = encodeURIComponent(checkStr);
        if (!allValid) {
            alert("Please enter only letter, digit, whitespace and \"@%*$/:)(#_&-+!.;,<=^> \" characters in the \"Message\" field.");
            document.theForm.Message.focus();
            return (false);
        }
    }
    var listingIds = theForm.LikeListings.value;
    var Listings_array = new Array();
    Listings_array = listingIds.split(",");
    var AgentIds = theForm.LikeListingsAgentforiegnkeys.value;
    var Agents_array = new Array();
    Agents_array = AgentIds.split(",");
    var noOfSimilarPropertyLeadSubmissions = 1;
    if (EmailLeadType == "2") {
        DoReport("EmailAgentForm-Submit-" + theForm.IdListing.value + "-" + GUID);
        var state = theForm.State.options[theForm.State.options.selectedIndex].value;
        if (state == "NotListed") {
            state = gE("statetext").value;
        }
        SendEmail("IdListing=" + theForm.IdListing.value + "&IdAgentForeignKey=" + theForm.IdAgentForeignKey.value + "&EmailAddress=" + theForm.EmailAddress.value + "&Phone=" + theForm.Phone.value + "&Extension=" + theForm.Extension.value + "&Message=" + theForm.Message.value + "&Move=" + theForm.Move.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&Country=" + theForm.Country.value + "&State=" + state + "&City=" + theForm.City.value + "&Street=" + theForm.Street.value + "&Zip=" + theForm.Zip.value + "&emailto=agent&guid=" + GUID + "&refer=" + theForm.refer.value + "&LikeListings=" + theForm.LikeListings.value + "&locationEndecaID=" + theForm.locationEndecaID.value);
        for (var index in Listings_array) {
            var id = Listings_array[index];
            var a_id = Agents_array[index];
            if (gE("checkbox_" + id) != null) {
                if (gE("checkbox_" + id).checked == 1) {
                    DoReport("EmailAgentForm-Submit-" + id + "-" + GUID);
                    SendEmail("IdListing=" + id + "&IdAgentForeignKey=" + a_id + "&EmailAddress=" + theForm.EmailAddress.value + "&Phone=" + theForm.Phone.value + "&Extension=" + theForm.Extension.value + "&Message=" + theForm.Message.value + "&Move=" + theForm.Move.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&Country=" + theForm.Country.value + "&State=" + state + "&City=" + theForm.City.value + "&Street=" + theForm.Street.value + "&Zip=" + theForm.Zip.value + "&emailto=agent&guid=" + GUID + "&refer=" + theForm.refer.value + "&LikeListings=" + theForm.LikeListings.value + "&locationEndecaID=" + theForm.locationEndecaID.value);
                    noOfSimilarPropertyLeadSubmissions++;
                }
            }
        }
    } else if (EmailLeadType == "3") {
        DoReport("EmailAgentForm-Submit-" + theForm.IdListing.value + "-" + GUID);
        SendEmail("IdListing=" + theForm.IdListing.value + "&IdAgentForeignKey=" + theForm.IdAgentForeignKey.value + "&EmailAddress=" + theForm.EmailAddress.value + "&Phone=" + theForm.Phone.value + "&Extension=" + theForm.Extension.value + "&Message=" + theForm.Message.value + "&Move=" + theForm.Move.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&State=" + theForm.State.value + "&City=" + theForm.City.value + "&Street=" + theForm.Street.value + "&Zip=" + theForm.Zip.value + "&emailto=agent&guid=" + GUID + "&refer=" + theForm.refer.value + "&LikeListings=" + theForm.LikeListings.value + "&locationEndecaID=" + theForm.locationEndecaID.value);
        for (var index in Listings_array) {
            var id = Listings_array[index];
            var a_id = Agents_array[index];
            if (gE("checkbox_" + id) != null) {
                if (gE("checkbox_" + id).checked == 1) {
                    DoReport("EmailAgentForm-Submit-" + id + "-" + GUID);
                    SendEmail("IdListing=" + id + "&IdAgentForeignKey=" + a_id + "&EmailAddress=" + theForm.EmailAddress.value + "&Phone=" + theForm.Phone.value + "&Extension=" + theForm.Extension.value + "&Message=" + theForm.Message.value + "&Move=" + theForm.Move.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&State=" + theForm.State.value + "&City=" + theForm.City.value + "&Street=" + theForm.Street.value + "&Zip=" + theForm.Zip.value + "&emailto=agent&guid=" + GUID + "&refer=" + theForm.refer.value + "&LikeListings=" + theForm.LikeListings.value + "&locationEndecaID=" + theForm.locationEndecaID.value);
                    noOfSimilarPropertyLeadSubmissions++;
                }
            }
        }
    } else {
        DoReport("EmailAgentForm-Submit-" + theForm.IdListing.value + "-" + GUID);
        SendEmail("IdListing=" + theForm.IdListing.value + "&IdAgentForeignKey=" + theForm.IdAgentForeignKey.value + "&EmailAddress=" + theForm.EmailAddress.value + "&Message=" + theForm.Message.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&emailto=agent&guid=" + GUID + "&refer=" + theForm.refer.value + "&LikeListings=" + theForm.LikeListings.value + "&locationEndecaID=" + theForm.locationEndecaID.value);
        for (var index in Listings_array) {
            var id = Listings_array[index];
            var a_id = Agents_array[index];
            if (gE("checkbox_" + id) != null) {
                if (gE("checkbox_" + id).checked == 1) {
                    DoReport("EmailAgentForm-Submit-" + id + "-" + GUID);
                    SendEmail("IdListing=" + id + "&IdAgentForeignKey=" + a_id + "&EmailAddress=" + theForm.EmailAddress.value + "&Message=" + theForm.Message.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&emailto=agent&guid=" + GUID + "&refer=" + theForm.refer.value + "&LikeListings=" + theForm.LikeListings.value + "&locationEndecaID=" + theForm.locationEndecaID.value);
                    noOfSimilarPropertyLeadSubmissions++;
                }
            }
        }
    }
    var SEOPath = window.location.href.substring(window.location.href.indexOf('#') + 1);
    if (noOfSimilarPropertyLeadSubmissions >= 1) s.eVar34 = noOfSimilarPropertyLeadSubmissions;
    if (this.QSCache != undefined && theForm.IdListing.value != "") {
        s.products = ";" + theForm.IdListing.value + ";;;;evar44=" + QSCache.codefeatured + "|evar41=" + QSCache.booknumber;
    } else if (theForm.IdListing.value != "" && theForm.omBookNumber.value != "" && theForm.omCodeFeatured.value != "") {
        s.products = ";" + theForm.IdListing.value + ";;;;evar44=" + theForm.omCodeFeatured.value + "|evar41=" + theForm.omBookNumber.value;
    }
    if (theForm.IdListing.value == "") {}
    OmSingleEventandEvar(this, 5, 'request info', 24, theForm.IdListing.value);
    return (true);
}
function ValidateSmallEmailAgent(theForm) {
    var EmailLeadType = theForm.EmailLeadType.value;
    var GUID = theForm.guid.value;
    var refer = theForm.refer.value.split('/')[0];
    if (theForm.EmailAddress.value == "") {
        alert("Please enter your email address.");
        theForm.EmailAddress.focus();
        return (false);
    }
    if (theForm.FirstName.value == "") {
        alert("Please enter your first name.");
        theForm.FirstName.focus();
        return (false);
    }
    if (theForm.LastName.value == "") {
        alert("Please enter your last name.");
        theForm.LastName.focus();
        return (false);
    }
    if (EmailLeadType == "3" && theForm.Zip.value == "") {
        alert("Please enter your zip.");
        theForm.Zip.focus();
        return (false);
    }
    var addFlag = validEmailField(theForm.EmailAddress, "Please enter valid email address in the format: yourname@yourdomain.com", undefined);
    if (!addFlag) return (false);
    var locationEndecaID = "";
    if (QSCache.endecaLocationId != null && QSCache.endecaLocationId != "") {
        locationEndecaID = QSCache.endecaLocationId;
    }
    var likeListings = "";
    if (QSCache.likeListings != null && QSCache.likeListings != "") {
        likeListings = QSCache.likeListings;
    }
    if (EmailLeadType == "2") {
        DoReport("EmailAgentForm-Submit-" + theForm.IdListing.value + "-" + GUID);
        SendEmail("IdListing=" + theForm.IdListing.value + "&IdAgentForeignKey=" + theForm.IdAgentForeignKey.value + "&EmailAddress=" + theForm.EmailAddress.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&emailto=agent&guid=" + GUID + "&refer=" + refer + "&locationEndecaID=" + locationEndecaID + "&LikeListings=" + likeListings);
    } else if (EmailLeadType == "3") {
        DoReport("EmailAgentForm-Submit-" + theForm.IdListing.value + "-" + GUID);
        SendEmail("IdListing=" + theForm.IdListing.value + "&IdAgentForeignKey=" + theForm.IdAgentForeignKey.value + "&EmailAddress=" + theForm.EmailAddress.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&Zip=" + theForm.Zip.value + "&emailto=agent&guid=" + GUID + "&refer=" + refer + "&locationEndecaID=" + locationEndecaID + "&LikeListings=" + likeListings);
    } else {
        DoReport("EmailAgentForm-Submit-" + theForm.IdListing.value + "-" + GUID);
        SendEmail("IdListing=" + theForm.IdListing.value + "&IdAgentForeignKey=" + theForm.IdAgentForeignKey.value + "&EmailAddress=" + theForm.EmailAddress.value + "&FirstName=" + theForm.FirstName.value + "&LastName=" + theForm.LastName.value + "&emailto=agent&guid=" + GUID + "&refer=" + refer + "&locationEndecaID=" + locationEndecaID + "&LikeListings=" + likeListings);
    }
    var SEOPath = window.location.href.substring(window.location.href.indexOf('#') + 1);
    s.eVar34 = "1";
    OmSingleEventandEvar(this, 5, 'request info', 24, theForm.IdListing.value);
    return (true);
}
function RestoreSelects() {
    if (!document.all) {
        return;
    }
    var SelectCollection = document.getElementsByTagName("select");
    for (var s = 0; s < SelectCollection.length; s++) {
        SelectCollection[s].style.visibility = "visible";
    }
}
function SweepSelects(TargetObject) {
    if (!document.all) {
        return;
    }
    var TRO = new RecurseOffset(TargetObject);
    var MatchLeft = TRO.offsetLeft;
    var MatchTop = TRO.offsetTop;
    var MatchRight = MatchLeft + TRO.offsetWidth;
    var MatchBottom = MatchTop + TRO.offsetHeight;
    var SelectCollection = document.getElementsByTagName("select");
    for (var s = 0; s < SelectCollection.length; s++) {
        var SelectObject = SelectCollection[s];
        var SRO = new RecurseOffset(SelectObject);
        var SelectLeft = SRO.offsetLeft;
        var SelectTop = SRO.offsetTop;
        var SelectRight = SelectLeft + SRO.offsetWidth;
        var SelectBottom = SelectTop + SRO.offsetHeight;
        if ((SelectRight > MatchLeft) && (SelectBottom > MatchTop) && (SelectLeft < MatchRight) && (SelectTop < MatchBottom)) {
            SelectObject.style.visibility = "hidden";
        }
        if ((SelectLeft == 0) && (SelectTop == 0)) {
            SelectObject.style.visibility = "hidden";
        }
    }
}
function UrlGen(strQueryString) {
    this.Parameters = new Array();
    UrlGen.prototype.Init = function (strQueryString) {
        with(this) {
            Parameters = new Array();
            var QueryString = strQueryString.replace(/&amp;/gi, '&');
            QueryString = QueryString.replace('%7c', '|');
            QueryString = unescape(QueryString);
            var _tempParams = QueryString.split('&');
            for (var i = 0; i < _tempParams.length; i++) {
                var _Param = _tempParams[i].split('=');
                Parameters.push(_Param);
            }
        }
    };
    UrlGen.prototype.RemoveParam = function (strKey) {
        with(this) {
            var _tempParams = new Array();
            for (var i = 0; i < Parameters.length; i++) {
                if (Parameters[i][0].toLowerCase() != strKey.toLowerCase()) {
                    _tempParams.push(Parameters[i]);
                }
            }
            Parameters = _tempParams;
        }
    };
    UrlGen.prototype.RemoveParams = function (arrParams) {
        with(this) {
            for (var p = 0; p < arrParams.length; p++) {
                RemoveParam(arrParams[p]);
            }
        }
    };
    UrlGen.prototype.AddParam = function (strKey, strValue) {
        with(this) {
            Parameters.push(new Array(strKey, strValue));
        }
    };
    UrlGen.prototype.GetParam = function (strKey) {
        with(this) {
            for (var i = 0; i < Parameters.length; i++) {
                if (Parameters[i][0].toLowerCase() == strKey.toLowerCase()) {
                    return Parameters[i][1];
                }
            }
            return "";
        }
    };
    UrlGen.prototype.AddNavFilter = function (strFilterName, strFilterValue) {
        with(this) {
            var NavFilters = new NavFilterCollection(GetParam("Nf"));
            NavFilters.AddFilter(strFilterName, strFilterValue);
            RemoveParam('Nf');
            AddParam('Nf', NavFilters.ToString());
        }
    };
    UrlGen.prototype.RemoveNavFilter = function (strNavFilterName) {
        with(this) {
            var NavFilters = new NavFilterCollection(GetParam("Nf"));
            NavFilters.RemoveFilter(strNavFilterName);
            RemoveParam('Nf');
            if (NavFilters.ToString() != '') {
                AddParam('Nf', NavFilters.ToString());
            }
        }
    };
    UrlGen.prototype.GetNavFilters = function (strNavFilterNamePattern) {
        with(this) {
            var NavFilters = new NavFilterCollection(GetParam("Nf"));
            return NavFilters.GetFilters(strNavFilterNamePattern);
        }
    };
    UrlGen.prototype.ToString = function () {
        with(this) {
            var _tempParams = new Array();
            for (var i = 0; i < Parameters.length; i++) {
                if (trim(Parameters[i][0]) != "") {
                    _tempParams.push(Parameters[i].join('='));
                }
            }
            return _tempParams.join('&');
        }
    };
    this.Init(strQueryString);
}
function NavFilterCollection(strNfValue) {
    this._QS = unescape(strNfValue);
    NavFilterCollection.prototype.RemoveFilter = function (strFilterName) {
        var arrFilters = this._QS.split('||');
        var newFilters = new Array();
        for (var x = 0; x < arrFilters.length; x++) {
            var ThisFilter = arrFilters[x].split('|');
            if (ThisFilter[0].toLowerCase() != strFilterName.toLowerCase()) {
                if (trim(arrFilters[x]) != '') {
                    newFilters.push(arrFilters[x]);
                }
            }
        }
        this._QS = newFilters.join('||');
    };
    NavFilterCollection.prototype.GetFilters = function (strFilterNamePattern) {
        var arrFilters = this._QS.split('||');
        if (strFilterNamePattern == undefined) {
            return arrFilters;
        } else {
            var MatchedFilters = new Array();
            for (var x = 0; x < arrFilters.length; x++) {
                var data = arrFilters[x].split('|');
                var myregexp = new RegExp(strFilterNamePattern, "gi");
                if (data[0].match(myregexp)) {
                    MatchedFilters.push(arrFilters[x]);
                }
            }
            return MatchedFilters;
        }
    };
    NavFilterCollection.prototype.AddFilter = function (strFilterName, strFilterValue) {
        var arrFilters = this._QS.split('||');
        var newFilters = new Array();
        for (var x = 0; x < arrFilters.length; x++) {
            if (trim(arrFilters[x]) != '') {
                var eles = arrFilters[x].split('|');
                if (trim(eles[0]).toLowerCase() != trim(strFilterName).toLowerCase()) {
                    newFilters.push(arrFilters[x]);
                }
            }
        }
        newFilters.push(String.format("{0}|{1}", strFilterName, strFilterValue));
        this._QS = newFilters.join('||');
    };
    NavFilterCollection.prototype.ToString = function () {
        return this._QS;
    };
}
function setAdTagsParameters() {
    document.globalPageSite = "DOOR";
    document.globalPageSctnName = adtag_globalPageSctnName;
    document.globalPageSctnId = adtag_globalPageSctnId;
    document.globalPageType = adtag_globalPageType;
    document.globalCategoryDspName = adtag_globalCategoryDspName;
    document.globalSctnDspName = adtag_globalSctnDspName;
    document.globalPageTitle = adtag_globalPageTitle;
    document.globalPageAbstract = adtag_globalPageAbstract;
    document.globalPageKeywords = adtag_globalPageKeywords;
    document.globalPageSponsorship = adtag_globalPageSponsorship;
    document.globalSctnLineage = adtag_globalSctnLineage;
    mdManager.addParameter("Url", adtag_url);
    mdManager.addParameter("Type", adtag_globalPageType);
    mdManager.addParameter("Role", "");
    mdManager.addParameter("Title", adtag_globalPageTitle);
    mdManager.addParameter("Sponsorship", adtag_globalPageSponsorship);
    mdManager.addParameter("Abstract", adtag_globalPageAbstract);
    mdManager.addParameter("Keywords", adtag_globalPageKeywords);
    mdManager.addParameter("Classification", adtag_globalSctnLineage);
    mdManager.addParameter("Site", "DOOR");
    mdManager.addParameter("SctnName", adtag_globalPageSctnName);
    mdManager.addParameter("SctnDspName", adtag_globalSctnDspName);
    mdManager.addParameter("CategoryDspName", adtag_globalCategoryDspName);
    mdManager.addParameter("SctnId", adtag_globalPageSctnId);
    mdManager.addParameter("DetailId", "");
    mdManager.addParameter("PageNumber", "1");
    mdManager.addParameter("UniqueId", adtag_globalUniqueId);
    mdManager.addParameter("Show_Abbr", "");
    mdManager.addParameter("SearchKeywords", "<% // FROM INITIAL SEARCH BOX %>");
    mdManager.addParameter("SearchFilters", "<% // FROM REFINEMENTS %>");
}
function SetDefault(CurrentValue, DefaultValue) {
    if (CurrentValue == undefined) {
        return DefaultValue;
    }
    return CurrentValue;
}
function MortgageCalThickBox(Address, CityState, IdWeb, Price) {
    tb_show('Calculate Mortgage', WebRoot + "Controls/AjaxCalls/MortgageCalculator.aspx?height=250&width=300&Address=" + Address + "&IdWeb=" + IdWeb + "&Price=" + Price + "&CityState=" + CityState, false);
}
function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g, '');
    if (isNaN(num)) num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num * 100 + 0.50000000001);
    cents = num % 100;
    num = Math.floor(num / 100).toString();
    if (cents < 10) cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3));
    return (((sign) ? '' : '-') + '$' + num);
}
function MortgageCalculate(theForm) {
    var price = parseInt(theForm.Price.value);
    var downPayment = theForm.DownPayment.value;
    if (!IsNumeric(downPayment) || theForm.DownPayment.value == "") {
        alert("Please enter numeric value in Down payment");
        theForm.DownPayment.focus();
        return (false);
    }
    var loanTerm = theForm.LoanTerm.value;
    if (!IsNumeric(loanTerm) || theForm.LoanTerm.value == "") {
        alert("Please enter numeric value in Loan Term");
        theForm.LoanTerm.focus();
        return (false);
    }
    loanTerm = parseFloat(theForm.LoanTerm.value) * 12;
    var Rate = theForm.IntersetRate.value;
    if (!IsNumeric(Rate) || theForm.IntersetRate.value == "") {
        alert("Please enter numeric value in Interset Rate");
        theForm.IntersetRate.focus();
        return (false);
    }
    Rate = (parseFloat(theForm.IntersetRate.value) / 100) / 12;
    var Principal = (price) - ((price * downPayment) / 100)
    var totalMonthlypayment = 0;
    totalMonthlypayment = (Rate + (Rate / (Math.pow(1 + Rate, loanTerm) - 1))) * Principal;
    theForm.MonthlyPayment.value = formatCurrency(Math.round(totalMonthlypayment));
}
function ResetValue(theForm) {
    var price = parseInt(theForm.Price.value);
    theForm.DownPayment.value = "20";
    theForm.LoanTerm.value = "30";
    theForm.IntersetRate.value = "6";
    var Rate = (parseInt(theForm.IntersetRate.value) / 100) / 12;
    var Principal = (price) - ((price * parseInt(theForm.DownPayment.value)) / 100)
    var totalMonthlypayment = 0;
    totalMonthlypayment = (Rate + (Rate / (Math.pow(1 + Rate, (parseInt(theForm.LoanTerm.value) * 12)) - 1))) * Principal;
    theForm.MonthlyPayment.value = formatCurrency(Math.round(totalMonthlypayment));
}
function RemoveHTML(textValue) {
    return textValue.replace(/(<([^>]+)>)/gi, "");
}
