﻿// global varibales used by PreloadAd & SetAdvar newImage;var newAdInd;var newAdAddress;var newAdCity;var newAdPrice;var newAdLink;var controlPrefix;function PreloadAd(adInd, idPrefix, imgSrc, link, address, city, price){    //preload new image    newImage = new Image();    newImage.src = imgSrc;    // save values in global varibales (used in SetAd)    newAdInd = adInd;    controlPrefix = idPrefix;        newAdLink = link;    newAdAddress = address;    newAdCity = city;    newAdPrice = price;    setTimeout("SetAd()",10);}function SetAd(){    //check to see if the loading of the image is complete    if (newImage && newImage.complete){        //show new listing's photo/ad        document.getElementById(controlPrefix + "ad" + newAdInd + "_img").src = newImage.src;        //show address of the new listing        document.getElementById(controlPrefix + "ad" + newAdInd + "_address").innerText = newAdAddress;        document.getElementById(controlPrefix + "ad" + newAdInd + "_city").innerText = newAdCity;        //show price        document.getElementById(controlPrefix + "ad" + newAdInd + "_price").innerText = newAdPrice;        //link to the full decription        document.getElementById(controlPrefix + "ad" + newAdInd + "_link").href = newAdLink;        document.getElementById(controlPrefix + "ad" + newAdInd + "_link_img").href = newAdLink;    } else {        //image is no loaded yet, retry later        setTimeout("SetAd()",10);    }}

function FindItFast(){
    var url = "/search/psResults.aspx?searchBy=AgentSiteFindItFast&showPreviewImg=1" +
        "&searchFor=" + escape(document.getElementById("searchFor").value) + 
        "&priceMin=" + escape(document.getElementById("priceMin").value) + 
        "&priceMax=" + escape(document.getElementById("priceMax").value) + 
        "&bedrooms=" + escape(document.getElementById("bedrooms").value) + 
        "&baths=" + escape(document.getElementById("baths").value)
    window.location = url;
}

function CallFindItFast(){
    if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)){
        // overwrite default Enter key form submit
        FindItFast();
        return false;
    } else {
        return true;
    }
}

function doQuickMap() {
    //this functon is DIFFERENT from the one on pattersonschwartz.com, as it has [&agtid=" + window.location.hostname] part at the end of URL
    var locDrop  = document.getElementById('dropLocations');
    var locValue = locDrop.options[locDrop.selectedIndex].value;
    if (locValue != "0,0,0") {
    locValue = locValue.split(",");
    qstr_loc = "goto=yes&gotoLoc=" + locValue[0] + "%2C" + locValue[1] + "%2C" + locValue[2] + "&";	
    var url = "http://patterson1.mapmuse.com/re1/map_patterson_re1.php?sp_theme=PATTERSON&" + qstr_loc + "noOfLayers=1&layer0=PATTERSON&searchMM01=" + document.getElementById('searchMM01').options[document.getElementById('searchMM01').selectedIndex].value  + "&searchMM101=" + document.getElementById('searchMM101').options[document.getElementById('searchMM101').selectedIndex].value + "&agtid=" + window.location.hostname;
    popWin(url,'MapSearch',1010,700,'toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
    }
}
