
function MortgageCalc(num)
{
    //alert(num);
    window.location.href = WebRoot + "tools/calculators/mortgage-calculator.aspx?price=" + num;
}

function Listing(IdListing)
{
    var UGen = new UrlGen(QSCache.QueryString);
        UGen.RemoveParam("LID");
        UGen.AddParam("LID",IdListing);
        
        var strURL = WebRoot + "controls/ajaxcalls/DetailListingPath.aspx?" + UGen.ToString();
        //alert(strURL);
        //if (DetailSEOURL != '') strURL += '&DetailSEOURL=' + DetailSEOURL.toUpperCase(); 
        $AJAX.GetForDelegate(function(AjaxResponse)
        {
            //alert(AjaxResponse);
            window.location.href = AjaxResponse;
            
        }, strURL);
        
//        if (WebRoot != "/")
//        {
//            window.location.href = WebRoot + "detail.aspx?" + UGen.ToString();
//            return;
//        }
//        
//        var theTarget = String.format("/for_sale/listing/{1}", WebRoot, IdListing);

//        document.SEO.Query.value = UGen.ToString();
//        document.SEO.action = theTarget;
//        document.SEO.submit();
}

//================================================================
//  Function body now generated in XML, see code-in-front
//================================================================
//    function BackToResults()
//    {
//        var UGen = new UrlGen(QSCache.QueryString);
//        UGen.RemoveParam("LID");
//        UGen.RemoveParam("LIDS");
//        window.location.href = WebRoot + "Results_SEO.aspx?" + UGen.ToString();
//    }


    function ListingPage(No, Position)
    {
        // position of current listing after query.
        QSCache.Position = Position; 
        var UGen = new UrlGen(QSCache.QueryString);
        UGen.RemoveParam("No");
        UGen.AddParam("No",No);
        QSCache.QueryString = UGen.ToString();
        //alert('cache:' + QSCache.QueryString);
        //document.write(WebRoot + "Controls/AjaxCalls/DetailListingIds.aspx?" + QSCache.QueryString); 
        try
        {
            $AJAX.GetForDelegate(ListingPageHandler, WebRoot + "Controls/AjaxCalls/DetailListingIds.aspx?" + QSCache.QueryString);
        }
        catch (e) {
            alert('Ajax Error: ' + QSCache.QueryString);
        }
    }

    function ListingPageHandler(AJAXResponse)
    {
        //alert('listing page handler:' + AJAXResponse);
        if (AJAXResponse.length > 0)
        {
            var arrListingIds = AJAXResponse.split(',');
            var IdListing = arrListingIds[QSCache.Position];
            var UGen = new UrlGen(QSCache.QueryString);
            UGen.RemoveParams(["LIDS","LID"]);
            UGen.AddParam("LIDS",AJAXResponse.toUpperCase());
            UGen.AddParam("LID",IdListing);
         
           try
           {   
                var strURL = WebRoot + "controls/ajaxcalls/DetailListingPath.aspx?ispath=true&" + UGen.ToString();
               // alert(strURL);
                $AJAX.GetForDelegate(function(AjaxResponse)
                {
                  //  alert(AjaxResponse);
                    window.location.href = "/for_sale/" + AjaxResponse;
                }, strURL);
          }
          catch (e) 
          {
              alert('Ajax Error: ' + UGen.ToString());
          }
        }
    }

function LoadCommunityData(AddrZip)
{
   var strURL = WebRoot + "controls/ajaxcalls/GetCommunityData.aspx?AddrZip=" + AddrZip;
   $AJAX.GetForDelegate(function(AjaxResponse)
            {
                if(AjaxResponse != "")
                {
                gE("nabe_view").innerHTML = AjaxResponse;
                eval(gE("Dem_JS").innerHTML);
  window.setTimeout(function(){ eval(gE("Dem_JS_2").innerHTML); }, 200);
                }
                
            }, strURL);
   
}

function galleryModal(){

    //Fill array with images with 'modal' class
    var $singleImages = $('img.single-modal');

    //Max Height and Width Variable for images.
    var maxH = 480;
    var maxW = 640;
    
    //Loop through array and place modal function onclick of images in array.
    $singleImages.each(function(){
        
        //Event That intititates functionality
        $(this).click(function(){
        
            var imagePre = new Image();
            
            imagePre.onload = function(){
                //Resize if image is too large
                if(this.width > maxW || this.height > maxH){
                    if(this.width > this.height){
                        this.height = (this.height*maxW)/this.width;
                        this.width = maxW;
                    }else{
                        this.width = (this.width*maxH)/this.height;
                        this.height = maxH;
                    }
                }
                //Create Modal With New Source, Height, and Width
                $.modal("<div class='clearfix'><img height='"+this.height+"' width='"+this.width+"' src='"+this.src+"'/><div class='right' style='display:inline; margin-right:7px;'><a href='javascript:$.modal.close();'>Close</a></div></div>",{
                    overlayClose: true,
                    opacity:50,
                    overlayCss: { backgroundColor:"#000" },
                    dataCss: {textAlign:"center", paddingTop:"7px", backgroundColor:"#fff"},
                    minHeight: this.height+14,
                    minWidth: this.width+14,
                    onOpen: function (dialog) {
	                    dialog.overlay.fadeIn('fast', function () {
		                    dialog.container.slideDown('fast', function () {
			                    dialog.data.fadeIn('fast');
		                    });
	                    });
                    }
                });
            }
            
            /*-*-*-*-*-*-*-*-*-*--- LOAD SRC OF IMAGE ON PAGE INTO IMAGE OBJECT ---*-*-*-*-*-*-*-*-*-*/
            /*-*-*-*-*-*-*-*-*-*--- MUST HAPPEN AFTR ONLOAD SO BROWSER GIVES HW ---*-*-*-*-*-*-*-*-*-*/
            imagePre.src = this.src;
        });
        
    });

}

function GoToTabPage(URL)
{
  window.location.href = URL;
}

function showphone(type)
{
   if(gE(type + "phone"))
   {
      gE(type + "phone").style.display='block';
      gE("hide" + type + "phone").style.display='none';
   }
}


function SaveToProductCookie(CookieValue)
{
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + 1);
    document.cookie = "fdc_p=" + CookieValue + "; expires=" + exdate.toGMTString() + "; path=/";
}






























