function bindArguments(fn){var args=[];for(var n=1;n<arguments.length;n++){args.push(arguments[n]);}return function(){return fn.apply(this,args);};}function Event(){this.events=[];this.builtinEvts=[];}Event.prototype.getActionIdx=function(evt,action,binding){if(evt){var curel=this.events[evt];if(curel){var len=curel.length;for(var i=len-1;i>=0;i--){if(curel[i].action==action&&curel[i].binding==binding){return i;}}}else{return -1;}}return -1;};Event.prototype.addListener=function(evt,action,binding){if(this.events[evt]){if(this.getActionIdx(evt,action,binding)==-1){var curevt=this.events[evt];curevt[curevt.length]={action:action,binding:binding};}}else{this.events[evt]=[];this.events[evt][0]={action:action,binding:binding};}};Event.prototype.removeListener=function(evt,action,binding){if(this.events[evt]){this.events[evt]=[];}};Event.prototype.fireEvent=function(e,evt,args){if(!e){e=window.event;}if(this.events){var listeners=this.events[evt];if(listeners){for(var i in listeners){var action=listeners[i].action;if(listeners[i].binding){action.apply(listeners[i].binding,args);}else{action(e,args);}}}}return false;};var appEvents=new Event();HZIcon=function(){};HZIcon.DEFAULT_SEARCH_ICON=function(){return G_DEFAULT_ICON;};HZIcon._HOUSE_ICON=null;HZIcon.HOUSE_ICON=function(){if(HZIcon._HOUSE_ICON){return HZIcon._HOUSE_ICON;}HZIcon._HOUSE_ICON=new GIcon();HZIcon._HOUSE_ICON.image="/images/icons/addressIcon.png";HZIcon._HOUSE_ICON.iconSize=new GSize(22,35);HZIcon._HOUSE_ICON.shadowSize=new GSize(22,20);HZIcon._HOUSE_ICON.iconAnchor=new GPoint(6,20);HZIcon._HOUSE_ICON.infoWindowAnchor=new GPoint(5,1);return HZIcon._HOUSE_ICON;};HZIcon._FLICKR=null;HZIcon.FLICKR=function(){if(HZIcon._FLICKR){return HZIcon._FLICKR;}HZIcon._FLICKR=new GIcon();HZIcon._FLICKR.image="/images/digital_camera_icon.png";HZIcon._FLICKR.iconSize=new GSize(35,28);HZIcon._FLICKR.iconAnchor=new GPoint(17,28);HZIcon._FLICKR.infoWindowAnchor=new GPoint(16,1);return HZIcon._FLICKR;};HZIcon._ELEMENTARY_SCHOOL=null;HZIcon.ELEMENTARY_SCHOOL=function(){if(HZIcon._ELEMENTARY_SCHOOL){return HZIcon._ELEMENTARY_SCHOOL;}HZIcon._ELEMENTARY_SCHOOL=new GIcon();HZIcon._ELEMENTARY_SCHOOL.image="/images/icons/icon_elementary.png";HZIcon._ELEMENTARY_SCHOOL.iconSize=new GSize(22,35);HZIcon._ELEMENTARY_SCHOOL.iconAnchor=new GPoint(11,35);HZIcon._ELEMENTARY_SCHOOL.infoWindowAnchor=new GPoint(10,1);return HZIcon._ELEMENTARY_SCHOOL;};HZIcon._HIGH_SCHOOL=null;HZIcon.HIGH_SCHOOL=function(){if(HZIcon._HIGH_SCHOOL){return HZIcon._HIGH_SCHOOL;}HZIcon._HIGH_SCHOOL=new GIcon();HZIcon._HIGH_SCHOOL.image="/images/icons/icon_highschool.png";HZIcon._HIGH_SCHOOL.iconSize=new GSize(22,35);HZIcon._HIGH_SCHOOL.iconAnchor=new GPoint(11,35);HZIcon._HIGH_SCHOOL.infoWindowAnchor=new GPoint(10,1);return HZIcon._HIGH_SCHOOL;};HZIcon._SCHOOL=null;HZIcon.SCHOOL=function(){if(HZIcon._SCHOOL){return HZIcon._SCHOOL;}HZIcon._SCHOOL=new GIcon();HZIcon._SCHOOL.image="/images/icons/icon_school.png";HZIcon._SCHOOL.iconSize=new GSize(22,35);HZIcon._SCHOOL.iconAnchor=new GPoint(11,35);HZIcon._SCHOOL.infoWindowAnchor=new GPoint(10,1);return HZIcon._SCHOOL;};HZIcon._HOSPITAL=null;HZIcon.HOSPITAL=function(){if(HZIcon._HOSPITAL){return HZIcon._HOSPITAL;}HZIcon._HOSPITAL=new GIcon();HZIcon._HOSPITAL.image="/images/icons/icon_hospital.png";HZIcon._HOSPITAL.iconSize=new GSize(22,35);HZIcon._HOSPITAL.iconAnchor=new GPoint(12,40);HZIcon._HOSPITAL.infoWindowAnchor=new GPoint(10,1);return HZIcon._HOSPITAL;};HZIcon._RESTAURANT=null;HZIcon.RESTAURANT=function(){if(HZIcon._RESTAURANT){return HZIcon._RESTAURANT;}HZIcon._RESTAURANT=new GIcon();HZIcon._RESTAURANT.image="/images/icons/icon_restaurant.png";HZIcon._RESTAURANT.iconSize=new GSize(22,35);HZIcon._RESTAURANT.iconAnchor=new GPoint(12,40);HZIcon._RESTAURANT.infoWindowAnchor=new GPoint(10,1);return HZIcon._RESTAURANT;};HZIcon._PUB=null;HZIcon.PUB=function(){if(HZIcon._PUB){return HZIcon._PUB;}HZIcon._PUB=new GIcon();HZIcon._PUB.image="/images/icons/icon_bar.png";HZIcon._PUB.iconSize=new GSize(22,35);HZIcon._PUB.iconAnchor=new GPoint(12,40);HZIcon._PUB.infoWindowAnchor=new GPoint(10,1);return HZIcon._PUB;};HZIcon._COFFEE=null;HZIcon.COFFEE=function(){if(HZIcon._COFFEE){return HZIcon._COFFEE;}HZIcon._COFFEE=new GIcon();HZIcon._COFFEE.image="/images/icons/icon_coffee.png";HZIcon._COFFEE.iconSize=new GSize(22,35);HZIcon._COFFEE.iconAnchor=new GPoint(12,40);HZIcon._COFFEE.infoWindowAnchor=new GPoint(10,1);return HZIcon._COFFEE;};HZIcon._GRAVEYARD=null;HZIcon.GRAVEYARD=function(){if(HZIcon._GRAVEYARD){return HZIcon._GRAVEYARD;}HZIcon._GRAVEYARD=new GIcon();HZIcon._GRAVEYARD.image="/images/icons/icon_graveyard.png";HZIcon._GRAVEYARD.iconSize=new GSize(22,35);HZIcon._GRAVEYARD.iconAnchor=new GPoint(12,40);HZIcon._GRAVEYARD.infoWindowAnchor=new GPoint(10,1);return HZIcon._GRAVEYARD;};HZIcon._TIMMIES=null;HZIcon.TIMMIES=function(){if(HZIcon._TIMMIES){return HZIcon._TIMMIES;}HZIcon._TIMMIES=new GIcon();HZIcon._TIMMIES.image="/images/icons/icon_tims.png";HZIcon._TIMMIES.iconSize=new GSize(22,35);HZIcon._TIMMIES.iconAnchor=new GPoint(12,40);HZIcon._TIMMIES.infoWindowAnchor=new GPoint(10,1);return HZIcon._TIMMIES;};HZIcon._STARBUCKS=null;HZIcon.STARBUCKS=function(){if(HZIcon._STARBUCKS){return HZIcon._STARBUCKS;}HZIcon._STARBUCKS=new GIcon();HZIcon._STARBUCKS.image="/images/icons/icon_starbucks.png";HZIcon._STARBUCKS.iconSize=new GSize(22,35);HZIcon._STARBUCKS.iconAnchor=new GPoint(12,40);HZIcon._STARBUCKS.infoWindowAnchor=new GPoint(10,1);return HZIcon._STARBUCKS;};HZIcon._CREDITUNION=null;HZIcon.CREDITUNION=function(){if(HZIcon._CREDITUNION){return HZIcon._CREDITUNION;}HZIcon._CREDITUNION=new GIcon();HZIcon._CREDITUNION.image="/images/cu.gif";HZIcon._CREDITUNION.iconSize=new GSize(26,26);HZIcon._CREDITUNION.iconAnchor=new GPoint(13,26);HZIcon._CREDITUNION.infoWindowAnchor=new GPoint(13,1);if(HZIcon._CREDITUNION){return HZIcon._CREDITUNION;}};HZIcon._PARK=null;HZIcon.PARK=function(){if(HZIcon._PARK){return HZIcon._PARK;}HZIcon._PARK=new GIcon();HZIcon._PARK.image="/images/icons/icon_park.png";HZIcon._PARK.iconSize=new GSize(22,35);HZIcon._PARK.iconAnchor=new GPoint(13,26);HZIcon._PARK.infoWindowAnchor=new GPoint(13,1);return HZIcon._PARK;};HZIcon._TTC=null;HZIcon.TTC=function(){if(HZIcon._TTC){return HZIcon._TTC;}HZIcon._TTC=new GIcon();HZIcon._TTC.image="/images/icons/icons_ttc.png";HZIcon._TTC.iconSize=new GSize(22,35);HZIcon._TTC.iconAnchor=new GPoint(13,26);HZIcon._TTC.infoWindowAnchor=new GPoint(13,1);return HZIcon._TTC;};HZIcon._CHILD_CARE=null;HZIcon.CHILD_CARE=function(){if(HZIcon._CHILD_CARE){return HZIcon._CHILD_CARE;}HZIcon._CHILD_CARE=new GIcon();HZIcon._CHILD_CARE.image="/images/icons/childcare.png";HZIcon._CHILD_CARE.iconSize=new GSize(35,35);HZIcon._CHILD_CARE.iconAnchor=new GPoint(13,26);HZIcon._CHILD_CARE.infoWindowAnchor=new GPoint(13,1);return HZIcon._CHILD_CARE;};HZIcon._GROCERY_STORE=null;HZIcon.GROCERY_STORE=function(){if(HZIcon._GROCERY_STORE){return HZIcon._GROCERY_STORE;}HZIcon._GROCERY_STORE=new GIcon();HZIcon._GROCERY_STORE.image="/images/icons/grocery.png";HZIcon._GROCERY_STORE.iconSize=new GSize(35,35);HZIcon._GROCERY_STORE.iconAnchor=new GPoint(13,26);HZIcon._GROCERY_STORE.infoWindowAnchor=new GPoint(13,1);return HZIcon._GROCERY_STORE;};HZIcon._GO_TRAIN=null;HZIcon.GO_TRAIN=function(){if(HZIcon._GO_TRAIN){return HZIcon._GO_TRAIN;}HZIcon._GO_TRAIN=new GIcon();HZIcon._GO_TRAIN.image="/images/icons/go.png";HZIcon._GO_TRAIN.iconSize=new GSize(35,35);HZIcon._GO_TRAIN.iconAnchor=new GPoint(13,26);HZIcon._GO_TRAIN.infoWindowAnchor=new GPoint(13,1);return HZIcon._GO_TRAIN;};HZIcon._LCBO=null;HZIcon.LCBO=function(){if(HZIcon._LCBO){return HZIcon._LCBO;}HZIcon._LCBO=new GIcon();HZIcon._LCBO.image="/images/icons/lcbo.png";HZIcon._LCBO.iconSize=new GSize(23,35);HZIcon._LCBO.iconAnchor=new GPoint(10,33);HZIcon._LCBO.infoWindowAnchor=new GPoint(7,1);return HZIcon._LCBO;};HZIcon._LISTING=null;HZIcon.LISTING=function(){if(HZIcon._LISTING){return HZIcon._LISTING;}HZIcon._LISTING=new GIcon();HZIcon._LISTING.image="/images/icons/icon_listing.png";HZIcon._LISTING.iconSize=new GSize(23,35);HZIcon._LISTING.iconAnchor=new GPoint(10,33);HZIcon._LISTING.infoWindowAnchor=new GPoint(7,1);return HZIcon._LISTING;};HZIcon._LISTING2=null;HZIcon.LISTING2=function(){if(HZIcon._LISTING2){return HZIcon._LISTING2;}HZIcon._LISTING2=new GIcon();HZIcon._LISTING2.image="/images/icons/icon_listing2.png";HZIcon._LISTING2.iconSize=new GSize(28,43);HZIcon._LISTING2.iconAnchor=new GPoint(12,39);HZIcon._LISTING2.infoWindowAnchor=new GPoint(7,1);return HZIcon._LISTING2;};HZIcon._BANK=null;HZIcon.BANK=function(){if(HZIcon._BANK){return HZIcon._BANK;}HZIcon._BANK=new GIcon();HZIcon._BANK.image="/images/icons/icon_bank.png";HZIcon._BANK.iconSize=new GSize(23,35);HZIcon._BANK.iconAnchor=new GPoint(10,33);HZIcon._BANK.infoWindowAnchor=new GPoint(7,1);return HZIcon._BANK;};HZIcon._AGENT=null;HZIcon.AGENT=function(){if(HZIcon._AGENT){return HZIcon._AGENT;}HZIcon._AGENT=new GIcon();HZIcon._AGENT.image="/images/icons/real_estate_agent.png";HZIcon._AGENT.iconSize=new GSize(23,35);HZIcon._AGENT.iconAnchor=new GPoint(10,33);HZIcon._AGENT.infoWindowAnchor=new GPoint(7,1);return HZIcon._AGENT;};HZIcon._ZIPCAR=null;HZIcon.ZIPCAR=function(){if(HZIcon._ZIPCAR){return HZIcon._ZIPCAR;}HZIcon._ZIPCAR=new GIcon();HZIcon._ZIPCAR.image="/images/icons/icon_zipcars.png";HZIcon._ZIPCAR.iconSize=new GSize(20,34);HZIcon._ZIPCAR.iconAnchor=new GPoint(10,33);HZIcon._ZIPCAR.infoWindowAnchor=new GPoint(7,1);return HZIcon._ZIPCAR;};HZIcon._TWITTER_BLUE=null;HZIcon.TWITTER_BLUE=function(){if(HZIcon._TWITTER_BLUE){return HZIcon._TWITTER_BLUE;}HZIcon._TWITTER_BLUE=new GIcon();HZIcon._TWITTER_BLUE.image="/images/tweets/blue.png";HZIcon._TWITTER_BLUE.iconSize=new GSize(23,36);HZIcon._TWITTER_BLUE.iconAnchor=new GPoint(10,33);HZIcon._TWITTER_BLUE.infoWindowAnchor=new GPoint(7,1);return HZIcon._TWITTER_BLUE;};HZIcon._TWITTER_WHITE=null;HZIcon.TWITTER_WHITE=function(){if(HZIcon._TWITTER_WHITE){return HZIcon._TWITTER_WHITE;}HZIcon._TWITTER_WHITE=new GIcon();HZIcon._TWITTER_WHITE.image="/images/tweets/white.png";HZIcon._TWITTER_WHITE.iconSize=new GSize(23,36);HZIcon._TWITTER_WHITE.iconAnchor=new GPoint(10,33);HZIcon._TWITTER_WHITE.infoWindowAnchor=new GPoint(7,1);return HZIcon._TWITTER_WHITE;};HZIcon._BEER_STORE=null;HZIcon.BEER_STORE=function(){if(HZIcon._BEER_STORE){return HZIcon._BEER_STORE;}HZIcon._BEER_STORE=new GIcon();HZIcon._BEER_STORE.image="/images/icons/beerstore.png";HZIcon._BEER_STORE.iconSize=new GSize(35,35);HZIcon._BEER_STORE.iconAnchor=new GPoint(13,26);HZIcon._BEER_STORE.infoWindowAnchor=new GPoint(13,1);return HZIcon._BEER_STORE;};HZIcon.icons=[HZIcon.DEFAULT_SEARCH_ICON,HZIcon.HOSPITAL,HZIcon.RESTAURANT,HZIcon.PUB,HZIcon.ELEMENTARY_SCHOOL,HZIcon.HIGH_SCHOOL,HZIcon.COFFEE,HZIcon.GRAVEYARD,HZIcon.CREDITUNION,HZIcon.TIMMIES,HZIcon.STARBUCKS,HZIcon.SCHOOL,HZIcon.PARK,HZIcon.TTC,HZIcon.CHILD_CARE,HZIcon.GROCERY_STORE,HZIcon.GO_TRAIN,HZIcon.LCBO,HZIcon.LISTING,HZIcon.LISTING2,HZIcon.BANK,HZIcon.AGENT,HZIcon.ZIPCAR,HZIcon.TWITTER_BLUE,HZIcon.TWITTER_WHITE,HZIcon.BEER_STORE];HZIcon.getIcon=function(index){if(index<0||index>=HZIcon.icons.length){index=0;}return HZIcon.icons[index]();};function Hash(){this.length=0;this.items=new Array();for(var i=0;i<arguments.length;i+=2){if(typeof(arguments[i+1])!="undefined"){this.items[arguments[i]]=arguments[i+1];this.length++;}}this.removeItem=function(in_key){var tmp_value;if(typeof(this.items[in_key])!="undefined"){this.length--;var tmp_value=this.items[in_key];delete this.items[in_key];}return tmp_value;};this.getItem=function(in_key){return this.items[in_key];};this.setItem=function(in_key,in_value){if(typeof(in_value)!="undefined"){if(typeof(this.items[in_key])=="undefined"){this.length++;}this.items[in_key]=in_value;}return in_value;};this.hasItem=function(in_key){return typeof(this.items[in_key])!="undefined";};this.toString=function(){var s="[";for(var i in this.items){s+="["+i+",[Objectname]]";}s+="]";return s;};}HZAjax=function(url,func){this.url_=url;this.func_=func;this.LOADED=false;this.params=null;this.requestType="GET";this.xmlhttp=null;this.async=true;this.aborted=false;};HZAjax.prototype.setParams=function(s){this.params=s;};HZAjax.prototype.setRequestType=function(type){this.requestType=type;};HZAjax.prototype.send=function(){this.xmlhttp=null;if(window.XMLHttpRequest){this.xmlhttp=new XMLHttpRequest();}else{if(window.ActiveXObject){this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}}if(this.xmlhttp!=null){if(this.func_!=null){this.xmlhttp.onreadystatechange=this.func_;}this.xmlhttp.open(this.requestType,this.url_,this.async);if(this.params){this.xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");this.xmlhttp.setRequestHeader("Content-length",this.params.length);this.xmlhttp.setRequestHeader("Connection","close");}this.xmlhttp.send(this.params);}else{alert("Your browser does not support XMLHTTP.");}};HZAjax.prototype.abort=function(){this.xmlhttp.abort();};HZAjax.prototype.checkReadyState=function(){if(this.aborted){return false;}try{if(this.xmlhttp.readyState==4){if(this.xmlhttp.status==200){return true;}else{alert("Problem retrieving XML data: status->"+this.xmlhttp);}}}catch(e){}};var showSV;var doTrack=true;var host;var doGE,doVT;var ge;var cityParam="";var getParams;var mCompany;var DEFAULT_ZOOM_LEVEL=14;var appEvents=new Event();var federalDistrict=null;var federalPolygon=null;var showingFederal=false;var showingSatelliteMap;var inStreetView=false;var afterGoogleLoadFunc=null;var doNext=false;var idToCentre=-1;var tinyLinkString=null;var tinyLinkChanged=true;var isRobot;var shortLinkClicked=false;var loadGoogleCalled=false;var doInitialize=false;var loadGoogleLibCalled=false;var googleLibLoaded=false;var adAgentId;var autoSearching;var hasDescription;var pugSearch=false;var demoPolygon=null;var ctpoly=null;var electionDataAjax=null;var normalMapSize=true;var firstMove=true;var firstZoom=true;var NO_LEVEL=-1;var CANADA_LEVEL=0;var PROVINCE_LEVEL=1;var CITY_LEVEL=2;var POSTAL_LEVEL=3;var STREET_LEVEL=4;var HOUSE_LEVEL=5;var US_LEVEL=6;var HOOD_LEVEL=7;var kmlFiles=new Array();var getHoodAjax=null;var hzcustom1=null;var hzcustom2=null;var hzcustom3=null;var anonLogin;var schoolSearch;var pugSearch=null;var useBounds=true;var searchCount=null;var map;var startingSearches;var searchAfterShowTitle;var googleLoaded=false;var allSearchResults=new Hash();var prevSearchResults=new Hash();var currentSearchResultID=0;var searchTitle;var googleSearchResults;var customSearchResults;var currentCentre;var startingCentre;var startingCentreMarker=null;var resultsID;var currentSearchMarkers;var startingSW;var startingNE;var currentAddress=null;var MAX_RESULTS=5;var RESULTS_FIELDS_MAX=6;var MAX_LENGTH_RESULTS_TITLE=28;var MAX_LENGTH_ADDRESS=28;var userSearchesAjax;var searchPopup=null;var currentIcon=null;var currentProvince;var selectionIndex=0;var searching=0;var allMarkers=new Hash();var resultsFields=[];var ctDataShowing=false;var hoodDataShowing=false;var pullingCTData=false;var pullingHoodData=false;var pullCTDataAgain=false;var pullHoodDataAgain=false;var expandedMap;var printMode;searchKeys=new Hash();var subwayGeoKml=null;var transitGeoKml=null;var hoodGeoKml=null;var myPolyAssocativeOjbect=new Array();var panoClient;var myPano;function initialize(){jQueryCheckTree();myPolyAssocativeOjbect=new Array();for(var i=0;i<RESULTS_FIELDS_MAX;i++){resultsFields.push("");}$("#shortlink").click(shortLinkClick);$("ul.tree").checkTree({});var address=addressString;currentAddress=new Address(addressString);currentAddress.parseJsonResult(addressGeocodedJSON);if(currentAddress.LEVEL!=NO_LEVEL&&address!="Canada"){var checkbox=document.getElementById("search-Schools");checkbox.checked=true;if(startingSearches.length==0){$("#li-Schools").find(".arrow").click();$("#li-Schools").find(".checkbox:first").addClass("checked");}userSearchesAjax=new HZAjax("/phpHelpers/search/loadCustomSearch.php",customSearchTermResponse);userSearchesAjax.send();addHZSearches();if(!printMode){$("#hzfinder").css("display","block");}$("#content").css("display","block");initialAddress();updateSignInLink();getPointCTData();var staticmap=document.getElementById("staticmap");if(staticmap){staticmap.onclick=loadSchoolsAndGoogle;}var printThis=document.getElementById("printthis");printThis.onclick=printPage;if(showSV){$("#streetview").click(enableStreetView).show();}var mapTypeLI=document.getElementById("maptype");mapTypeLI.onclick=toggleMapType;if(showingSatelliteMap){mapTypeLI.className="standard";mapTypeLI.innerHTML="Regular";}if(currentAddress.LEVEL==HOOD_LEVEL){afterGoogleLoadFunc=showThisHoodData;}if(printMode&&startingSearches.length==0){startingSearches.push("Schools");}if(startingSearches.length>0||printMode){loadGoogle();googleLoaded=true;}else{if(currentAddress.LEVEL==HOOD_LEVEL){loadSchoolsAndGoogle();}}$("span#tipCloseButton").click(function(){$("#tipbar").css({"margin-bottom":"0px","padding":"0px"});animatedcollapse.hide("tipbar");});if((!hasFinderCookie())&&(!printMode)){$("#tipbar").show();}getNeighbourhoodInfo();setTimeout("isHomeForSale()",500);setTimeout("loadGoogleLib()",2000);}else{$("#overlay").show();}}function getNeighbourhoodInfo(){if(hasDescription){$.get("/phpHelpers/hoods/hoodDescriptionAjax.php",{hood:currentAddress.hood.name,city:currentAddress.hood.city},function(data){$("#writtenDescription").html(data);});$("#textMenu").click(function(){var currentState=$("#textMenu").html();if(currentState==="<strong>'Hood Details</strong>"){$("#writtenDescription").show();$("#map").hide();$("#textMenu").html("<strong>Map View</strong>");}else{$("#writtenDescription").hide();$("#map").show();$("#textMenu").html("<strong>'Hood Details</strong>");}});}}function shortLinkClick(){if(!shortLinkClicked){var link=document.getElementById("shortlink");link.focus();link.select();shortLinkClicked=true;}}function loadSchoolsAndGoogle(){doTrack=false;startingSearches.push("Schools");loadGoogle();}function loadGoogle(){if(isRobot){return;}if(loadGoogleCalled){return;}loadGoogleCalled=true;doInitialize=true;if(googleLibLoaded){initializeHZ();return;}if(!loadGoogleLibCalled){loadGoogleLib();}}function loadGoogleLib(){if(loadGoogleLibCalled){return;}loadGoogleLibCalled=true;google.load("maps","2",{callback:googleLibLoad});}function googleLibLoad(){googleLibLoaded=true;if(doInitialize){initializeHZ();}}function initializeHZ(){var address=addressString;initHZInfoWindow();$("#map").html("");if(GBrowserIsCompatible()){loadMap();}startingCentre=new GLatLng(currentAddress.lat,currentAddress.lng);currentCentre=startingCentre;initializePrototypes();googleLoaded=true;if(doVT){addVTMarker();}showAddress();doTrack=true;if(afterGoogleLoadFunc){afterGoogleLoadFunc();}}function initializePrototypes(){GPolyline.prototype.contains=function(point){var j=0;var oddNodes=false;var x=point.lng();var y=point.lat();var vCount=this.getVertexCount();for(var i=0;i<vCount;i++){j++;if(j==vCount){j=0;}var vilat=this.getVertex(i).lat();var vilng=this.getVertex(i).lng();var vjlat=this.getVertex(j).lat();if(((vilat<y)&&(vjlat>=y))||((vjlat<y)&&(vilat>=y))){if(vilng+(y-vilat)/(vjlat-vilat)*(this.getVertex(j).lng()-vilng)<x){oddNodes=!oddNodes;}}}return oddNodes;};GPolygon.prototype.contains=GPolyline.prototype.contains;GMap2.prototype.setToBounds=function(bounds){var center_lat=(bounds.getNorthEast().lat()+bounds.getSouthWest().lat())/2;var center_lng=(bounds.getNorthEast().lng()+bounds.getSouthWest().lng())/2;var center=new GLatLng(center_lat,center_lng);var zoom=this.getBoundsZoomLevel(bounds,this.getSize())+1;map1.setCenter(center,Math.min(zoom,14));};}function loadMap(){map=new GMap2(document.getElementById("map"));map.setCenter(new GLatLng(currentAddress.lat,currentAddress.lng),10);if(showingSatelliteMap){map.setMapType(G_HYBRID_MAP);}if(doGE){map.addMapType(G_SATELLITE_3D_MAP);map.addControl(new GHierarchicalMapTypeControl());}map.addControl(new GSmallMapControl());map.disableDoubleClickZoom();GEvent.addListener(map,"moveend",mapMoved);GEvent.addListener(map,"zoomend",function(oldLevel,newLevel){if(firstZoom){firstZoom=false;return;}if(polyMgr!=null){polyMgr.buildSlicesFromMapBounds();}track("zoom end",oldLevel,newLevel);});GEvent.addListener(map,"maptypechanged",function(){if(map.getCurrentMapType()==G_SATELLITE_3D_MAP){map.getEarthInstance(geCallBack);}});}function geCallBack(GE){ge=GE;setTimeout("delayedGECallBack()",2000);}function delayedGECallBack(){ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);kmlAvailable();}function mapClicked(){GLog.write("mapClicked()");}function mapMoved(){if(firstMove){firstMove=false;return;}if(ctDataShowing){enableCensusData();}if(hoodDataShowing){enableHoodData();}if(polyMgr!=null){polyMgr.buildSlicesFromMapBounds();}track("map moved","","");}function kmlAvailable(){if(currentAddress.accuracy!=8){return;}var params="cty="+currentAddress.city+"&prv="+currentAddress.province+"&adr="+currentAddress.street;kmlAjax=new HZAjax("/kml/kmlOfInterest.php?"+params,function(){if(kmlAjax.checkReadyState()){var jsonResults=eval("("+kmlAjax.xmlhttp.responseText+")");var html="";if(jsonResults.length>0){$("#kmlavailable").show();$("#kmllist").click(function(){showKMLFile(0);});}for(var i=0;i<jsonResults.length;i++){var url=jsonResults[i]["kml_file"];var name=jsonResults[i]["name"];html+="<span style='border-bottom: 1px solid #000'>Enable "+name+"</span>";kmlFiles.push(jsonResults[i]);}$("#kmllist").html(html);for(var i=0;i<jsonResults.length;i++){$("#kmllist"+i).click(showKML);}}});kmlAjax.send();}function showKMLFile(id){var url=kmlFiles[id]["kml_file"];google.earth.fetchKml(ge,"http://"+host+url,finishedKML);}function finishedKML(object){if(!object){setTimeout(function(){alert("Bad or null KML.");},0);return;}ge.getFeatures().appendChild(object);ge.getView().setAbstractView(object.getAbstractView());}function ctDemoPolygon(){var polygon=new GPolygon.fromEncoded({polylines:[{color:"#00FF00",weight:POLY_WEIGHT,opacity:POLY_OPACITY,points:ctpoly.encodedPoly,levels:"BB",zoomFactor:32,numLevels:4}],fill:true,color:"#ff0000",opacity:0,outline:true});polygon.setFillStyle({color:"#00FF00",opacity:0.25});map.addOverlay(polygon);GEvent.bind(polygon,"click",this,function(){var latLng=movePointToInsideMap(polygon.getBounds().getCenter());var innerHTML="<div style='width:200px;border-top:1px solid #494949'>Total # of Homes: <b>"+addCommas(ctpoly.dwellings)+"</b><br>Avg Home Value: <b>$"+addCommas(ctpoly.houseValue)+"</b><br>Median Income: <b>$"+addCommas(ctpoly.medianIncome)+"</div>";track("polygon_click","house_census",name);var hzInfoWindow=new HZInfoWindow(innerHTML,latLng,260);hzInfoWindow.doBubble=true;map.addOverlay(hzInfoWindow);});GEvent.bind(polygon,"mouseout",this,function(){if(HZInfoWindow.currentHZInfoWindow!=null){setTimeout("HZInfoWindow.removeCurrentHZInfoWindow(false)",1000);}});return polygon;}function updateSignInLink(){if(!anonLogin){return;}try{var signinLI=document.getElementById("signin");var signinLink=document.createElement("a");signinLink.setAttribute("href","/signin.php"+currentAddress.addressStringAsURL());signinLink.appendChild(document.createTextNode("Sign In"));signinLI.innerHTML="";signinLI.appendChild(signinLink);}catch(e){}}function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else{var expires="";}document.cookie=name+"="+value+expires+"; path=/";}function readCookie(name){var nameEQ=name+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length);}if(c.indexOf(nameEQ)==0){return c.substring(nameEQ.length,c.length);}}return null;}function hasFinderCookie(){hzSearchCookie=readCookie("hzsearch");if(hzSearchCookie==null){return false;}else{if(hzSearchCookie<3){return false;}return true;}}function eraseCookie(name){createCookie(name,"",-1);}function infoWindowClose(){HZInfoWindow.removeCurrentHZInfoWindow(true);}function showAddress(){reCentreMap();doInitialSearch();}function doInitialSearch(){if(startingSearches==null){autoSearching=false;return;}if(startingSearches.length==0){startingSearches=null;autoSearching=false;if(printMode){window.print();}return;}var title=startingSearches.pop();if(title!="Schools"){$("#li-"+spaceToDash(title)).find(".arrow").click();}searchATitle(title);}function reCentreMap(){if(!map){return;}var zl;if(currentAddress.LEVEL==CANADA_LEVEL||currentAddress.LEVEL==NO_LEVEL){zl=3;}else{zl=currentAddress.zoom;}map.setCenter(startingCentre,parseInt(zl));startingSW=map.getBounds().getSouthWest();startingNE=map.getBounds().getNorthEast();switch(currentAddress.LEVEL){case CITY_LEVEL:case POSTAL_LEVEL:case STREET_LEVEL:case HOUSE_LEVEL:if(!startingCentreMarker){startingCentreMarker=new GMarker(startingCentre,{icon:HZIcon.HOUSE_ICON()});map.addOverlay(startingCentreMarker);}break;case PROVINCE_LEVEL:break;case CANADA_LEVEL:case NO_LEVEL:break;case US_LEVEL:if(!startingCentreMarker){startingCentreMarker=new GMarker(startingCentre,{icon:HZIcon.HOUSE_ICON()});map.addOverlay(startingCentreMarker);}break;default:}HZInfoWindow.removeCurrentHZInfoWindow(true);}function initialAddress(){currentAddress.updateAddressString();if(addressString.length=="2"){currentAddress.addressString=addressString.toUpperCase();currentAddress.LEVEL=PROVINCE_LEVEL;currentAddress.province=addressString;return;}if(addressString.toLowerCase()=="canada"){addressString="Canada";}}function pageLink(){return"/search.php"+currentAddress.addressStringAsURL()+searchAsParams()+extraParams();}function extraParams(){if(getParams==null){return"";}var s="";for(var key in getParams){s+="&"+key+"="+getParams[key];}return s;}function tinyLinkPopup(){var linkString=pageLink();var longlink=document.getElementById("longlink");longlink.value="http://homezilla.ca"+linkString;getTinyURL(linkString,tinyLinkResponse);}function tinyLinkResponse(){if(tinyAjax.checkReadyState()){var popupDiv=document.getElementById("tinypopup");var json=eval("("+tinyAjax.xmlhttp.responseText+")");var longlink=document.getElementById("longlink");tinyLinkChanged=false;popupDiv.style.display="block";document.getElementById("shortlink").value="http://homezilla.ca"+json.tinyurl;longlink.focus();longlink.select();}}function searchAsParams(){var s="";var numSearches=0;for(var i=0;i<RESULTS_FIELDS_MAX;i++){if(resultsFields[i]!=""){var title=resultsFields[i];numSearches++;s+="&s"+numSearches+"="+title;if(title=="Mortgage Brokers"){s+="&mc="+mCompany;}}}return s.replace(/ /g,"+");}function addHZSearch(title,icon){var hzsearch;hzsearch=new HZSearch(title,icon,false);searchKeys.setItem(title,hzsearch);}function setNextSelection(){selectionIndex++;if(selectionIndex>RESULTS_FIELDS_MAX-1){selectionIndex=0;}}function resetNextSelection(){for(var i=RESULTS_FIELDS_MAX-1;i>=0;i-=1){selectionIndex=i;if(resultsFields[i]!=""){setNextSelection();i=-1;}}}function searchATitle(title){if(currentAddress.LEVEL<=PROVINCE_LEVEL){return;}if(searchKeys.hasItem(title)){var checkbox=document.getElementById("search-"+spaceToDash(title));checkbox.checked=true;$("#li-"+spaceToDash(title)).find(".checkbox:first").addClass("checked");localSearch(checkbox,title);}}function toggleTitle(title){if(currentAddress.LEVEL==PROVINCE_LEVEL){showErrorMsg("Search not available at province level");return;}if(searchKeys.hasItem(title)){var checkbox=document.getElementById("search-"+spaceToDash(title));if(checkbox.checked){checkbox.checked=false;$("#li-"+spaceToDash(title)).find(".checkbox:first").removeClass("checked");localSearch(checkbox,title);}else{searchATitle(title);}}}function localSearch(checkbox,title){if(currentAddress==null){checkbox.checked=false;alert("No address to search");return;}if(!googleLoaded){if(title!="Schools"){doTrack=false;startingSearches.push(title);startingSearches.push("Schools");}else{$("#category-results1").html("");}loadGoogle();return;}if(checkbox.checked){if(searching==1){if(startingSearches==null){startingSearches=new Array();startingSearches.push(title);}return 0;}if(currentAddress.LEVEL<=PROVINCE_LEVEL){checkbox.checked=false;showErrorMsg("Please enter an address before searching");return 0;}showKML(title);searching=1;setupForSearch(title);}else{if(searching==1){alert("Search already in progress... please let it finish first");checkbox.checked=true;return 0;}searching=1;hideKML(title);var hzsearch=searchKeys.getItem(title);hzsearch.removeSearch();hzsearch.currentCustomIndex=0;searching=0;}}function removeAllSearches(){for(var title in searchKeys.items){searchKeys.getItem(title).removeSearch();}}function redoSearches(){currentCentre=map.getCenter();startingSearches=new Array();var tmpSearches=new Array();for(var title in allMarkers.items){var hzsearch=searchKeys.getItem(title);hzsearch.currentCustomIndex=0;tmpSearches.push(title);}var title;while(title=tmpSearches.pop()){startingSearches.push(title);}title=startingSearches.pop();var checkbox=document.getElementById("search-"+spaceToDash(title));localSearch(checkbox,title);}function showKML(title){switch(title){case"Subway Transit":if(!subwayGeoKml){var lcCity=currentAddress.city.toLowerCase();if(lcCity=="toronto"){var urlString="http://www.homezilla.ca/kml/toronto_subway.kml";subwayGeoKml=new GGeoXml(urlString);}if(lcCity=="montreal"||lcCity=="montr�al"){var urlString="http://www.homezilla.ca/kml/montreal_subway.kml";subwayGeoKml=new GGeoXml(urlString);}}if(subwayGeoKml){map.addOverlay(subwayGeoKml);}break;case"Go Transit":if(!transitGeoKml){var lcCity=currentAddress.city.toLowerCase();if(lcCity=="toronto"||lcCity=="hamilton"){var urlString="http://www.homezilla.ca/kml/gotransit.kml";transitGeoKml=new GGeoXml(urlString);}}if(transitGeoKml){map.addOverlay(transitGeoKml);}break;case"Public Transit":case"SkyTrain":case"Suburban Rail":case"Rapid Bus":case"Ferry":if(!transitGeoKml){var lcCity=currentAddress.city.toLowerCase();if(lcCity=="vancouver"){var urlString="http://www.homezilla.ca/kml/vantransit.kml";transitGeoKml=new GGeoXml(urlString);}if(lcCity=="calgary"){var urlString="http://www.homezilla.ca/kml/calgarytransit.kml";transitGeoKml=new GGeoXml(urlString);}}if(transitGeoKml){map.addOverlay(transitGeoKml);}break;}}function hideKML(title){switch(title){case"Subway Transit":if(subwayGeoKml){map.removeOverlay(subwayGeoKml);}break;case"Go Transit":case"Public Transit":case"SkyTrain":case"Suburban Rail":case"Rapid Bus":case"Ferry":if(transitGeoKml){map.removeOverlay(transitGeoKml);}break;}}function previousSearch(title){var prevMarkers=prevSearchResults.getItem(title);var searchIndex=whichTableIndex(title);if(!prevMarkers){return;}searching=1;resultsString="category-results"+(searchIndex+1);searchTitle=title;var hzsearch=searchKeys.getItem(title);currentMarkers=allMarkers.getItem(title);for(var i=0;i<currentMarkers.length;i++){var sr=currentMarkers[i];if(sr.custom){hzsearch.currentCustomIndex--;}}removeMarkers(title);currentSearchMarkers=prevMarkers.pop();if(!currentSearchMarkers){return;}var max=currentSearchMarkers.length;if(max>MAX_RESULTS){max=MAX_RESULTS;}for(var i=0;i<max;i++){var sr=currentSearchMarkers[i];if(sr.custom){hzsearch.currentCustomIndex--;}}allMarkers.setItem(title,currentSearchMarkers);displayCurrentResults();searching=0;}function nextSearch(title){if(searching==1){alert("Search already in progress...");checkbox.checked=false;return 0;}if(!googleLoaded){doNext=true;loadSchoolsAndGoogle();return;}searching=1;var hzsearch=searchKeys.getItem(title);var currentCustomIndex=hzsearch.currentCustomIndex;var searchIndex=whichTableIndex(title);if(searchIndex<0){return;}resultsString="category-results"+(searchIndex+1);searchTitle=title;var prevMarkers=prevSearchResults.getItem(title);if(!prevMarkers){prevMarkers=new Array();prevSearchResults.setItem(title,prevMarkers);}prevMarkers.push(allMarkers.getItem(title));removeMarkers(title);currentIcon=hzsearch.icon();$("#"+resultsString).html("<h3>"+searchTitle+"</h3>Searching...");currentSearchMarkers=[];googleSearchResults=[];customSearchResults=[];customSearchRequest(true);}function customSearchRequest(isNextSearch){var params;var hzsearch=searchKeys.getItem(searchTitle);var currentCustomIndex=hzsearch.currentCustomIndex;var num=5;if(searchTitle=="Real Estate Agents"&&adAgentId>0){num=4;}params="lat="+currentCentre.lat()+"&lng="+currentCentre.lng()+"&city="+currentAddress.city+"&prov="+currentAddress.province+"&index="+currentCustomIndex+"&num="+num+"&track="+trackSearchID;if(searchTitle=="Schools"||searchTitle=="Elementary Schools"||searchTitle=="Jr High Schools"||searchTitle=="High Schools"){params=params+"&address="+currentAddress.street;}if(autoSearching){params+="&auto=";}if(searchTitle=="Mortgage Brokers"){params+="&company="+mCompany;}if(searchTitle=="Real Estate Agents"&&adAgentId>0){params+="&agentid="+adAgentId;}if(isNextSearch){params+="&next=yes";}if(!autoSearching&&searchTitle!="Schools"||doTrack){params+="&dotrack=yes";}if(currentAddress.LEVEL==US_LEVEL){mergeResults();return;}params+="&type="+searchTitle;customSearchAjax=new HZAjax("/phpHelpers/search/businessSearchAjax.php",customSearchResponse);customSearchAjax.setParams(params);customSearchAjax.setRequestType("POST");customSearchAjax.send();if(hzsearch.custom){track("custom finder",searchTitle.replace(/ /,"+"),"");}}function printPage(){track("print","","");window.open(pageLink()+"&print=1","","toolbar=no,scrollbars=yes,directories=no,copyhistory=no,menubar=no,location=no");}function customSearchResponse(){if(customSearchAjax.checkReadyState()){var jsonResults=eval("("+customSearchAjax.xmlhttp.responseText+")");for(var i=0;i<jsonResults.length;i++){var jsonResult=jsonResults[i];var business=new Business(jsonResult);business.searchTitle=searchTitle;customSearchResults.push(business);}mergeResults();}}function searchCountByCookie(){if(searchCount==null){searchCount=readCookie("hzsearch");if(searchCount!=null){searchCOunt=parseInt(searchCount);}else{searchCount=0;}}searchCount++;createCookie("hzsearch",searchCount,30);}function setupForSearch(title){var hzsearch=searchKeys.getItem(title);searchTitle=hzsearch.title_;tinyLinkChanged=true;currentIcon=hzsearch.icon();currentSearchMarkers=new Array();var i=0;resultsString="category-results"+(selectionIndex+1);resultsFields[selectionIndex]=searchTitle;setNextSelection();$("#"+resultsString).html("<h3>"+searchTitle+"</h3>Searching...").show();googleSearchResults=[];customSearchResults=[];customSearchRequest(false);searchCountByCookie();}function mergeResults(){currentSearchMarkers=customSearchResults;if(searchTitle!="Mortgage Brokers"){for(var i=0;i<currentSearchMarkers.length;i++){sr=currentSearchMarkers[i];sr.setDistance();}}allMarkers.setItem(searchTitle,currentSearchMarkers);displayCurrentResults();searching=0;if(doNext){nextSearch(searchTitle);doNext=false;}if(idToCentre>=0){setCentre(idToCentre+1);idToCentre=-1;}doInitialSearch();}function displaySuggestLink(){if(searchTitle=="Homes For Sale"){$("#suggest-link").html('See all NS homes for sale at <a href="/forSale/nova_scotia/">Nova Scotia Homes</a>').show();}}function displayCurrentResults(){var max=currentSearchMarkers.length;var hzsearch=searchKeys.getItem(searchTitle);var prevCustomIndex=hzsearch.currentCustomIndex;var lastDistance=0;currentIcon=hzsearch.icon();if(searching==0){return;}if(max>MAX_RESULTS){max=MAX_RESULTS;}var innerHTML="<h3>"+searchTitle+hzsearch.iconForTitle()+"</h3>"+"<UL>";for(var i=0;i<max;i++){if(searching==0){return;}sr=currentSearchMarkers[i];if(sr.custom){hzsearch.currentCustomIndex++;}lastDistance=sr.distance;sr.addToMap(currentIcon);innerHTML+=sr.listHTML();}if(max=="0"){innerHTML+="<li>No Results</li>";}if((searchTitle=="Parks"||searchTitle=="Child Care Services")&&currentAddress.city=="Toronto"){innerHTML+="<li class='dataSource'>Data provided by: <a href='http://toronto.ca/open/'>City of Toronto</a></li>";}innerHTML+="</ul>";if(prevCustomIndex!=hzsearch.currentCustomIndex){innerHTML+='<ul class="resultspager">';if(prevCustomIndex>0){innerHTML+="<li class='resultsprev'><a href=\"javascript:previousSearch('"+searchTitle+"');\">"+'<img src="/images/leftarrow.png" height="14" alt="Left arrow" />&nbsp;Previous</a></li>';}if(max==MAX_RESULTS){innerHTML+="<li class='resultsnext'><a href=\"javascript:nextSearch('"+searchTitle+"');\">More &nbsp;"+'<img src="/images/rightarrow.png" height="14" alt="right arrow" /></a></li></ul>';}else{innerHTML+="</ul>";}}else{if(hzsearch.currentCustomIndex==0){var numResults=currentSearchMarkers.length;var customFound=false;var i=max;while(customFound==false&&i<numResults){sr=currentSearchMarkers[i];if(sr.custom){customFound=true;}i++;}if(customFound){innerHTML+='<ul class="resultspager">';if(sr.distance<(lastDistance+2000)){innerHTML+="<li class='resultsnext'><a href=\"javascript:nextSearch('"+searchTitle+"');\">More &nbsp;"+'<img src="/images/rightarrow.png" height="14" alt="right arrow" /></a></li></ul>';}}}}$("#"+resultsString).html(innerHTML);displaySuggestLink();}function whichTableIndex(title){for(var i=0;i<RESULTS_FIELDS_MAX;i++){if(resultsFields[i]==title){return i;}}return -1;}function setCentre(id){if(!googleLoaded){idToCentre=id;loadSchoolsAndGoogle();return;}$("html, body").animate({scrollTop:0},"normal");var sr=Business.getSR(id);currentCentre=new GLatLng(sr.lat(),sr.lng());map.setCenter(currentCentre,map.getZoom());sr.infoWindow();}function removeSearchBoxes(title){for(var i=0;i<RESULTS_FIELDS_MAX;i++){if(resultsFields[i]==title){var resultsString;resultsString="category-results"+(i+1);var divResults=document.getElementById(resultsString);if(i==RESULTS_FIELDS_MAX-1){divResults.style.display="none";}else{for(j=i+1;j<RESULTS_FIELDS_MAX;j++){resultsFields[j-1]=resultsFields[j];resultsString="category-results"+(j+1);var nextResults=document.getElementById(resultsString);divResults.innerHTML=nextResults.innerHTML;if(resultsFields[j]==""){divResults.style.display="none";j=RESULTS_FIELDS_MAX;}divResults=nextResults;}}divResults.innerHTML="";resultsFields[RESULTS_FIELDS_MAX-1]="";$("#"+"category-results"+RESULTS_FIELDS_MAX).hide();resetNextSelection();}}}function showResponsePopup(title,message){$("#responseTitle").html(title);$("#responseMessage").html(message);showPopupForm("responsePopup",true);}function showErrorMsg(error){$("#msg").html(error).show();}function showError(error){$("#errormessage").html(error);showPopupForm("errorPopup",true);}function showPopupForm(divID,translucent){$("#"+divID).show();if(translucent){$("#blockUI").show();}}function showEmailForm(){showPopupForm("emailPopup",true);}function sortSRs(a,b){return a.distance-b.distance;}String.prototype.ucFirst=function(){return this.substr(0,1).toUpperCase()+this.substr(1,this.length);};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"");};function displaySaveNotification(){displayNotification("save");}function displayNotification(name){$("#"+name+"Popup").show();$("#blockUI").show();}function customSearchTermResponse(){if(userSearchesAjax.checkReadyState()){try{var jsonResults=eval("("+userSearchesAjax.xmlhttp.responseText+")");var customCountFromCookie=0;jsonResults=jsonResults["searches"];for(var i=0;i<jsonResults.length;i++){var jsonResult=jsonResults[i];var id=parseInt(jsonResult["id"]);var title=jsonResult["title"];var term=jsonResult["term"];var fromCookie=parseInt(jsonResult["fromCookie"]);if(searchKeys.getItem(title)==null){hzsearch=new HZSearch(title,0,true);hzsearch.customID=id;searchKeys.setItem(title,hzsearch);hzsearch.addSearchTerm(term);if(fromCookie==1){hzsearch.fromCookie=true;switch(id){case 1:hzcustom1=hzsearch;break;case 2:hzcustom2=hzsearch;break;case 3:hzcustom3=hzsearch;break;default:}customCountFromCookie++;if(hzcustom1!=null&&hzcustom2!=null&&hzcustom3!=null){$("#customsearch").hide();}}}}if(username==""&&customCountFromCookie>=3){$("#customsearch").hide();}if(jsonResults.length>=1){$("#customsearches").show();}}catch(e){}}}function addCustomSearch(){var term=$("#searchField").val();if(term==""){return;}$("#customsearches").show();$("#searchField").val("");if(searchKeys.hasItem(term)){alert("That search is already available to you");return;}var hzsearch=new HZSearch(term,0,true);if(username==""){if(hzcustom1==null){hzcustom1=hzsearch;hzsearch.customID=1;createCookie("hzcustom1",term,14);}else{if(hzcustom2==null){hzcustom2=hzsearch;hzsearch.customID=2;createCookie("hzcustom2",term,14);}else{if(hzcustom3==null){hzcustom3=hzsearch;hzsearch.customID=3;createCookie("hzcustom3",term,14);}}}if(hzcustom1!=null&&hzcustom2!=null&&hzcustom3!=null){$("#customsearch").show();}hzsearch.fromCookie=true;searchKeys.setItem(term,hzsearch);hzsearch.addSearchTerm(term);}else{var params="term="+term+"&title="+term;saveCustomAjax=new HZAjax("/phpHelpers/search/saveCustomSearch.php",saveCustomSearchResponse);saveCustomAjax.setParams(params);saveCustomAjax.setRequestType("POST");saveCustomAjax.send();searchKeys.setItem(term,hzsearch);hzsearch.addSearchTerm(term);}searchATitle(term);}function deleteCustomSearch(title){var hzsearch=searchKeys.getItem(title);if(hzsearch==null||!hzsearch.custom){return;}if(hzsearch.fromCookie){eraseCookie("hzcustom"+hzsearch.customID);}hzsearch.removeSearch();var lisearch=document.getElementById("li-"+spaceToDash(title));var htmlelement=document.getElementById("customsearches");htmlelement.removeChild(lisearch);searchKeys.removeItem(title);var deleteCustom=new HZAjax("/phpHelpers/search/deleteCustomSearch.php",null);var params="customid="+hzsearch.customID;deleteCustom.setParams(params);deleteCustom.setRequestType("POST");deleteCustom.send();$("#customsearch").show();}function spaceToDash(s){return s.replace(/ /g,"-");}function saveCustomSearchResponse(){if(saveCustomAjax.checkReadyState()){var jsonResults=eval("("+saveCustomAjax.xmlhttp.responseText+")");try{var title=jsonResults["title"];var id=jsonResults["id"];var hzsearch=searchKeys.getItem(title);hzsearch.customID=id;}catch(e){}}}function closePopup(divId){if(divId!=null){$("#"+divId).hide();$("#blockUI").hide();}}function removeMarkers(title){if(allMarkers.hasItem(title)){var markers=allMarkers.getItem(title);for(var i=0;i<markers.length;i++){markers[i].removeFromMap();}allMarkers.setItem(title,new Array());}}function replaceAll(strOrig,strTarget,strSubString){var intIndexOfMatch=strOrig.indexOf(strTarget);while(intIndexOfMatch!=-1){strOrig=strOrig.replace(strTarget,strSubString);intIndexOfMatch=strOrig.indexOf(strTarget);}return strOrig;}function shortUrlLink(url,length){var s='<a href="'+url+'">';if(url.length>length){s+=url.slice(0,parseInt(length/2));s+="...";s+=url.slice(url.length-parseInt(length/2)+3);}else{s+=url;}s+="</a>";return s;}function getValue(field){if(field&&field.value){return field.value;}return null;}function setValue(field,value){if(field){field.value=value;}}function getElem(handle){if(typeof(handle)=="string"){return document.getElementById(handle);}return handle;}function getHTML(handle){var elem=getElem(handle);if(elem){return elem.innerHTML;}return null;}function setHTML(handle,html){var elem=getElem(handle);if(elem){elem.innerHTML=html;return true;}return false;}function appendHTML(handle,html){var elem=getElem(handle);if(elem){elem.innerHTML+=html;return true;}return false;}function setStyle(handle,css){var elem=getElem(handle);if(elem&&typeof(css)=="string"){elem.style.cssText+=";"+css;}}Address=function(address){this.city=null;this.province=null;this.street=null;this.addressString=address.trim();this.LEVEL=NO_LEVEL;this.postal=null;this.notes=null;this.url=null;this.lat=null;this.lng=null;this.marker_=null;this.id=null;this.zoom=DEFAULT_ZOOM_LEVEL;this.hood=null;};Address.prototype.parseJsonResult=function(jsonResult){var err=false;if(jsonResult==""){this.LEVEL=NO_LEVEL;err=true;this.lat=57.98480801923985;this.lng=-92.21875;return;}var result=eval("("+jsonResult+")");var responseStatus=result["status"];this.accuracy=0;if(responseStatus=="pass"){var accuracy=parseInt(result["accuracy"]);this.zoom=parseInt(result["zoom"]);if(result["country"].match("CA")==null){this.LEVEL=NO_LEVEL;err=true;}else{this.accuracy=accuracy;switch(accuracy){case 0:this.LEVEL=NO_LEVEL;err=true;this.lat=57.98480801923985;this.lng=-92.21875;break;case 1:this.LEVEL=CANADA_LEVEL;this.lat=57.98480801923985;this.lng=-92.21875;err=true;break;case 2:this.LEVEL=PROVINCE_LEVEL;this.province=result["province"];break;case 3:this.LEVEL=PROVINCE_LEVEL;this.province=result["province"];break;case 4:this.LEVEL=CITY_LEVEL;this.city=result["city"];this.province=result["province"];this.street=result["street"];this.hood=result["neighbourhood"];break;case 5:this.LEVEL=POSTAL_LEVEL;this.city=result["city"];this.postal=result["postal"];this.province=result["province"];this.hood=result["neighbourhood"];break;case 6:case 7:case 8:this.LEVEL=HOUSE_LEVEL;this.city=result["city"];this.province=result["province"];this.street=result["street"];this.hood=result["neighbourhood"];break;case 9:this.LEVEL=HOOD_LEVEL;this.city=result["city"];this.province=result["province"];this.hood=result["neighbourhood"];break;}}if(this.LEVEL!=NO_LEVEL&&this.LEVEL!=CANADA_LEVEL){this.province=this.province.toUpperCase();this.lat=result["lat"];this.lng=result["lng"];}}else{this.LEVEL=NO_LEVEL;err=true;this.lat=57.98480801923985;this.lng=-92.21875;}if(err){$("#searchtextfield").val(addressString);$("#overlay").show();$("#gosearch").addClass("errsearch").fadeIn("slow");$("#hzfinder").hide();$("#content").hide();}};Address.prototype.updateAddressString=function(){var s="";if(this.LEVEL==POSTAL_LEVEL){s=this.postal+", "+this.city+", "+this.province;}else{if(this.street){s+=this.street;}if(this.city){if(this.street){s+=", ";}s+=this.city;}if(this.province){if(this.city){s+=", ";}s+=this.province;}}this.addressString=s.trim();};Address.prototype.addressStringAsURL=function(){var s;if(this.LEVEL==POSTAL_LEVEL){s="?pos="+this.postal;}else{s="?adr="+(this.street?this.street.trim():"")+"&prv="+(this.province?this.province:"")+"&cty="+(this.city?this.city.trim():"");}return s.trim().replace(/ /g,"_");};Address.prototype.getStreetAddress=function(){if(this.LEVEL==US_LEVEL){return this.addressString;}if(this.street){return this.street;}if(this.LEVEL==POSTAL_LEVEL){this.street=this.addressString;return this.street;}var s=this.addressString.toLowerCase();var city=this.city.toLowerCase();var province=this.province.toLowerCase();s=s.replace(city,"");s=s.replace(/ ca$/,"").trim();s=s.replace(/,/g,"");s=s.replace(/\w+/g,function(a){if(a==province){return"";}return a;});s=s.replace(/\w+/g,function(a){return a.charAt(0).toUpperCase()+a.substr(1).toLowerCase();});this.street=s.trim();return this.street;};Address.prototype.getParamString=function(){if(this.LEVEL==US_LEVEL){return"addr="+this.addressString;}if(this.postal&&this.postal.length==0){this.postal=null;}if(this.url&&this.url.length==0){this.url=null;}if(this.notes&&this.notes.length==0){this.notes=null;}return"adr="+this.getStreetAddress()+"&city="+this.city+"&prov="+this.province+"&postal="+this.postal+"&lat="+this.lat+"&lng="+this.lng+"&homeid="+this.id+"&notes="+this.notes;+"&url="+this.url;};Address.prototype.getSearchLink=function(){s="/search.php?prv="+this.province;if(this.street){s+="&adr="+this.street;}if(this.city){s+="&cty="+this.city;}s=s.replace(/ /g,"_");return s;};Address.prototype.html=function(){return"<b>"+this.addressString+"</b>";};Address.prototype.getFullAddress=function(){var s="";switch(this.LEVEL){case HOUSE_LEVEL:case STREET_LEVEL:s+=this.street+", ";break;case POSTAL_LEVEL:s+=this.postal+", ";break;case HOOD_LEVEL:s+=this.hood+", ";break;}s+=this.city+", "+this.province;return s;};Address.prototype.toString=function(){var s="[ "+this.LEVEL+", "+this.street+", "+this.city+", "+this.province+", "+this.postal+", "+this.url+", "+this.lat+", "+this.lng+" ]";return s;};function HZSearch(title,iconIndex,isCustom){this.title_=title;this.iconIndex=iconIndex;this._icon=null;this.currentCustomIndex=0;this.custom=isCustom;this.customID="0";this.parentHZSearch=null;this.fromCookie=false;if(isCustom){this.createDiv();}}HZSearch.prototype.icon=function(){if(this._icon==null){this._icon=HZIcon.getIcon(this.iconIndex);}return this._icon;};HZSearch.prototype.iconForTitle=function(){if(this.iconIndex==0||this._icon==null){return"";}return"<span class='finderIcon'><img alt='"+this.title_+" near "+currentAddress.getFullAddress()+"' src='"+this._icon.image+"'/></span>";};HZSearch.prototype.innerHTML=function(){var s='<li id="li-'+spaceToDash(this.title_)+'"><input type="checkbox" value="'+this.title_+'" id="search-'+spaceToDash(this.title_)+'"'+" onclick='localSearch(this, \""+this.title_+"\");'/>"+'<label for="'+this.title_+'"><a href="javascript:toggleTitle('+"'"+this.title_+"');"+'">'+this.title_+"</a></label>";if(this.custom){s+="<a href='javascript:deleteCustomSearch(\""+this.title_+"\");' title='Delete'>&nbsp;<img src='/images/delete_x.png'></a>";}s+="</li>";return s;};HZSearch.prototype.createDiv=function(){var htmlelement;if(this.custom){$("#customsearches").append(this.innerHTML);}};HZSearch.prototype.removeSearch=function(){if(allMarkers.hasItem(this.title_)){removeMarkers(this.title_);removeSearchBoxes(this.title_);}};function Business(jsonResult){this.id=Business.addSR(this);this.sqlID=jsonResult.id;this.name=jsonResult.name;this.address=jsonResult.address;this.address2=jsonResult.address2;this.city=jsonResult.city;this.province=jsonResult.province;this._lat=parseFloat(jsonResult.lat);this._lng=parseFloat(jsonResult.lng);this.html_=null;this.phone=jsonResult.phone;this.calcDistance=jsonResult.distance;this.url=jsonResult.url;this.hzInfoWindow=null;if(jsonResult.isAdAgent){this.isAdAgent=true;}else{this.isAdAgent=false;}if(jsonResult.cell!=undefined){this.cell=jsonResult.cell;}if(jsonResult.source=="homezilla"){this.custom=true;}else{this.custom=false;}if(jsonResult.isMortgage=="1"){this.isMortgage=true;}else{this.isMortgage=false;}if(jsonResult.isCatchment=="1"){this.isCatchment=true;}else{this.isCatchment=false;}this.uniqueData=new Hash();for(var name in jsonResult.uniqueData){this.addUniqueData(name,jsonResult.uniqueData[name]);}this.onMap=false;}Business.addSR=function(sr){currentSearchResultID++;allSearchResults.setItem(currentSearchResultID,sr);return currentSearchResultID;};Business.prototype.addUniqueData=function(name,data){var emptyCount=0;if(name==""){emptyCount++;name="_empty"+emptyCount;}if(name=="Quality Url"){this.uniqueData.setItem(name,"<a href='"+data+"'>Review of this Facility</a>");}else{this.uniqueData.setItem(name,data);}};Business.prototype.html=function(){if(this.html_){return this.html_;}this.htmlLines=0;var str="";var name=this.name;var address=this.address+", "+this.city+", "+this.province;var catchment;if(this.isCatchment){catchment="This school is in your catchment!";}else{catchment="";}if(this.searchTitle=="Homes For Sale"){name=address;address=this.name;}if(this.url!=""){str+="<a href='/phpHelpers/search/redirect.php?track="+trackSearchID+"&bid="+this.sqlID+"&url="+escape(this.url)+"'><b>"+name+"</b></a><br>";this.htmlLines++;}else{str+="<span class='infoWinTitle'>"+name+"</span><br/>";this.htmlLines++;}str+="<div class='infoWinBody'>";if(this.address!=""){str+=address+"<br/>";this.htmlLines++;}if(this.address2!=""){str+=this.address+"<br/>";this.htmlLines++;}if(this.address==""){str+=this.city+", "+this.province+"<br/>";this.htmlLines++;}if(this.phone!=""){str+="Phone: "+this.phone+"<br/>";this.htmlLines++;}if(this.uniqueData){for(var field in this.uniqueData.items){var data=this.uniqueData.getItem(field);if(field.indexOf("_empty")==0){str+=data+"<br>";}else{str+=field+": "+data+"<br>";}this.htmlLines++;empty=false;}}if(catchment!=""){str+="<br/><strong>"+catchment+"</strong><br/>";}str+="</div>";this.html_=str;return this.html_;};Business.prototype.listHTML=function(){var s;switch(this.searchTitle){case"Mortgage Brokers":s="<li><strong>"+this.title()+'</strong><span class="address">';if(this.phone!=""){s+=this.phone;}else{if(this.cell!=""){s+=this.cell;}}if(this.url!=""){s+='<a class="brokerLink" href="/phpHelpers/search/redirect.php?track='+trackSearchID+"&ad="+mCompany+"&url="+this.url+'">Website</a>';}s+="</span></li>";break;case"Homes For Sale":s='<li><a href="javascript:setCentre('+this.id+')"><strong>'+this.getShortStreetAddress()+'</strong><span class="address">'+this.title()+" - "+this.prettyDistance()+"</a></span></li>";break;default:var className;var liClassName;if(this.searchTitle=="Parks"&&currentAddress.city=="Toronto"){className="addressInLine";}else{if(this.isAdAgent){className="address";}else{className="address";}}if(this.isCatchment){liClassName="catchment";s='<li class="catchment"><a href="javascript:setCentre('+this.id+')"><strong>'+this.title()+'</strong><span class="'+className+'">'+this.getShortStreetAddress()+" - "+this.prettyDistance()+"</a></span></li>";}else{liClassName="";s='<li><a href="javascript:setCentre('+this.id+')"><strong>'+this.title()+'</strong><span class="'+className+'">'+this.getShortStreetAddress()+" - "+this.prettyDistance()+"</a></span></li>";}break;}return s;};Business.prototype.getStreetAddress=function(){return this.address;};Business.prototype.getShortStreetAddress=function(){var address=this.address;if(!printMode&&address.length>MAX_LENGTH_ADDRESS){address=address.slice(0,MAX_LENGTH_ADDRESS-3)+"...";}return address;};Business.prototype.phone=function(){if(this.phone==""){return null;}return this.phone;};Business.prototype.lng=function(){return this._lng;};Business.prototype.lat=function(){return this._lat;};Business.prototype.title=function(){var title=this.name;if(!printMode&&title.length>MAX_LENGTH_RESULTS_TITLE){title=title.slice(0,MAX_LENGTH_RESULTS_TITLE-3)+"...";}return title;};Business.getSR=function(id){return allSearchResults.getItem(id);};Business.prototype.addToMap=function(icon){if(this.searchTitle!="Mortgage Brokers"){map.addOverlay(this.marker(icon));this.onMap=true;}};Business.prototype.removeFromMap=function(){if(this.onMap){map.removeOverlay(this.marker());this.onMap=false;}};Business.prototype.toString=function(){return"[ "+this.name+", "+this.id+", "+this.distance+", CUSTOM ]";};Business.prototype.infoWindow=function(){HZInfoWindow.removeCurrentHZInfoWindow(false);if(this.hzInfoWindow){this.hzInfoWindow=null;}var point=this.marker_.getPoint();var innerHTML=this.html();var numLines=this.htmlLines;var width=250;var iconSize=this.marker_.getIcon().iconSize;if(map.getCurrentMapType()==G_SATELLITE_3D_MAP){map.openInfoWindow(new GLatLng(this._lat,this._lng),innerHTML);}else{this.hzInfoWindow=new HZInfoWindow(innerHTML,point,width,iconSize,"hzInfoWindow");this.hzInfoWindow.doBubble=true;this.hzInfoWindow.business=this;map.addOverlay(this.hzInfoWindow);this.hzInfoWindow.addCloseButton();}};Business.prototype.prettyDistance=function(){var d=this.distance;if(d<100&&d>=50){d=0.1;}else{d=Math.round(d/100)*100;d=d/1000;}return d+" km";};Business.prototype.duplicate=function(sr){return false;};Business.prototype.setDistance=function(){this.distance=startingCentre.distanceFrom(new GLatLng(this.lat(),this.lng()));};Business.prototype.marker=function(opt_icon){if(this.marker_){return this.marker_;}var marker=new GMarker(new GLatLng(parseFloat(this.lat()),parseFloat(this.lng())),{icon:opt_icon});marker.business=this;if(!printMode){GEvent.bind(marker,"click",this,function(){this.click();});GEvent.bind(marker,"mouseover",this,function(){if(!HZInfoWindow.currentHZInfoWindow||marker.business.hzInfoWindow!=HZInfoWindow.currentHZInfoWindow){marker.business.hzInfoWindow=null;}if(!marker.business.hzInfoWindow){marker.business.infoWindow();}});GEvent.bind(marker,"mouseout",this,function(){if(this.hzInfoWindow&&this.hzInfoWindow.clicked==false){setTimeout("HZInfoWindow.removeCurrentHZInfoWindow(false)",2000);}});}this.marker_=marker;return marker;};Business.prototype.click=function(){if(!this.hzInfoWindow){this.infoWindow();}this.hzInfoWindow.clicked=true;};function HZInfoWindow(html,point,width,iconSize,cssClass){this.point_=point;this.width_=width;this.iconSize_=iconSize;this.cssClass_=cssClass||"hzInfoWindow";this.doBubble=false;this.clicked=false;this.mouseOver=false;this.mouseOut=true;this.html_=html;}HZInfoWindow.currentHZInfoWindow=null;HZInfoWindow.removeCurrentHZInfoWindow=function(force){if(force==undefined){force=true;}if(HZInfoWindow.currentHZInfoWindow&&(!HZInfoWindow.currentHZInfoWindow.mouseOver||force)){if(HZInfoWindow.currentHZInfoWindow.business!=null){HZInfoWindow.currentHZInfoWindow.business.hzInfoWindow=null;}map.removeOverlay(HZInfoWindow.currentHZInfoWindow);map.getPane(G_MAP_FLOAT_PANE).innerHTML="";}};function initHZInfoWindow(){HZInfoWindow.prototype=new GOverlay();HZInfoWindow.prototype.initialize=function(map){HZInfoWindow.currentHZInfoWindow=this;var outerDiv=document.createElement("div");var div=document.createElement("div");var bubbleDiv=document.createElement("div");this.outerDiv_=outerDiv;this.div_=div;this.bubbleDiv_=bubbleDiv;this.outerDiv_.appendChild(bubbleDiv);this.outerDiv_.appendChild(div);$(outerDiv).addClass("infoWindowOuterDiv");GEvent.bindDom(this.outerDiv_,"mousedown",this,this.onClick_);GEvent.bindDom(this.outerDiv_,"dblclick",this,this.onClick_);GEvent.bindDom(this.outerDiv_,"DOMMouseScroll",this,this.onClick_);$(this.div_).html(this.html_).addClass(this.cssClass_);this.setHeight();$(div).mouseover(function(){if(HZInfoWindow.currentHZInfoWindow==null){return;}HZInfoWindow.currentHZInfoWindow.mouseOver=true;HZInfoWindow.currentHZInfoWindow.mouseOut=false;});$(div).mouseout(function(){if(HZInfoWindow.currentHZInfoWindow==null){return;}HZInfoWindow.currentHZInfoWindow.mouseOver=false;HZInfoWindow.currentHZInfoWindow.mouseOut=true;setTimeout("HZInfoWindow.removeCurrentHZInfoWindow(false)",2000);});map.getPane(G_MAP_FLOAT_PANE).appendChild(outerDiv);};HZInfoWindow.prototype.setHeight=function(){var tempElement=this.div_.cloneNode(true);tempElement.id="_tempContents";tempElement.style.visibility="hidden";tempElement.style.height="auto";document.body.appendChild(tempElement);tempElement=document.getElementById("_tempContents");var contentHeight=tempElement.offsetHeight;document.body.removeChild(tempElement);this.height_=contentHeight;};HZInfoWindow.prototype.onClick_=function(e){if(navigator.userAgent.toLowerCase().indexOf("msie")!=-1&&document.all){window.event.cancelBubble=true;window.event.returnValue=false;}else{e.stopPropagation();}};HZInfoWindow.prototype.remove=function(){this.outerDiv_.removeChild(this.div_);this.outerDiv_.removeChild(this.bubbleDiv_);this.outerDiv_.parentNode.removeChild(this.outerDiv_);HZInfoWindow.currentHZInfoWindow=null;};HZInfoWindow.prototype.copy=function(){return new HZInfoWindow(this.html_,this.point_,this.width_,this.iconSize_,this.cssClass_);};HZInfoWindow.prototype.setTopLeft=function(){var ttPosToDiv=map.fromLatLngToDivPixel(this.point_);var ttPos=map.fromLatLngToContainerPixel(this.point_);var ttTop=ttPos.y-this.height_;var ttLeft=ttPos.x-this.width_;if(this.doBubble){ttTop-=12;ttLeft-=10;}if(this.iconSize_!=null){ttLeft-=this.iconSize_.width/2;ttTop-=this.iconSize_.height;}this.positionTop=(ttTop>=0);this.positionLeft=(ttLeft>=0);var odTop=ttPosToDiv.y;if(this.positionTop&&this.iconSize_!=null){odTop-=this.iconSize_.height;}this.outerDiv_.style.top=odTop+"px";var odLeft=ttPosToDiv.x;if(!this.doBubble&&this.iconSize_!=null){if(this.positionLeft){odLeft-=this.iconSize_.width/2;}else{odLeft+=this.iconSize_.width/2;}}this.outerDiv_.style.left=odLeft+"px";};HZInfoWindow.prototype.addCloseButton=function(){var closeDiv=document.createElement("div");$(closeDiv).addClass("iwClose");closeDiv.onclick=HZInfoWindow.removeCurrentHZInfoWindow;this.div_.appendChild(closeDiv);};HZInfoWindow.prototype.redraw=function(force){if(!force){return;}this.setTopLeft();this.div_.style.width=this.width_+"px";this.div_.style.height=this.height_+"px";$(this.div_).addClass(this.cssClass_);if(this.doBubble){if(this.positionTop){if(this.positionLeft){$(this.bubbleDiv_).addClass("bubbleTopLeft");$(this.div_).addClass("iwBubbleTopLeft");}else{$(this.bubbleDiv_).addClass("bubbleTopRight");$(this.div_).addClass("iwBubbleTopRight");}this.div_.style.top="-"+(this.height_+18)+"px";}else{if(this.positionLeft){$(this.bubbleDiv_).addClass("bubbleBottomLeft");$(this.div_).addClass("iwBubbleBottomLeft");}else{$(this.bubbleDiv_).addClass("bubbleBottomRight");$(this.div_).addClass("iwBubbleBottomRight");}}}};}function getTinyURL(linkString,responseFunc){tinyAjax=new HZAjax("/phpHelpers/util/tinyurlAjax.php?url="+urlencode(linkString)+"&track="+trackSearchID,responseFunc);tinyAjax.send();}function hilightDemoPoly(){if(googleLoaded){}}function normalDemoPoly(){if(googleLoaded){demoPolygon.setFillStyle({color:"#00FF00",opacity:0});}}function showDemographics(){if(!googleLoaded){afterGoogleLoadFunc=showDemographics;loadSchoolsAndGoogle();return;}HZInfoWindow.removeCurrentHZInfoWindow(true);toggleCTData();}function addDemographics(){var s="<span>"+"<dl>"+"<dt>Population</dt>"+"<dd>"+addCommas(ctpoly.population)+"</dd>"+"<dt>Median Income</dt>"+"<dd>$"+addCommas(ctpoly.medianIncome)+"</dd>"+"<dt># of Homes</dt>"+"<dd>"+addCommas(ctpoly.dwellings)+"</dd>"+"</dl>"+"</span>";$("#demographicsData").html(s).show();s="<input id='democheckbox' type='checkbox' onclick='toggleDemographicBounds(this)'/>Enable demographics bounds<div id='demohint'>Hint: look at the map</div>";$("#demographicsDataTwo").html(s).show();}function enableStreetView(){if(!googleLoaded){afterGoogleLoadFunc=enableStreetView;loadSchoolsAndGoogle();return;}if(inStreetView){$("#pano").hide();$("#map").show();var streetviewLI=document.getElementById("streetview");streetviewLI.className="";inStreetView=false;map.setCenter(startingCentre);track("hzmaptype","streetview off","");$("#pano").css("margin-right","5px");}else{$("#pano").show();$("#map").hide();inStreetView=true;$("#pano").css("margin-right","0px");var streetviewLI=document.getElementById("streetview");streetviewLI.className="streetViewOn";track("hzmaptype","streetview","");showPanoData();}}function showPanoData(){myPano=new GStreetviewPanorama(document.getElementById("pano"));fenwayPOV={yaw:260.64659986187695,pitch:-10};myPano.setLocationAndPOV(startingCentre);panoClient=new GStreetviewClient();panoClient.getNearestPanorama(startingCentre,loadPano);}function loadPano(panoData){myPano.setLocationAndPOV(panoData.location.latlng);startingCentre=panoData.location.latlng;currentCentre=startingCentre;}function polygonEvents(polygon){GEvent.bind(polygon,"click",this,function(){if(polyMgr.prevNhbd!=-1){latLng=movePointToInsideMap(polygon.getBounds().getCenter());name=rankingsApp.nhbdName(polyMgr.prevNhbd);var innerHTML;if(name.indexOf("Census")!=-1){innerHTML=rankingsApp.nhbdName(polyMgr.prevNhbd)+"<div style='width:200px;border-top:1px solid #494949'>Total # of Homes: <b>"+addCommas(rankingsApp.data.nhbds[polyMgr.prevNhbd].dwellings)+"</b><br>Avg Home Value: <b>$"+addCommas(rankingsApp.data.nhbds[polyMgr.prevNhbd].houseValue)+"</b><br>Median Income: <b>$"+addCommas(rankingsApp.data.nhbds[polyMgr.prevNhbd].medianIncome)+"</div>";track("polygon_click","census",name);}else{innerHTML=rankingsApp.nhbdName(polyMgr.prevNhbd);track("polygon_click","neighbourhood",name);}var hzInfoWindow=new HZInfoWindow(innerHTML,latLng,250);hzInfoWindow.doBubble=true;map.addOverlay(hzInfoWindow);}});GEvent.bind(polygon,"mouseout",this,function(){if(HZInfoWindow.currentHZInfoWindow!=null){setTimeout("HZInfoWindow.removeCurrentHZInfoWindow(false)",1000);}});}function electionDataResponse(){if(electionDataAjax.xmlhttp.readyState==4){var districtPolygons=eval("("+electionDataAjax.xmlhttp.responseText+")");for(var i=0;i<districtPolygons.nhbds.length;i++){districtpoly=districtPolygons.nhbds[i];var polygon=new GPolygon.fromEncoded({polylines:[{color:districtpoly.color,weight:POLY_WEIGHT,opacity:POLY_OPACITY,points:districtpoly.encodedPoly,levels:"BB",zoomFactor:32,numLevels:4}],fill:true,color:districtpoly.color,opacity:0,outline:true});if(polygon.contains(startingCentre)){federalPolygon=polygon;federalDistrict=districtpoly;addElectionResults();electionDataAjax.LOADED=true;return;}}noElectionResults();electionDataAjax.LOADED=true;}}function toggleMapType(){if(!googleLoaded){afterGoogleLoadFunc=toggleMapType;loadSchoolsAndGoogle();return;}var mapTypeLI=document.getElementById("maptype");if(showingSatelliteMap){map.setMapType(G_NORMAL_MAP);mapTypeLI.innerHTML="Satellite";showingSatelliteMap=false;mapTypeLI.className="";eraseCookie("hzmaptype");track("hzmaptype","normal","");}else{map.setMapType(G_HYBRID_MAP);showingSatelliteMap=true;mapTypeLI.className="standard";mapTypeLI.innerHTML="Regular";track("hzmaptype","satellite","");createCookie("hzmaptype","satellite",14);}}function toggleElectionResults(){var fedelection=document.getElementById("fedelection");var browserLI=document.getElementById("electionbrowser");if(showingFederal){map.removeOverlay(federalPolygon);fedelection.style.display="none";fedelection.innerHTML="";showingFederal=false;browserLI.className="";}else{track("toggle_elections","","");addElectionResults();}}function addElectionResults(){var fedelection=document.getElementById("fedelection");var browserLI=document.getElementById("electionbrowser");browserLI.className="voting";var s="";map.addOverlay(federalPolygon);showingFederal=true;s="<h3>"+federalDistrict.name+" MP's</h3>";s+="<dl>";for(var i=0;i<federalDistrict.years.length;i++){var yearobj=federalDistrict.years[i];s+="<dt class='"+yearobj.party+"'>"+yearobj.name+" elected in "+yearobj.year+"<br>"+yearobj.party_name+"</dt>";}s+="</dl>";fedelection.innerHTML+=s;fedelection.style.display="block";browserLI.className="voting";}function getPointCTData(){if(currentAddress.LEVEL<=CITY_LEVEL){noDemographics();return;}var paramList="lat="+currentAddress.lat+"&lng="+currentAddress.lng;pointCTDataAjax=new HZAjax("/phpHelpers/polygons/getCTData.php?"+paramList,pointCTDataResponse);pointCTDataAjax.send();}function pointCTDataResponse(){if(pointCTDataAjax.xmlhttp.readyState==4){var jsonResults=eval("("+pointCTDataAjax.xmlhttp.responseText+")");if(typeof(jsonResults["error"])!="undefined"){noDemographics();return;}ctpoly=jsonResults;addDemographics(ctpoly);$("#demobrowser").click(showDemographics);}}function noElectionResults(){var browserLI=document.getElementById("electionbrowser");browserLI.className="nodemo";browserLI.onmouseover=function(){var db=document.getElementById("electionbrowser");db.innerHTML="Not Available";};browserLI.onmouseout=function(){var db=document.getElementById("electionbrowser");db.innerHTML="Elections";};}function noDemographics(){var demobrowserLI=document.getElementById("demobrowser");demobrowserLI.onmouseover=function(){var db=document.getElementById("demobrowser");db.innerHTML="Not Available";};demobrowserLI.onmouseout=function(){var db=document.getElementById("demobrowser");db.innerHTML="Demographics";};var demographicsDiv=document.getElementById("demographicsData");$("#demographicsData").html("<div id='demographicsError'>No Demograpics Available</div>").show();}function track(type,item1,item2){if(isRobot){return;}var paramList="type="+type+"&item1="+item1+"&item2="+item2+"&track="+trackSearchID;trackAjax=new HZAjax("/phpHelpers/util/trackAjax.php?"+paramList,null);trackAjax.send();}function getCTData(year){if(pullingCTData){pullCTDataAgain=true;return;}pullingCTData=true;var bounds=map.getBounds();var paramList="swlat="+bounds.getSouthWest().lat()+"&swlng="+bounds.getSouthWest().lng()+"&nelat="+bounds.getNorthEast().lat()+"&nelng="+bounds.getNorthEast().lng()+"&track="+trackSearchID;getCTsAjax=new HZAjax("/phpHelpers/polygons/getCTData.php?"+paramList,storeCTData);getCTsAjax.send();}function getCTDataFromId(id){getCTIdAjax=new HZAjax("/phpHelpers/polygons/getCTData.php?ctid="+id,showMainCTData);getCTIdAjax.send();}function showMainCTData(){if(getCTIdAjax.checkReadyState()){}}function getHoodData(){if(pullingHoodData){pullHoodDataAgain=true;return;}pullingHoodData=true;if(getHoodAjax){storeHoodData();}else{var bounds=map.getBounds();var paramList="swlat="+(bounds.getSouthWest().lat()-0.01)+"&swlng="+(bounds.getSouthWest().lng()-0.03)+"&nelat="+(bounds.getNorthEast().lat()+0.01)+"&nelng="+(bounds.getNorthEast().lng()+0.03)+"&track="+trackSearchID;getHoodAjax=new HZAjax("/phpHelpers/polygons/getHoodData.php?"+paramList,storeHoodData);getHoodAjax.send();}}function showThisHoodData(){var bounds=map.getBounds();var paramList="hood="+currentAddress.hood.id;thisHoodAjax=new HZAjax("/phpHelpers/polygons/getHoodData.php?"+paramList,showThisHoodDataResponse);thisHoodAjax.send();}function showThisHoodDataResponse(){if(thisHoodAjax.xmlhttp.readyState==4){var jsonResult=eval("("+thisHoodAjax.xmlhttp.responseText+")");var polylines=[];for(var i=0;i<jsonResult.length;i++){var poly=jsonResult[i];var polyline={color:"#000000",weight:3,opacity:POLY_OPACITY,points:poly,levels:"BB",zoomFactor:32,numLevels:4};polylines.push(polyline);}var polygon=new GPolygon.fromEncoded({polylines:polylines,fill:true,color:"#909090",opacity:0.4,outline:true});map.addOverlay(polygon);}}function getPolygons(type,year){type=type.toLowerCase();switch(type){case"census":getCTData(year);break;case"hoods":getHoodData();break;default:break;}}function storeCTData(){storePolyData(getCTsAjax.xmlhttp);}function storeHoodData(){if(getHoodAjax.xmlhttp.readyState==4){storePolyData(getHoodAjax.xmlhttp);if(currentAddress.LEVEL==HOOD_LEVEL){for(var i=0;i<polyMgr.polys.length;i++){var hoodIndex=polyMgr.polyToNhbd[i];var hood=rankingsApp.data.nhbds[hoodIndex];if(hood.id==currentAddress.hood.id){var polygon=polyMgr.polys[i];polygon.show();}}}}}function storePolyData(xmlhttp){if(xmlhttp.readyState==4){var myPolyObject=eval("("+xmlhttp.responseText+")");if(polyMgr==null){sandyNhbdData=myPolyObject;polyMgr=new PolyManager(map);for(var i=0;i<sandyNhbdData.nhbds.length;i++){sandyNhbdData.nhbds[i].polys=polyMgr.indexPolys(sandyNhbdData.nhbds[i].encodedPoly,"BB",sandyNhbdData.nhbds[i].color,1,i);}rankingsApp=new RankingsApp();}else{polyMgr.activeSet=[];var myPolyObject=eval("("+xmlhttp.responseText+")");var myPolyAssocativeOjbect=new Array();for(var i=0;i<sandyNhbdData.nhbds.length;i++){myPolyAssocativeOjbect[sandyNhbdData.nhbds[i].name]=i;}var initalPolyLength=polyMgr.polys.length;var polysAdded=0;for(var i=0;i<myPolyObject.nhbds.length;i++){if(myPolyAssocativeOjbect[myPolyObject.nhbds[i].name]==null){myPolyObject.nhbds[i].polys=polyMgr.indexPolys(myPolyObject.nhbds[i].encodedPoly,"BB",myPolyObject.nhbds[i].color,1,polysAdded+initalPolyLength);polysAdded++;}}rankingsApp.addNewPolys(myPolyObject);polyMgr.reload();}if(pullingCTData){ctDataShowing=true;pullingCTData=false;if(pullCTDataAgain){pullCTDataAgain=false;getCTData("2006");}}if(pullingHoodData){hoodDataShowing=true;pullingHoodData=false;if(pullHoodDataAgain){pullHoodDataAgain=false;getHoodData();}}}}function urlencode(str){return escape(str).replace(/\+/g,"%2B").replace(/%20/g,"+").replace(/\*/g,"%2A").replace(/\//g,"%2F").replace(/@/g,"%40");}function addCommas(nStr){nStr+="";x=nStr.split(".");x1=x[0];x2=x.length>1?"."+x[1]:"";var rgx=/(\d+)(\d{3})/;while(rgx.test(x1)){x1=x1.replace(rgx,"$1"+","+"$2");}return x1+x2;}var rankingsApp;var summaryBox;var nhbdMarkers;var nhbdPolys=[];var polyMgr;var NUM_SLICES=15;var POLY_COLOR="#0000ff";var POLY_WEIGHT=3;var POLY_OPACITY=0.7;var sandyNhbdData;var mouseListener;function showHoodData(){var checkbox=document.getElementById("hoodtag");toggleHoodData(checkbox);}function toggleHoodData(checkbox){if(!googleLoaded){afterGoogleLoadFunc=showHoodData;loadSchoolsAndGoogle();return;}HZInfoWindow.removeCurrentHZInfoWindow(true);if(checkbox.checked){if(ctDataShowing){toggleCTData();}enableHoodData();}else{disableHoodData();}}function showDemographicData(){var checkbox=document.getElementById("democheckbox");toggleDemographicBounds(checkbox);}function toggleDemographicBounds(checkbox){if(!googleLoaded){afterGoogleLoadFunc=showDemographicData;loadSchoolsAndGoogle();return;}if(checkbox.checked){if(ctpoly!=null){demoPolygon=ctDemoPolygon();$("#demohint").show();}}else{map.removeOverlay(demoPolygon);$("#demohint").hide();}}function toggleCTData(){if(!ctDataShowing){var hoodbox=document.getElementById("hoodtag");if(hoodbox.checked){hoodbox.checked=false;toggleHoodData(hoodbox);}enableCensusData();}else{disableCensusData();}}function enableHoodData(){getPolygons("hoods","");useBounds=false;showHoodHint();}function enableCensusData(){getPolygons("census","2006");useBounds=false;var browserLI=document.getElementById("demobrowser");browserLI.className="demo";}function disableHoodData(){stopHoods();hideHoodHint();summaryBox=null;sandyNhbdData=null;polyMgr=null;map.closeInfoWindow();setHTML("polyDesc","");useBounds=true;}function showHoodHint(){$("#boundriesHint").show();}function hideHoodHint(){$("#boundriesHint").hide();}function disableCensusData(){stopHoods();summaryBox=null;sandyNhbdData=null;polyMgr=null;map.closeInfoWindow();setHTML("polyDesc","");useBounds=true;ctDataShowing=false;var browserLI=document.getElementById("demobrowser");browserLI.className="";}function stopHoods(){appEvents.removeListener("selectNhbd",showNhbd,summaryBox);polyMgr.unload();GEvent.removeListener(mouseListener);GEvent.removeListener(doubleClickListener);}function RankingsApp(ver){var startTime=new Date().getTime();this.data=new Object();this.data.nhbds=sandyNhbdData.nhbds;summaryBox=new SummaryBox(this);this.data.nhbdIndex=-1;appEvents.addListener("selectNhbd",showNhbd,summaryBox);if(this.nhbdIndex()!=-1){appEvents.fireEvent(null,"selectNhbd",[this.nhbdIndex()]);}polyMgr.init();appEvents.addListener("selectNhbd",polyMgr.showNhbd,polyMgr);doubleClickListener=GEvent.addListener(map,"dblclick",takeMeToTheHood);mouseListener=GEvent.addListener(map,"mousemove",mouseMove);}RankingsApp.prototype.addNewPolys=function(newPolygonData){var existingHoodCount=this.data.nhbds.length;for(var i=0;i<newPolygonData.nhbds.length;i++){this.data.nhbds[existingHoodCount+i]=newPolygonData.nhbds[i];}};function takeMeToTheHood(){}function movePointToInsideMap(latLng){var lat=null;var lng=null;var bounds=map.getBounds();var N=bounds.getNorthEast().lat();var E=bounds.getNorthEast().lng();var S=bounds.getSouthWest().lat();var W=bounds.getSouthWest().lng();if(latLng.lat()>N){lat=N;}else{if(latLng.lat()<S){lat=S;}}if(latLng.lng()>E){lng=E;}else{if(latLng.lng()<W){lng=W;}}if(lat!=null||lng!=null){if(lat==null){lat=latLng.lat();}if(lng==null){lng=latLng.lng();}latLng=new GLatLng(lat,lng);}return latLng;}RankingsApp.prototype.polygon=function(i){return this.data.nhbds[i].encodedPoly;};RankingsApp.prototype.nhbdIndex=function(i){return this.data.nhbdIndex;};RankingsApp.prototype.nhbdCount=function(i){return this.data.nhbds.length;};RankingsApp.prototype.nhbdName=function(i){return replaceAll(this.data.nhbds[i].name,"+","'");};RankingsApp.prototype.nhbdCentroid=function(i){return this.data.nhbds[i].centroid;};function SummaryBox(app){this.app=app;}function showNhbd(idx){setHTML("polyDesc",rankingsApp.nhbdName(idx)+" is outlined");}function GeoHelper(){}GeoHelper.strToPoint=function(str){var point=str.split(" ");return new GLatLng(1*point[1],1*point[0]);};GeoHelper.strToBounds=function(str){var pointpairs=str.split(",");return new GLatLngBounds(this.strToPoint(pointpairs[0]),this.strToPoint(pointpairs[1]));};GeoHelper.strToCentroid=function(str){var pointpairs=str.split(",");var sw=this.strToPoint(pointpairs[0]);var ne=this.strToPoint(pointpairs[1]);return new GLatLng((sw.lat()+ne.lat())/2,(sw.lng()+ne.lng())/2);};function mouseMove(pt){polyMgr.update(pt);}function PolyManager(map){this.map=map;this.polys=[];this.polyToNhbd=[];this.nhbdToPolys=[];this.prevPoly=null;this.prevNhbd=-1;this.prevHSlice=-1;this.prevVSlice=-1;this.activeSet=[];}PolyManager.prototype.init=function(idxToSelect){var startTime=new Date().getTime();for(var i=0;i<this.polys.length;i++){this.map.addOverlay(this.polys[i]);}this.buildSlicesFromMapBounds();};PolyManager.prototype.unload=function(){while(this.polys.length>0){this.map.removeOverlay(this.polys.pop());}};PolyManager.prototype.reload=function(idxToSelect){for(var i=0;i<this.polys.length;i++){this.map.addOverlay(this.polys[i]);this.polys[i].hide();}this.buildSlicesFromMapBounds();};PolyManager.prototype.indexPolys=function(ptString,levelString,color,num,nhbdIdx){var nhbdPolyIndices=[];if(num==1){nhbdPolyIndices.push(this.polys.length);var polygon=new GPolygon.fromEncoded({polylines:[{color:color,weight:POLY_WEIGHT,opacity:POLY_OPACITY,points:ptString,levels:levelString,zoomFactor:32,numLevels:4}],fill:true,visibility:0,color:"#909090",opacity:0.4,outline:true});polygon.hide();polygonEvents(polygon);this.polys.push(polygon);this.polyToNhbd.push(nhbdIdx);}else{var sepPts=ptString.split(" ");var sepLevels=levelString.split(" ");for(var i=0;i<num;i++){nhbdPolyIndices.push(this.polys.length);var polygon=new GPolygon.fromEncoded({polylines:[{color:color,weight:POLY_WEIGHT,opacity:POLY_OPACITY,points:setPts[i],levels:setLevels[i],zoomFactor:32,numLevels:4}],fill:true,color:"#909090",visibility:0,opacity:0.4,outline:true});polygon.hide();polygonEvents(polygon);setHTML("polyDesc",rankingsApp.nhbdName(idx)+" is outlined");this.polys.push(polygon);this.polyToNhbd.push(nhbdIdx);}}this.nhbdToPolys.push(nhbdPolyIndices);return nhbdPolyIndices;};PolyManager.prototype.buildSlicesFromMapBounds=function(){this.hSlices=[];this.vSlices=[];this.hSlicePolys=[];this.vSlicePolys=[];var bounds=map.getBounds();var N=bounds.getNorthEast().lat();var E=bounds.getNorthEast().lng();var S=bounds.getSouthWest().lat();var W=bounds.getSouthWest().lng();var dX=E-W;var dY=N-S;var xStep=dX/NUM_SLICES;var yStep=dY/NUM_SLICES;for(var i=0;i<NUM_SLICES;i++){var newHSlice=new GLatLngBounds(new GLatLng(S+yStep*i,W),new GLatLng(S+yStep*(i+1),E));var newVSlice=new GLatLngBounds(new GLatLng(S,W+xStep*i),new GLatLng(N,W+xStep*(i+1)));this.hSlices.push(newHSlice);this.vSlices.push(newVSlice);var polysInHSlice=[];var polysInVSlice=[];for(var j=0;j<this.polys.length;j++){if(newHSlice.intersects(this.polys[j].getBounds())){polysInHSlice.push(j);}if(newVSlice.intersects(this.polys[j].getBounds())){polysInVSlice.push(j);}}this.hSlicePolys.push(polysInHSlice);this.vSlicePolys.push(polysInVSlice);}};PolyManager.prototype.update=function(pt){if(this.prevPoly!=null&&this.prevPoly.getBounds().contains(pt)&&this.prevPoly.contains(pt)){return;}var newHSlice=null;var newVSlice=null;for(var i=0;i<NUM_SLICES;i++){if(this.hSlices[i].contains(pt)){newHSlice=i;}if(this.vSlices[i].contains(pt)){newVSlice=i;}}if(newHSlice==null||newVSlice==null){this.deselectAll();return;}if(newHSlice!=this.prevHSlice||newVSlice!=this.prevVSlice){this.prevHSlice=newHSlice;this.prevVSlice=newVSlice;var outer=this.hSlicePolys[newHSlice];var inner=this.vSlicePolys[newVSlice];if(inner.length>outer.length){var tmp=outer;outer=inner;inner=tmp;}this.activeSet=[];for(var i=0;i<outer.length;i++){for(var j=0;j<inner.length;j++){if(outer[i]==inner[j]){this.activeSet.push(outer[i]);}}}}for(var i=0;i<this.activeSet.length;i++){var poly=this.polys[this.activeSet[i]];if(poly.getBounds().contains(pt)&&poly.contains(pt)){this.prevPoly=this.polys[this.activeSet[i]];this.showNhbdInternal(this.polyToNhbd[this.activeSet[i]]);appEvents.fireEvent(null,"selectNhbd",[this.polyToNhbd[this.activeSet[i]]]);return;}}this.deselectAll();};PolyManager.prototype.showNhbdInternal=function(idx){if(this.prevNhbd!=-1){var polyIndices=this.nhbdToPolys[this.prevNhbd];for(var i=0;i<polyIndices.length;i++){this.polys[polyIndices[i]].hide();}}if(polyMgr.prevNhbd!=-1){name=rankingsApp.nhbdName(polyMgr.prevNhbd);if(name.indexOf("Census")!=-1){track("polygon_hover","census",name);}else{track("polygon_hover","neighbourhood",name);}}var polyIndices=this.nhbdToPolys[idx];for(var i=0;i<polyIndices.length;i++){this.polys[polyIndices[i]].show();}this.prevNhbd=idx;};PolyManager.prototype.showNhbd=function(idx){if(idx!=this.prevNhbd&&idx>-1&&idx<this.nhbdToPolys.length){this.showNhbdInternal(idx);}};PolyManager.prototype.deselectAll=function(){if(this.prevNhbd!=-1){var polyIndices=this.nhbdToPolys[this.prevNhbd];for(var i=0;i<polyIndices.length;i++){this.polys[polyIndices[i]].hide();}this.prevNhbd=-1;this.prevPoly=null;appEvents.fireEvent(null,"selectCity",[]);}};function isHomeForSale(){if(currentAddress.accuracy!=8){return;}isThisForSale(currentAddress.street,currentAddress.city,currentAddress.province);}function isThisForSale(address,city,province){var params;params="cty="+city+"&prv="+province+"&adr="+address+"&cty2="+cityParam;listingsCheckAjax=new HZAjax("/phpHelpers/rets/addressHomesCheck.php?"+params,forSaleResponse);listingsCheckAjax.send();}function forSaleResponse(){if(listingsCheckAjax.xmlhttp.readyState==4){var jsonResults=eval("("+listingsCheckAjax.xmlhttp.responseText+")");if(jsonResults.home.hasHome!="false"){updateForSaleSign(jsonResults.home.homes[0]);}}}function updateForSaleSign(jsonListing){$("#forSaleDetails").html("<dl><dt>Price:</dt><dd>"+jsonListing.price+"</dd>"+"<dt> Beds:</dt><dd>"+jsonListing.beds+"</dd>"+"<dt> Baths:</dt><dd>"+jsonListing.baths+"</dd>"+"</dl>"+"<div id='listingLink'><a href='"+jsonListing.listingLink+"'>Show me the listing...</a></div>");$("#forSaleSign").show();}function setModalTopLeft(){var vtmodal=$("#vtmodal");var h=($(window).height()-vtmodal.height())/2;var w=($(window).width()-vtmodal.width())/2;if(h>200){h=200;}$("#modalContainer").css("top",h);$("#modalContainer").css("left",w);}function openVT(e){track("virtual_tour",currentAddress.city,"");$("#vtmodal").modal();setModalTopLeft();$("#vtmodal").show();}function addVTMarker(){var latlng=new GLatLng(videoLat,videoLng);var marker=new GMarker(latlng,HZIcon.FLICKR());map.addOverlay(marker);GEvent.addListener(marker,"click",function(){openVT();});}function jQueryCheckTree(){(function(jQuery){jQuery.fn.checkTree=function(settings){settings=jQuery.extend({onExpand:null,onCollapse:null,onCheck:null,onUnCheck:null,onHalfCheck:null,onLabelHoverOver:null,onLabelHoverOut:null,labelAction:"expand",debug:false},settings);var $tree=this;$tree.find("li").find("ul").hide().end().find(":checkbox").click(function(){var action=settings.labelAction;switch(settings.labelAction){case"expand":jQuery(this).siblings(".arrow").click();break;case"check":jQuery(this).siblings(".checkbox").click();break;}}).change(function(){var $all=jQuery(this).siblings("ul").find(":checkbox");var $checked=$all.filter(":checked");if($all.length==$checked.length){jQuery(this).attr("checked","checked").siblings(".checkbox").removeClass("half_checked").addClass("checked");if(settings.onCheck){settings.onCheck(jQuery(this).parent());}}else{if($checked.length==0){jQuery(this).attr("checked","").siblings(".checkbox").removeClass("checked").removeClass("half_checked");if(settings.onUnCheck){settings.onUnCheck(jQuery(this).parent());}}else{if(settings.onHalfCheck&&!jQuery(this).siblings(".checkbox").hasClass("half_checked")){settings.onHalfCheck(jQuery(this).parent());}jQuery(this).attr("checked","").siblings(".checkbox").removeClass("checked").addClass("half_checked");}}}).attr("checked","").hide().end().find("label").hover(function(){jQuery(this).addClass("hover");if(settings.onLabelHoverOver){settings.onLabelHoverOver(jQuery(this).parent());}},function(){jQuery(this).removeClass("hover");if(settings.onLabelHoverOut){settings.onLabelHoverOut(jQuery(this).parent());}}).click(function(){var action=settings.labelAction;switch(settings.labelAction){case"expand":jQuery(this).siblings(".arrow").click();break;case"check":jQuery(this).siblings(".checkbox").click();break;}}).end().each(function(){var $arrow=jQuery('<div class="arrow"></div>');if(jQuery(this).is(":has(ul)")){$arrow.addClass("collapsed");$arrow.click(function(){jQuery(this).siblings("ul").toggle();if(jQuery(this).hasClass("collapsed")){jQuery(this).addClass("expanded").removeClass("collapsed");if(settings.onExpand){settings.onExpand(jQuery(this).parent());}}else{jQuery(this).addClass("collapsed").removeClass("expanded");if(settings.onCollapse){settings.onCollapse(jQuery(this).parent());}}});}var $checkbox=jQuery('<div class="checkbox"></div>');$checkbox.click(function(){jQuery(this).removeClass("half_checked").toggleClass("checked").siblings(":checkbox").click();});jQuery(this).prepend($checkbox).prepend($arrow);});return $tree;};})(jQuery);}