function NearbyFinder(maxId,lat,lon,st,ci,pv,pc,lm,name,addr,ph){this.maxId=maxId;this.currentId=-1;this.lat=lat;this.lon=lon;this.street=st;this.city=ci;this.province=pv;this.postalCode=pc;this.name=(undefined!=name)?name:"";this.addr=(undefined!=addr)?addr:"";this.ph=(undefined!=ph)?ph:"";this.lm=(undefined!=lm)?lm:false;this.results=new Array(this.maxId+1);this.mapInfo=new Array(this.maxId+1);for(var i=0;i<=this.maxId;i++){this.results[i]=null;this.mapInfo[i]=null}}String.prototype.trim=function(){this.replace("/^s+|s+$/g","");return this.replace("/\n+$/g","")};function getNameAndLink(listing){var result="";if((null!=listing.link)&&listing.link.href.length>0){result='<a href="'+listing.link.href+'" title="'+listing.link.title+'" target="_BLANK" onclick="_hbLink(\'yp_whatnearby\', \'whatnearby\');"><strong>'+listing.link.content+"</strong></a>"}else{result="<strong>"+listing.name+"</strong>"}return result}function getAddress(listing){var address="";if(null!=listing.address){if(listing.address.street!=null&&listing.address.street.length>0){address+=listing.address.street.trim()}if(listing.address.city!=null&&listing.address.city.length>0){if(address!=""){address+=", "}address+=listing.address.city.trim()}if(listing.address.province!=null&&listing.address.province.length>0){if(address!=""){address+=", "}address+=listing.address.province.trim()}if(listing.address.postalCode!=null&&listing.address.postalCode.length>0){if(address!=""){address+=" "}address+=listing.address.postalCode.trim()}}return address}function buildList(listings){var htmlsection="";for(i=0;i<listings.length;i++){if(i==0){htmlsection+='<tr><td colspan="2" style="width: 100%; height: 3px; line-height: 3px; border-bottom: 1px solid #FFE21C">&nbsp;</td></tr>'}htmlsection+='<tr><td colspan="2" style="height: 3px; line-height: 3px">&nbsp;</td></tr>';j=i+1;htmlsection+='<tr><td rowspan="2"><div class="mapCount listing">'+j+'<a name="mappedListing'+j+'"></a></div></td><td>'+getNameAndLink(listings[i])+"</td></tr>";htmlsection+="<tr><td>";if(listings[i].phone!=null&&listings[i].phone.length>0){htmlsection+='<div class="phoneNumber">'+listings[i].phone+"</div>"}address=getAddress(listings[i]);if(address!=""){htmlsection+='<div class="address">'+address+"</td></tr>"}htmlsection+='<tr><td colspan="2" style="width: 100%; line-height: 3px; border-bottom: 1px solid #FFE21C">&nbsp;</td></tr>'}return htmlsection}initMapInfo=function(finder,id){finder.mapInfo[id]=new Array();var iconSpec=(true==finder.lm)?createIconSpecification("/images/bluePushpin.gif",'<div id="1" class="pushpinLandmark"></div>'):createIconSpecification("http://cb.yp.ca/map/dart.png",'<div id="1" class="pushpin"></div>');finder.mapInfo[id][0]=[finder.lat,finder.lon,finder.name,finder.addr,finder.ph,"","","",iconSpec]};addMapInfo=function(finder,id,lat,lon,link,title,name,st,ci,pv,pc,ph,distance){if(null==finder.mapInfo[id]){initMapInfo(finder,id)}var i=finder.mapInfo[id].length;var iconSpec=createIconSpecification("http://cb.yp.ca/map/dart.png",'<div id="'+i+'" class="pushpin"><span class="text">'+i+"</div>");finder.mapInfo[id][i]=new Array();if((null!=lat)&&(null!=lon)){finder.mapInfo[id][i][0]=lat;finder.mapInfo[id][i][1]=lon}else{finder.mapInfo[id][i][0]=0;finder.mapInfo[id][i][1]=0}if(null!=link){finder.mapInfo[id][i][2]="<a href='"+link+"' title='"+title+"' target='_BLANK'><strong>"+name+"</strong></a>"}else{finder.mapInfo[id][i][2]=name}finder.mapInfo[id][i][3]=(null!=st)?st:"";finder.mapInfo[id][i][4]=(null!=ci)?ci:"";finder.mapInfo[id][i][5]=(null!=pv)?pv:"";finder.mapInfo[id][i][6]=(null!=pc)?pc:"";finder.mapInfo[id][i][7]=(null!=ph)?ph:"";finder.mapInfo[id][i][8]=iconSpec};redoMap=function(finder,id){if(null==finder.mapInfo[id]){initMapInfo(finder,id)}var map=createMap(clientToken,finder.lat,finder.lon,10);map.AddLocations(finder.mapInfo[id]);map.CenterZoom(finder.mapInfo[id])};function collapseListings(finder,id){for(var i=0;i<=finder.maxId;i++){if(i!=id){if(document.getElementById("nearby_"+i)!=null){document.getElementById("nearby_"+i).style.display="none"}}if((i!=finder.maxId)&&(document.getElementById("nearbyicon_"+i)!=null)){document.getElementById("nearbyicon_"+i).src="/images/scrollNone.gif"}}}function redrawListings(finder,id){collapseListings(finder,id);finder.currentId=id;if(0<=id){element=document.getElementById("nearby_"+id);if(element!==null){element.style.display="block"}}redoMap(finder,id)}function createInnerHtml(finder,id){var htmlsection='<table cellpadding="0" cellspacing="0" border="0">';if(finder.results[id].listings.length>0){htmlsection+=buildList(finder.results[id].listings)}else{htmlsection+='<tr><td colspan="2">'+finder.results[id].noResults+"</td></tr>"}if((finder.results[id].totalCount>finder.results[id].listings.length)&&(0<finder.results[id].listings.length)&&(null!=finder.results[id].moreLink)){htmlsection+='<tr><td colspan="2"><span style="float: right"><a href="'+finder.results[id].moreLink.href+'" title="'+finder.results[id].moreLink.title+'" target="_BLANK">'+finder.results[id].moreLink.content+"</a></span></td></tr>"}htmlsection+='<tr><td colspan="2"><span style="float: right"><a href="'+finder.results[id].allLink.href+'" title="'+finder.results[id].allLink.title+'" target="_BLANK">'+finder.results[id].allLink.content+"</a></span></td></tr>";htmlsection+='</table><div style="height: 5px; line-height: 5px">&nbsp;</div>';return htmlsection}function parseResults(finder,id,results,noHtml){if((null!=results)&&(""!=results)){finder.results[id]=eval("("+results+")");finder.mapInfo[id]=null;if(null!=finder.results[id]){for(var i=0;i<finder.results[id].listings.length;i++){var l=finder.results[id].listings[i];addMapInfo(finder,id,l.address.location.latitude,l.address.location.longitude,l.link.href,l.link.title,l.name,l.address.street,l.address.city,l.address.province,l.address.postalcode,l.phone,l.distance)}if(!noHtml&&(null!=document.getElementById("nearby_"+id))){document.getElementById("nearby_"+id).innerHTML=createInnerHtml(finder,id)}}}}function getNearbyList(finder,url,id){if(0<=id){if((id!=finder.maxId)&&(id==finder.currentId)){redrawListings(finder,-1)}else{if((null==finder.results[id])||(id==finder.maxId)){try{var http=getHTTPObject();http.open("GET",url,true);http.onreadystatechange=function(){if(http.readyState==4){parseResults(finder,id,http.responseText,false);redrawListings(finder,id)}};http.send(null)}catch(e){}}else{redrawListings(finder,id)}}}}function showNearbyList(finder,url,id){if(0<=id){if((id!=finder.maxId)&&(id==finder.currentId)){redrawListings(finder,-1)}else{redrawListings(finder,id)}}}function nearbySearch(finder,url,id){if(0<=id){try{var http=getHTTPObject();http.open("GET",url,true);http.onreadystatechange=function(){if(http.readyState==4){parseResults(finder,id,http.responseText,false)}};http.send(null)}catch(e){}}}function getNearbyName(finder){var whatval=document.getElementById("ac1").value;var urlstr="/search/nearby.html?addr=cZ"+finder.lon+","+finder.lat+"QQstZQQciZ"+finder.city+"QQpvZ"+finder.province+"QQpcZ&what="+whatval+"&ln="+finder.name;getNearbyList(finder,urlstr,finder.maxId);_hbLink("yp_"+_hbxStrip(whatval),"whatnearby")}function onWhatInput(event,finder){e=event||window.event;if(13==e.keyCode){e.cancelBubble=true;e.returnValue=false;getNearbyName(finder)}};