﻿// All Functions from _LR Master page

var oPostcodeMatch={
lastRequestId: 0,
displayElem: null,
match: function matchPostcode(postcode,useForDisplay)
 {
 //postcode: a complete or first characters of a postcode.
 //useForDisplay: a DOM element with an innerHTML property which is to be used to display match results.
    oPostcodeMatch.displayElem=useForDisplay;
if(postcode.length>=3)
    {
    //if the string has a numeric character in the first 3+ characters,
    //it may be a postcode.
    var hasNum=/[0-9]/;
    if(hasNum.test(postcode))
        {
        oPostcodeMatch.displayElem.innerHTML='<img src="images/glass.gif">';
        oPostcodeMatch.lastRequestId=oPostcodeMatch.lastRequestId+1;
        CountResultsService.ResultsForPostcode(postcode, oPostcodeMatch.lastRequestId, this.matchComplete);
        return true;
        }
     else
     //not a postcode. Search on location will probably take too long - do nothing.
       oPostcodeMatch.displayElem.innerHTML='';
       return true;
     }
else
  oPostcodeMatch.displayElem.innerHTML='';
  return true;
    
},

matchComplete: function matchComplete(result)
{
    if(parseInt(result[1])==oPostcodeMatch.lastRequestId)
    {
    if(result[1]>0)
        oPostcodeMatch.displayElem.innerHTML = " <br>" + result[2] + " matches<br>" + result[0] + "";
    else if(result[1]==-1)
    {
    //Houston, we have a problem
    oPostcodeMatch.displayElem.innerHTML = result[0];
    }
    else
       oPostcodeMatch.displayElem.innerHTML="";
    }
 }
 
 }


//hides the email alert option block
function hide() 
{
    document.getElementById('div1').style.display='none';
}
//Show the email alert option block
function show() 
{
    document.getElementById('div1').style.display='block';
}

function bookmarkUs()
{
    var ver = navigator.appName;
    var num = parseInt(navigator.appVersion);
    if ((ver == "Microsoft Internet Explorer")&&(num >= 4)) 
    {    
        window.external.AddFavorite('http://www.mypropertyspy.co.uk/?src=63327&cid=1448','My Property Spy');
    }
    else
    {
        alert('Press CTRL+D to bookmark us.');
    }
}

