
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)
    {
        QSCache.Position = Position; // position of current listing after query.
        var UGen = new UrlGen(QSCache.QueryString);
        UGen.RemoveParam("No");
        UGen.AddParam("No",No);
        QSCache.QueryString = UGen.ToString();
        //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)
    {
        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?" + UGen.ToString();
                //alert(strURL);
                $AJAX.GetForDelegate(function(AjaxResponse)
                {
                    //alert(AjaxResponse);
                    window.location.href = 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);
   
}
