
var YPSearchManager=new YPSearchManagerClass();function YPSearchManagerClass()
{this.Search=m_Search;this.ReSearch=m_ReSearch;this.RetrieveQueries=m_RetrieveQueries;this.AddLocationPinToMap=AddLocationPinToMap;this.CenterListing=m_CenterListing;this.ShowDualResults=ShowDualResults;this.ShowPopup=m_ShowPopup;this.OpenURL=OpenURL;this.ShowActionDiv=ShowActionDiv;this.GDDForListingPopup=GDDForListingPopup;this.GNBForListingPopup=GNBForListingPopup;this.GDDForLocationPopup=GDDForLocationPopup;this.GNBForLocationPopup=GNBForLocationPopup;this.SaveListingToCustomMap=SaveListingToCustomMap;this.SaveLocationToCustomMap=SaveLocationToCustomMap;this.HBXSearch=hbxSearch;this.isGNBForListingPopup=false;var dualResultShortTableSize=1;var popupDelay=800;var g_sResult=new Object();var g_recResult=new Object();var pinShapeLayer=null;var g_Locations=new Object();var locationIndex=0;this.includePlaces=function(veplaces){g_Locations=veplaces;}
var g_navMap=true;var g_showDualResults=false;var g_listingShapeMap=new Array();var searchingLock=null;var recommendMode=false;function hbxSearch(searchType,count,keyword,location)
{var ev1=_hbEvent("search");ev1.keywords=keyword!=null&&keyword!=''?_hbxStrip(keyword):null;ev1.results=count;ev1.attr1=location!=null&&location!=''?_hbxStrip(_hbxAccentStrip(location)):null;switch(searchType)
{case"map":ev1.attr2="find on a map";break;case"business":ev1.attr2="find a business";break;case"directions":ev1.attr2="get driving directions";break;}}
function m_Search(keyOrBus,navMap,vePlaces){searchingLock=new Object();recommendMode=false;var businessSearch=(keyOrBus=='bus');var personSearch=(keyOrBus=='per');var sbn=(businessSearch)?document.getElementById('cbBusOnly').checked:false;g_navMap=true;g_showDualResults=false;g_Locations=vePlaces;var searchType=keyOrBus;var query=new SearchQuery(keyOrBus,null,null,(vePlaces!=null&&vePlaces.length>0?vePlaces[0].LatLong:null),null,null);if(navMap!=undefined)
{g_navMap=navMap;}
ClientCache.Save("g_ReusePane",paneNumber);ClientCache.Save("g_FullTable","fab_table"+paneNumber);ClientCache.Save("g_Summary","fab_summary"+paneNumber);ClientCache.Save("g_Goto","fab_goto"+paneNumber);ClientCache.Save("g_Goto_top","fab_goto_top"+paneNumber);ClientCache.Save("g_FullBus","fab_full"+paneNumber);if((pinShapeLayer!=null)&&(this.isGNBForListingPopup==false))
{pinShapeLayer.DeleteAllShapes();}
InfoBoxManager.ClearDescriptions('Location');var location=ClientCache.Retrieve('pane_'+paneNumber+'_LocationInput');var keyword=ClientCache.Retrieve('pane_'+paneNumber+'_NameInput').cleanse();var qString="?keyword="+keyword+"&location="+location+"&txtMode="+keyOrBus+"&sbn="+sbn;if(businessSearch&&location.isSimpleSearchCity())qString+="&rci="+location.cleanse();var simpleSearchOff=(triggerSimpleSearchInAllCases&&location.containsNumbers())||(!triggerSimpleSearchInAllCases);var doProximitySearch=(simpleSearchOff&&vePlaces!=null&&vePlaces.length>0&&!location.isSimpleSearchCity()&&location.cleanse()!="canada");if(doProximitySearch)
{var vePlace=vePlaces[0];qString+="&lat="+vePlace.LatLong.Latitude+"&lon="+vePlace.LatLong.Longitude+"&confidence="+vePlace.MatchConfidence;if(businessSearch)
{AddLocationPinToMap(0,vePlace.Name,vePlace.LatLong.Latitude,vePlace.LatLong.Longitude,1);}
ClientCache.Save("LatLongSpecified","true");ClientCache.Save("Latitude",vePlace.LatLong.Latitude);ClientCache.Save("Longitude",vePlace.LatLong.Longitude);ClientCache.Save("Confidence",vePlace.MatchConfidence);}
else
{ClientCache.Save("LatLongSpecified","false");}
qString+="&newSearch=1";if(isFrench())
{qString+="&language=FR";}
qString+="&perPage=10";ClientCache.Save('busName',keyword);ClientCache.Save('location',location);query.What=keyword!=''?keyword:null;query.Where=location!=''?location:null;ClientCache.Save('pane_'+paneNumber+'_keyword',keyword);ClientCache.Save('pane_'+paneNumber+'_location',location);ClientCache.Save('lastSearch',keyOrBus);ClientCache.Save('pane_'+paneNumber+'_type',keyOrBus);ClientCache.Save('pane_'+paneNumber+'_query',qString);this.PersistQuery(query,keyOrBus);qStringCache=qString+"&pageNum=1";var request=new AjaxRequest("Handlers/YPSearch.ashx"+qString,ProcessResult);request.Execute();}
function m_ReSearch(pageNum,reusePaneNumber)
{searchingLock=new Object();recommendMode=false;currentKeyOrBus=keyOrBus;var paneNumber;g_showDualResults=false;var keyOrBus=ClientCache.Retrieve('lastSearch');var keyword=ClientCache.Retrieve('pane_'+reusePaneNumber+'_keyword');var location=ClientCache.Retrieve('pane_'+reusePaneNumber+'_location');var paneNumber;if(reusePaneNumber!=undefined)
{paneNumber=reusePaneNumber;}
else
{paneNumber=ClientCache.Retrieve('selected_pane_num');}
ClientCache.Save("g_ReusePane",paneNumber);ClientCache.Save("g_Table","fab_table"+paneNumber);ClientCache.Save("g_Summary","fab_summary"+paneNumber);ClientCache.Save("g_Goto","fab_goto"+paneNumber);ClientCache.Save("g_Goto_top","fab_goto_top"+paneNumber);ClientCache.Save("g_FullBus","fab_full"+paneNumber);if(pinShapeLayer!=null)
{pinShapeLayer.DeleteAllShapes();}
if(!g_sResult)
{keyword=g_sResult.Keyword;location=g_sResult.Location;}
var qString="?keyword="+keyword+"&location="+location+"&pageNum="+pageNum+"&txtMode="+keyOrBus+"&newSearch=0";if((keyOrBus=='bus')&&location.isSimpleSearchCity())qString+="&rci="+location.cleanse();var spec=ClientCache.Retrieve("LatLongSpecified");if(spec&&spec=="true")
{qString+="&lat="+ClientCache.Retrieve("Latitude")+"&lon="+ClientCache.Retrieve("Longitude")+"&confidence="+ClientCache.Retrieve("Confidence");}
if(isFrench())
{qString+="&language=FR";}
qString+="&perPage=10";qStringCache=qString;var request=new AjaxRequest("Handlers/YPSearch.ashx"+qString,ProcessResult);request.Execute();}
function ProcessResult(rText)
{try{YPSearchManager.ClearFind();g_sResult=eval('('+rText+')');if(g_sResult!=null&&g_sResult.CurrentPage==1)
{var locationSearched=((ClientCache.Retrieve('lastSearch')=='bus')?document.getElementById('txtBusLocation').value:document.getElementById('txtPersonLocation').value);hbxSearch('business',g_sResult.BusinessList.length,g_sResult.Keyword,locationSearched);}
ClientCache.Save('resultPageNum',g_sResult.CurrentPage);UpdateSummaryHeading();UpdateSummaryNav("g_Goto");UpdateSummaryNav("g_Goto_top");var fullTable=document.getElementById(ClientCache.Retrieve("g_FullTable"));var shortTable=document.getElementById(ClientCache.Retrieve("g_ShortTable"));if(fullTable!=null)
{var tblBody=fullTable.tBodies?fullTable.tBodies[0]:0;if(!tblBody)
{tblBody=document.createElement("TBODY");fullTable.appendChild(tblBody);}
var shortTblBody=null;if(shortTable!=null)
{shortTblBody=shortTable.tBodies?shortTable.tBodies[0]:0;if(!shortTblBody)
{shortTblBody=document.createElement("TBODY");shortTable.appendChild(shortTblBody);}
ShowDualResults(g_showDualResults);}
var rowSize=fullTable.rows.length;for(var x=rowSize-1;x>=0;x--)
{fullTable.deleteRow(x);}
if(shortTable!=null)
{rowSize=shortTable.rows.length;for(var x=rowSize-1;x>=0;x--)
{shortTable.deleteRow(x);}}}
InfoBoxManager.ClearDescriptions('Listing');for(var x=g_sResult.BusinessList.length-1;x>=0;x--){AddListingPinToMap(g_sResult.BusinessList[x]);}
if(g_showDualResults)
{for(var x=0;x<g_sResult.BusinessList.length&&x<dualResultShortTableSize;x++)
{var newRow=shortTblBody.insertRow(-1);PopulateListing(newRow,g_sResult.BusinessList[x],x);}}
if(fullTable!=null){var listingForRecommend=null;for(var x=0;x<g_sResult.BusinessList.length;x++){var newRow=tblBody.insertRow(-1);var currentBus=g_sResult.BusinessList[x];PopulateListing(newRow,currentBus,x);if(listingForRecommend==null&&currentBus.DistanceSpecified){listingForRecommend=currentBus;}}}
g_navMap=true;if(g_navMap){if(g_sResult.ListingTotal==1)
{m_CenterListing(1);}
else
{var locations=new Array();for(var y=0;y<g_sResult.BusinessList.length;y++)
{var business=g_sResult.BusinessList[y];if(business.GeoCodeSpecified)
{locations.push(new VELatLong(business.Latitude,business.Longitude));}}
if(locations.length>0){mapManager.Map.SetMapView(locations);}}}
var panel=document.getElementById('content'+ClientCache.Retrieve("g_ReusePane"));panel.scrollTop=0;POIManager.RefreshPOIs();mapManager.resizeLeftDiv();AjaxControlManager.OpenCloseLeftNavAccordion();searchingLock=null;HideLoading();return;}
catch(e)
{}}
function ShowDualResults(showDual)
{var summary=document.getElementById(ClientCache.Retrieve("g_Summary"));var fullBus=document.getElementById(ClientCache.Retrieve("g_FullBus"));var shortBus=document.getElementById(ClientCache.Retrieve("g_ShortBus"));var gotoDiv=document.getElementById(ClientCache.Retrieve("g_Goto"));var gotoTopDiv=document.getElementById(ClientCache.Retrieve("g_Goto_top"));var locations=document.getElementById(ClientCache.Retrieve("g_Locations"));var dual=document.getElementById(ClientCache.Retrieve("g_Dual"));var dualControl=document.getElementById(ClientCache.Retrieve("g_DualControl"));fullBus.style.display=(showDual?'none':'');gotoDiv.style.display=(showDual?'none':'');gotoTopDiv.style.display=(showDual?'none':'');summary.style.display=(showDual?'none':'');dual.style.display='';shortBus.style.display=(showDual?'':'none');locations.style.display=(showDual?'':'none');dualControl.style.display=(showDual?'':'none');}
function UpdateSummaryHeading(){var summary=document.getElementById(ClientCache.Retrieve("g_Summary"));if(summary==null)return;var prevCount=summary.childNodes.length;for(var x=prevCount-1;x>=0;x--)
{summary.removeChild(summary.childNodes[x]);}
var pNode=document.createElement('div');pNode.style.marginLeft='15px';var locn=ClientCache.Retrieve('pane_'+paneNumber+'_LocationInput');if(locn==undefined){var locationBox=((ClientCache.Retrieve('lastSearch')=='bus')?document.getElementById('txtBusLocation'):document.getElementById('txtPersonLocation'));locn=locationBox==null?g_sResult.Location:locationBox.value;}
if(g_sResult.ListingTotal==0)
{var noResultText="";if(mapManager.GetIsCategorySearch()!=undefined&&mapManager.GetIsCategorySearch()){noResultText=String.format(resourceElementNoResultsCategory,g_sResult.Keyword,locn);mapManager.SetCategorySearch(false);}
else{noResultText=String.format(resourceElementNoResults,g_sResult.Keyword,locn);}
var element=document.createElement("span");element.innerHTML=noResultText;pNode.appendChild(element);summary.style.color="red";summary.style.fontWeight="bold";summary.style.fontSize="12px";summary.appendChild(pNode);ClientCache.Save('lastSearchFailed','true');return;}
summary.style.color="";summary.style.fontWeight="";summary.style.fontSize="";pNode.appendChild(document.createTextNode(resourceResultsFor+' '));var keyNode=document.createElement('strong');var keyn=ClientCache.Retrieve('pane_'+paneNumber+'_NameInput');if(keyn==undefined)
keyn==g_sResult.Keyword
keyNode.appendChild(document.createTextNode(keyn));pNode.appendChild(keyNode);pNode.appendChild(document.createTextNode(' '+resourceNear+' '));var locNode=document.createElement('strong');locNode.appendChild(document.createTextNode(locn));pNode.appendChild(locNode);pNode.appendChild(document.createTextNode(' :'));summary.appendChild(pNode);pNode=document.createElement('div');pNode.style.marginLeft='15px';pNode.appendChild(document.createTextNode(g_sResult.FirstListing+' - '+g_sResult.LastListing+' '+resourceOf+' '+g_sResult.ListingTotal));summary.appendChild(pNode);}
function UpdateSummaryNav(key)
{var summary=document.getElementById(ClientCache.Retrieve(key));if(summary==null)return;var reusePaneNumber=ClientCache.Retrieve("g_ReusePane");var prevCount=summary.childNodes.length;for(var x=prevCount-1;x>=0;x--)
{summary.removeChild(summary.childNodes[x]);}
if(g_sResult.ListingTotal==0)
{return;}
summary.appendChild(document.createTextNode(resourceGoToPage+" : "));var curPage=g_sResult.CurrentPage;var totPage=g_sResult.PageCount;var smaller=false;var greater=false;var halfRange=2;var lowRange=(curPage-halfRange>0)?curPage-halfRange:1;var highRange=(curPage+halfRange>totPage)?totPage:curPage+halfRange;if(curPage-lowRange<halfRange){highRange=highRange+(halfRange-curPage+lowRange);highRange=(highRange>totPage)?totPage:highRange;}
if(highRange-curPage<halfRange){lowRange=lowRange-(halfRange-highRange+curPage);lowRange=(lowRange<1)?1:lowRange;}
for(var x=1;x<=totPage;x++)
{if((x<lowRange||x>highRange)&&(x!=1&&x!=totPage)){if(x<curPage)
{if(!smaller)
{summary.appendChild(document.createTextNode('... '));}
smaller=true;continue;}else if(x>curPage)
{if(!greater){summary.appendChild(document.createTextNode('... '));}
greater=true;continue;}}
var node;if(x==curPage){node=document.createElement('strong');node.appendChild(document.createTextNode(x));summary.appendChild(node);summary.appendChild(document.createTextNode(' '));continue;}
node=document.createElement('span');node.className='listingunderlined';node.onclick=new Function('YPSearchManager.ReSearch('+x+','+reusePaneNumber+');');node.appendChild(document.createTextNode(x));summary.appendChild(node);summary.appendChild(document.createTextNode(' '));}
if(totPage>1&&curPage!=totPage)
{node=document.createElement('span');node.className='listingunderlined';node.onclick=new Function('YPSearchManager.ReSearch('+(curPage+1)+','+reusePaneNumber+');');node.appendChild(document.createTextNode(resourceNext+' >'));summary.appendChild(node);}}
function PopulateListing(newRow,currentListing,index)
{var newCell0=newRow.insertCell(0);newCell0.className='listingbackground';if(index==0)
{newCell0.style.background='';}
var cellDiv=document.createElement('div');newCell0.appendChild(cellDiv);var dart=document.createElement('div');dart.className='dartweb handicon';cellDiv.appendChild(dart);if(!currentListing.GeoCodeSpecified)
{dart.className='FloatLeft';}
else
{var dartIndex=document.createElement('div');var listIndex=currentListing.Index;if(listIndex<10){dartIndex.className='pinIndex_single';}else if(listIndex<100){dartIndex.className='pinIndex_double';}else{dartIndex.className='pinIndex_triple';}
dartIndex.appendChild(document.createTextNode(listIndex));dart.appendChild(dartIndex);}
if(currentListing.DistanceSpecified)
{var distanceNode=document.createElement('div');distanceNode.className='distance';distanceNode.appendChild(document.createTextNode(currentListing.Distance+' km'));dart.appendChild(distanceNode);}
var contentNode=document.createElement('div');contentNode.className='listingcontent';var pNode=document.createElement('div');contentNode.appendChild(pNode);var spanNode=document.createElement('span');if(currentListing.GeoCodeSpecified)
{spanNode.className='listingtitle';}
spanNode.onclick=new Function('YPSearchManager.CenterListing('+currentListing.Index+');');spanNode.appendChild(document.createTextNode(currentListing.Name));dart.onclick=new Function('YPSearchManager.CenterListing('+currentListing.Index+');');pNode.appendChild(spanNode);pNode.appendChild(document.createElement('br'));pNode.appendChild(document.createTextNode(currentListing.Phone));var aNode=document.createElement('div');aNode.innerHTML=currentListing.AddressHtml;pNode.appendChild(aNode);cellDiv.appendChild(contentNode);}
function AddListingPinToMap(currentListing)
{if(!currentListing.GeoCodeSpecified)
{return;}
var yellowDart=true;var divHeight=(yellowDart?"318px":"170px");var topMargin=(yellowDart?"15px":"8px");var listingType=((currentListing.ListingDetails.search('www.canada411.ca')>0)?'per':'bus');var description='<div style="height: '+divHeight+';margin-top:'+topMargin+';">';description+='<div class="popupTop">';description+='<div class="popupTopLeft">';var latLong=new VELatLong(currentListing.Latitude,currentListing.Longitude);var shape=new VEShape(VEShapeType.Pushpin,latLong);if(currentListing.WebURL.length>0)
{description+='<div style="font-weight: bold; font: 12px/14px Arial;">';description+='<a href="'+currentListing.WebURL+'">'+currentListing.Name+'</a>';description+='</div>';}else
{description+='<div style="font-weight: bold; font: 12px/14px Arial;">';description+='<strong>'+currentListing.Name+'</strong>';description+='</div>';}
description+=currentListing.AddressHtml;description+='<br />';description+=currentListing.Phone;if(yellowDart&&currentListing.HSText!=null&&currentListing.HSText[0]!="")
{description+='<div class="separator" style="margin-top:3px;"></div>';description+='<div>';for(var y=0;y<currentListing.HSText.length;y++)
{description+='<br />';description+=currentListing.HSText[y];}
description+='</div>';}
description+='<div class="separator" style="margin-top:3px;"></div>';if(listingType=='per'){var openURL=(CurrentLanguage=='fr')?'www.canada411.ca':'www.canada411.ca';description+='<div style="margin-top:8px; cursor:pointer; font-weight:bolder;" class="listingunderlined" onclick="YPSearchManager.OpenURL(\''+currentListing.ListingDetails+'\'); ">';description+='<img src="Images/YPLogo.gif" align="left"></img>';description+='<strong>'+resourceC411SeeMore+'</strong>';}
else{var openURL=(CurrentLanguage=='fr')?'pagesjaunes.ca':'www.yellowpages.ca';description+='<div style="margin-top:8px; cursor:pointer; font-weight:bolder;" class="listingunderlined" onclick="YPSearchManager.OpenURL(\'http:\/\/'+openURL+currentListing.ListingDetails+'\'); ">';description+='<img src="Images/YPLogo.gif" align="left"></img>';description+='<strong>'+resourceSeeMore+'</strong>';}
description+='</div>';description+='</div>';description+='<div class="popupTopRight">';if(yellowDart)
{if(currentListing.ThumbnailURLs.length>0&&currentListing.ThumbnailURLs[0].length>0)
{description+='<div class="popupThumbnail"><img alt="'+resourceSeeMore+'" src="'+currentListing.ThumbnailURLs[0]+' " onclick="YPSearchManager.OpenURL(\'http:\/\/'+openURL+currentListing.ListingDetails+'\'); "> </img></div>';}}
description+='<div id=\"A_ACTION_'+currentListing.Index+'\" class="popupActionArea" style="top: '+(yellowDart?'120px':'10px')+';">';description+='<div id=\"A_EMPTY_'+currentListing.Index+'\" style="height:130px; width:100px;"></div>';description+='<div id=\"A_TO_'+currentListing.Index+'\" style="height:130px;display:none;"><div class="popupHeader"><strong>'+resourceDD+':</strong></div><br/>';description+='<div>'+resourceToHere+':</div>';description+='<input type="text" id="toAddress'+currentListing.Index+'" style="width:158px;" onkeydown="ExecuteFindFromInput(\'imgTo'+(currentListing.Index)+'\', event);"/><br/>';description+='<div><img id="imgTo'+(currentListing.Index)+'" src="'+images+'GetDD.gif" class="popupLink" style="left:100px; float: right;" onclick="YPSearchManager.GDDForListingPopup(\'TO\', '+(currentListing.Index)+');" /></div>';description+='</div>';description+='<div id=\"A_FROM_'+currentListing.Index+'\" style="height:130px;display:none;"><div class="popupHeader"><strong>'+resourceDD+': </strong></div><br/>';description+='<div>'+resourceFromHere+':</div>';description+='<input type="text" id="fromAddress'+currentListing.Index+'" style="width:158px;" onkeydown="ExecuteFindFromInput(\'imgFrom'+(currentListing.Index)+'\', event);"/><br/>';description+='<div><img id="imgFrom'+(currentListing.Index)+'" src="'+images+'GetDD.gif" class="popupLink" style="left:100px; float: right;" onclick="YPSearchManager.GDDForListingPopup(\'FROM\', '+(currentListing.Index)+');"/></div>';description+='</div>';description+='<div id=\"A_NEAR_'+currentListing.Index+'\" style="height:130px;display:none;"><div class="popupHeader"><strong>'+resourceWhatsNearby+': </strong></div><br/>';description+='<div class="popupSubheader">'+resourceSearchForCategory+':<br/></div>';description+='<input type="text" id="nearby'+currentListing.Index+'" style="width:158px;" onkeydown="ExecuteFindFromInput(\'imgNear'+(currentListing.Index)+'\', event);"/><br/>';description+='<div style="float:left; width:110px">'+resourceWhatsNearbyExample+'</div>';description+='<div><img id="imgNear'+(currentListing.Index)+'" src="'+images+'GetDD.gif" class="popupLink" style="left:100px; float: right; margin-top:11px; " onclick="YPSearchManager.GNBForListingPopup('+(currentListing.Index)+',\''+currentListing.Name+'\',\''+currentListing.Address+'\',\''+currentListing.Phone+'\');"/></div>';description+='</div>';var dartImg=(yellowDart?"dartweb.gif":"dartwebwhitegrey.gif");description+='<div id=\"A_MAP_'+currentListing.Index+'\" style="height:130px;display:none;">';description+='<div id=\"A_MAP_SAVE_'+currentListing.Index+'\" style="display:none;">';description+='<div style="float:left;">';description+='<div class="popupHeader" style="width:110px"><strong>'+resourceSaveToAMap+': </strong></div><br />';description+='<div style="width:110px">'+resourceSaveToAMapPrompt+'</div>';description+='</div>';description+='<div><img src="Images/'+dartImg+'" class="popupLink" style="margin-right:10px; margin-top:10px; float: right; border: 1px solid black;" /></div>';description+='<div style="margin-top:10px;">';description+='<select id="mapSelect" style="width:158px;">';description+='</select><br/>';description+='<div><img id="imgAdd'+(currentListing.Index)+'" src="'+images+'doneButton.gif" class="popupLink" style="left:100px; float: right;" onclick="YPSearchManager.SaveListingToCustomMap('+(currentListing.Index)+');"/></div>';description+='</div>';description+='</div>';description+='<div id=\"A_MAP_WARN_'+currentListing.Index+'\" style="float:left;display:none">';description+='<div class="popupHeader" style="width:110px"><strong>'+resourceSaveToAMap+': </strong></div><br />';description+='<div style="width:180px">'+resourceLoginNeeded+'</div>';description+='</div>';description+='</div>';description+='</div>';description+='</div>';description+='</div>';description+='<div class="popupBottom">';description+='<table>';description+='<td><img src="images/drivingicon.gif" align="left" style="margin-right:3px;margin-left:3px"></img></td>';description+='<td>'+resourceDD.toUpperCase();description+='<div></div><span class="popupLink popupDrivingFunctionTo" onclick="YPSearchManager.ShowActionDiv(\'A_\', '+(currentListing.Index)+', \'FROM\');"><img src="images/tohereicon.gif"><span>'+resourceToHere.toUpperCase()+'</span></img></span> | ';description+='<span class="popupLink popupDrivingFunctionFrom" onclick="YPSearchManager.ShowActionDiv(\'A_\', '+(currentListing.Index)+', \'TO\');"><img src="images/fromhereicon.gif"><span>'+resourceFromHere.toUpperCase()+'</span></img></span>';description+='</td>';description+='<td style="width:60px;margin-right:3px;"><span class="popupLink" onclick="YPSearchManager.ShowActionDiv(\'A_\', '+(currentListing.Index)+', \'NEAR\');"><img src="images/nearbyicon.gif" align="left" style="margin-right:3px"></img>';description+='<span class="popupLink">'+resourceWhatsNearby.toUpperCase()+'</div></span></td>';description+='<td style="margin-right:3px; width:70px;"><span class="popupLink" onclick="YPSearchManager.ShowActionDiv(\'A_\', '+(currentListing.Index)+', \'MAP\');"><img src="images/savemapicon.gif" align="left" style="margin-right:3px;margin-left:3px"></img>';description+=resourceAddToAMap.toUpperCase()+'</span></td>';description+='</tr></table>';description+='</div>';description+='</div>';description=(yellowDart?'(B)':'(S)')+description;var key=InfoBoxManager.StoreDescription('Listing',currentListing.Index,description);shape.SetDescription(key);var cIndex=currentListing.Index;var txtStyle='triple';if(cIndex<10)
{txtStyle='single';}
else if(cIndex<100)
{txtStyle='double';}
shape.SetCustomIcon("<div class="+(browserManager.BrowserName=='msie'&&browserManager.BrowserVersion<7.0?'pin_yellow_ie6':'pin_yellow')+"><div class='"+txtStyle+"'>"+(cIndex)+"</div></div>");if(!yellowDart)
{shape.SetCustomIcon("<div class='pin_white'><div class='"+txtStyle+"'>"+(cIndex)+"</div></div>");}
mapManager.Map.AddShape(shape);g_listingShapeMap[cIndex]=shape.GetID();}
function AddLocationPinToMap(index,location,latitude,longitude,businessSearch)
{location=location.replace(/ \[(.)*\]/,"");printManager.setPrintPage("singleLocation",location);if(businessSearch==undefined||!businessSearch)
{document.getElementById(ClientCache.Retrieve("g_Dual")).style.display="block";document.getElementById(ClientCache.Retrieve("g_Summary")).style.display="none";document.getElementById(ClientCache.Retrieve("g_ShortBus")).style.display="none";document.getElementById(ClientCache.Retrieve("g_Locations")).style.display="none";document.getElementById(ClientCache.Retrieve("g_DualControl")).style.display="none";document.getElementById(ClientCache.Retrieve("g_Goto")).style.display="none";document.getElementById(ClientCache.Retrieve("g_Goto_top")).style.display="none";document.getElementById(ClientCache.Retrieve("g_LocationResult")).innerHTML="<div class='DefaultLocation'>"+"<img src='Images/dartblue.gif' style='margin-top:15px; margin-left:15px;' />"+"<span class='Arial12' style='margin-left:6px'>"+location+"</span></div>";}
var shape=new VEShape(VEShapeType.Pushpin,new VELatLong(latitude,longitude));var divHeight="170px";var topMargin="8px";var description='<div style="height: '+divHeight+';margin-top:'+topMargin+';">';description+='<div class="popupTop">';description+='<div class="popupTopLeft">';description+='<div style="display:block; margin-top:5px; margin-bottom:5px;"><img src="Images/dartblue.gif"></img></div>';description+='<div style="font-weight: bold; font: 12px/14px Arial;">';if(YPSearchManager.isGNBForListingPopup==true&&!(businessSearch==undefined||!businessSearch))
{if(pinShapeLayer!=null)
{pinShapeLayer.DeleteAllShapes();}
description+='<strong>'+GlobalListing.name+'</strong>'+"<br/>"+GlobalListing.address+"<br/>"+GlobalListing.phone;}
else
{description+='<strong>'+location+'</strong>';}
YPSearchManager.isGNBForListingPopup=false;description+='</div>';description+='</div>';description+='<div class="popupTopRight">';description+='<div id=\"AL_ACTION_'+index+'\" class="popupActionArea" style="top:10px;">';description+='<div id=\"AL_EMPTY_'+index+'\" style="height:130px; width:100px;"></div>';description+='<div id=\"AL_TO_'+index+'\" style="height:130px; display:none; margin-left:5px;"><div class="popupHeader"><strong>'+resourceDD+':</strong></div><br/>';description+='<div><img src="Images/tohereicon.gif">'+resourceToHere+':</img></div>';description+='<input type="text" id="l_toAddress'+index+'" style="width:158px;" onkeydown="ExecuteFindFromInput(\'l_imgTo'+(index)+'\', event);"/><br/>';description+='<div class="popupLink" onclick="YPSearchManager.ShowActionDiv(\'AL_\', '+index+', \'FROM\');">'+resourceFromHere+'<img src="images/fromhereicon.gif"></div>';description+='<div><img id="l_imgTo'+index+'" src="'+images+'GetDD.gif" class="popupLink" style="left:100px; float: right;" onclick="YPSearchManager.GDDForLocationPopup(\'TO\', '+(index)+');" /></div>';description+='</div>';description+='<div id=\"AL_FROM_'+index+'\" style="height:130px; display:none; margin-left:5px;"><div class="popupHeader"><strong>'+resourceDD+': </strong></div><br/>';description+='<div><img src="Images/fromhereicon.gif">'+resourceFromHere+':</img></div>';description+='<input type="text" id="l_fromAddress'+index+'" style="width:158px;" onkeydown="ExecuteFindFromInput(\'l_imgFrom'+(index)+'\', event);"/><br/>';description+='<div class="popupLink" onclick="YPSearchManager.ShowActionDiv(\'AL_\', '+(index)+', \'TO\');">'+resourceToHere+'<img src="images/tohereicon.gif"></div>';description+='<div><img id="l_imgFrom'+(index)+'" src="'+images+'GetDD.gif" class="popupLink" style="left:100px; float: right;" onclick="YPSearchManager.GDDForLocationPopup(\'FROM\', '+(index)+');"/></div>';description+='</div>';description+='<div id=\"AL_NEAR_'+index+'\" style="height:130px;display:none;"><div class="popupHeader"><strong>'+resourceWhatsNearby+': </strong></div><br/>';description+='<div class="popupSubheader">'+resourceSearchForCategory+':<br/></div>';description+='<input type="text" id="l_nearby'+index+'" style="width:158px;" onkeydown="ExecuteFindFromInput(\'l_imgNear'+(index)+'\', event);"/><br/>';description+='<div style="float:left; width:110px">'+resourceWhatsNearbyExample+'</div>';description+='<div><img id="l_imgNear'+(index)+'" src="'+images+'GetDD.gif" class="popupLink" style="margin-top:11px; left:100px; float: right;" onclick="YPSearchManager.GNBForLocationPopup('+(index)+');"/></div>';description+='</div>';var dartImg="dartblue.gif";description+='<div id=\"AL_MAP_'+index+'\" style="height:130px;display:none;">';description+='<div id=\"AL_MAP_SAVE_'+index+'\" style="display:none">';description+='<div style="float:left;">';description+='<div class="popupHeader" style="width:110px"><strong>'+resourceSaveToAMap+': </strong></div><br />';description+='<div style="width:110px">'+resourceSaveToAMapPrompt+'</div>';description+='</div>';description+='<div><img src="Images/'+dartImg+'" class="popupLink" style="margin-right:10px; margin-top:10px; float: right; border: 1px solid black;" /></div>';description+='<div style="margin-top:10px;">';description+='<select id="mapSelect" style="width:158px;"">';description+='</select><br/></div>';description+='<div><img id="l_imgAdd'+(index)+'" src="'+images+'doneButton.gif" class="popupLink" style="left:100px; float: right;" onclick="YPSearchManager.SaveLocationToCustomMap('+(index)+');"/></div>';description+='</div>';description+='<div id=\"AL_MAP_WARN_'+index+'\" style="float:left;display:none">';description+='<div class="popupHeader" style="width:110px"><strong>'+resourceSaveToAMap+': </strong></div><br />';description+='<div style="width:180px">'+resourceLoginNeeded+'</div>';description+='</div>';description+='</div>';description+='</div>';description+='</div>';description+='</div>';description+='<div class="popupBottom">';description+='<table>';description+='<tr><td><table><td><img src="images/drivingicon.gif" align="left" style="margin-right:3px;margin-left:3px"></img></td>';description+='<td>'+resourceDD.toUpperCase();description+='<div></div><span class="popupLink popupDrivingFunctionTo" onclick="YPSearchManager.ShowActionDiv(\'AL_\', '+(index)+', \'TO\');"><img src="images/tohereicon.gif"><span>'+resourceToHere.toUpperCase()+' | </span></img></span>';description+='<span class="popupLink popupDrivingFunctionFrom" onclick="YPSearchManager.ShowActionDiv(\'AL_\', '+(index)+', \'FROM\');"><img src="images/fromhereicon.gif"><span>'+resourceFromHere.toUpperCase()+'</span></img></span>';description+='</td>';description+='<td style="width:60px;margin-right:3px;"><span class="popupLink" onclick="YPSearchManager.ShowActionDiv(\'AL_\', '+(index)+', \'NEAR\');"><img src="images/nearbyicon.gif" align="left" style="margin-right:3px"></img>';description+='<span class="popupLink" style="padding-left:3px">'+resourceWhatsNearby.toUpperCase()+'</div></span></td>';description+='<td style="margin-right:3px; width:70px;"><span class="popupLink" onclick="YPSearchManager.ShowActionDiv(\'AL_\', '+(index)+', \'MAP\');"><img src="images/savemapicon.gif" align="left" style="margin-right:3px;margin-left:3px"></img>';description+=resourceAddToAMap.toUpperCase()+'</span></td>';description+='</tr></table>';description+='</div>';description+='</div>';description='(S)'+description;var key=InfoBoxManager.StoreDescription('Location',index,description);shape.SetDescription(key);shape.SetCustomIcon("<div class='pin_blue'></div>");mapManager.Map.AddShape(shape);mapManager.Map.SetCenter(new VELatLong(latitude,longitude));return shape;}
function m_CenterListing(listingIndex){if(!g_listingShapeMap)
{return;}
if(!g_listingShapeMap[listingIndex])
{return;}
var shape=mapManager.Map.GetShapeByID(g_listingShapeMap[listingIndex]);if(!shape)
{return;}
POIManager.HidePOIs();mapManager.Map.SetCenterAndZoom(shape.GetPoints()[0],14);mapManager.Map.SetCenterAndZoom(shape.GetPoints()[0],5);mapManager.Map.SetCenterAndZoom(shape.GetPoints()[0],14);POIManager.RefreshPOIs();HideCurrentEro(null);YPSearchManager.ShowPopup(g_listingShapeMap[listingIndex]);}
function m_ShowPopup(shapeID)
{activeEro=new PushpinERO(shapeID,mapManager.Map);activeEro.Show();}
this.CreateSearchQuery=function(searchType,what,where,latLong,origin,destination)
{return new SearchQuery(searchType,what,where,latLong,origin,destination);}
function SearchQuery(searchType,what,where,latLong,origin,destination)
{this.SearchType=searchType;this.What=what;this.Where=where;this.LatLong=latLong;this.Origin=origin;this.Destination=destination;this.Parse=function(input)
{if(input==null)
{return;}
var delimiter='|';var fields=input.split('|');if(fields.length==7)
{this.SearchType=(fields[0]!=null?fields[0]:null);this.What=(fields[1]!=null&&fields[1]!=''?fields[1]:null);this.Where=(fields[2]!=null&&fields[2]!=''?fields[2]:null);this.LatLong=(fields[3]!=null&&fields[3]!=''&&fields[4]!=null&&fields[4]!=''?new VELatLong(fields[3],fields[4]):null);this.Origin=(fields[5]!=null&&fields[5]!=''?fields[5]:null);this.Destination=(fields[6]!=null&&fields[6]!=''?fields[6]:null);}}
this.ToString=function()
{var output='';output+=this.SearchType!=null?this.SearchType:'';output+='|'+(this.What!=null?this.What:'');output+='|'+(this.Where!=null?this.Where:'');output+='|'+(this.LatLong!=null?this.LatLong.Latitude+'|'+this.LatLong.Longitude:'|');output+='|'+(this.Origin!=null?this.Origin:'');output+='|'+(this.Destination!=null?this.Destination:'');return output;}}
this.PersistQuery=function(searchQuery,type){if(searchQuery==null){return;}
var lifeTime=366;var dateTime=new Date();dateTime.setTime(dateTime.getTime()+(lifeTime*24*60*60*1000));var queriesCount=5;var pastQueries=m_RetrieveQueries(type);var contents=searchQuery.ToString();if(pastQueries.length>0){var currentQueries=new Array();for(var i=0;i<pastQueries.length;i++){if(pastQueries[i].ToString().toLowerCase()!=contents.toLowerCase()&&i<queriesCount-1){currentQueries.push(pastQueries[i]);}}
pastQueries=currentQueries;}
for(var i=0;i<pastQueries.length;i++){contents+=(i<=pastQueries.length-1)?'[':'';contents+=pastQueries[i].ToString();}
ClientCache.setClientCookie('search'+type+'Cookie',contents,dateTime,'/');}
function m_RetrieveQueries(type)
{if(type==null)
{return;}
var queries=new Array();var contents=ClientCache.getClientCookieByName('search'+type+'Cookie');if(contents!=null)
{var queriesData=contents.split('[');for(var i=0;i<queriesData.length;i++)
{var query=new SearchQuery();query.Parse(queriesData[i]);if(query.What!=null||(type!='bus'&&type!='per'))
queries.push(query);}}
return queries;}
function isFrench()
{var qString=window.location.search.substring(1);var parts=qString.split("&");for(i=0;i<parts.length;i++){ft=parts[i].split("=");if(ft[0]=='lang'&&ft[1]=='fr'){return true;}}
return false;}
function OpenURL(url)
{window.open(url,'mywindow','width=800,height=600,toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');}
this.EmulateMapFind=function(searchText,paneClicked)
{findMapResultsPaneNumber=paneClicked;document.getElementById('txtFind').value=searchText;mapManager.FindLookup(true);}
this.ClearFind=function(){mapManager.ClearFind();if((pinShapeLayer!=null)&&(this.isGNBForListingPopup==false))
{pinShapeLayer.DeleteAllShapes();}}
function ShowActionDiv(prefix,listingIndex,divId){if(divId=='TO')
{document.getElementById(prefix+'EMPTY_'+listingIndex).style.display='none';document.getElementById(prefix+'FROM_'+listingIndex).style.display='none';document.getElementById(prefix+'NEAR_'+listingIndex).style.display='none';document.getElementById(prefix+'MAP_'+listingIndex).style.display='none';document.getElementById(prefix+'TO_'+listingIndex).style.display='';}
else if(divId=='FROM'){document.getElementById(prefix+'EMPTY_'+listingIndex).style.display='none';document.getElementById(prefix+'TO_'+listingIndex).style.display='none';document.getElementById(prefix+'NEAR_'+listingIndex).style.display='none';document.getElementById(prefix+'MAP_'+listingIndex).style.display='none';document.getElementById(prefix+'FROM_'+listingIndex).style.display='';}
else if(divId=='NEAR')
{document.getElementById(prefix+'EMPTY_'+listingIndex).style.display='none';document.getElementById(prefix+'TO_'+listingIndex).style.display='none';document.getElementById(prefix+'FROM_'+listingIndex).style.display='none';document.getElementById(prefix+'MAP_'+listingIndex).style.display='none';document.getElementById(prefix+'NEAR_'+listingIndex).style.display='';}
else if(divId=='MAP')
{document.getElementById(prefix+'EMPTY_'+listingIndex).style.display='none';document.getElementById(prefix+'TO_'+listingIndex).style.display='none';document.getElementById(prefix+'FROM_'+listingIndex).style.display='none';document.getElementById(prefix+'NEAR_'+listingIndex).style.display='none';document.getElementById(prefix+'MAP_'+listingIndex).style.display='';var HiddenUserId=document.getElementById("HiddenUserId");if(HiddenUserId.value==null||HiddenUserId.value=='')
{document.getElementById(prefix+'MAP_WARN_'+listingIndex).style.display='';document.getElementById(prefix+'MAP_SAVE_'+listingIndex).style.display='none';}
else
{document.getElementById(prefix+'MAP_WARN_'+listingIndex).style.display='none';document.getElementById(prefix+'MAP_SAVE_'+listingIndex).style.display='';PersistenceManager.LoadUserMaps(PopulateMapSelect);}}}
function PopulateMapSelect(responseText)
{try
{var mapSelector=document.getElementById('mapSelect');var prevCount=mapSelector.childNodes.length;for(var x=prevCount-1;x>=1;x--)
{mapSelector.removeChild(mapSelector.childNodes[x]);}
var mapList=eval('('+responseText+')');if(mapList!=undefined&&mapList.DataList!=null)
{for(var x=0;x<mapList.DataList.length;x++)
{var newOption=new Option(mapList.DataList[x].Title,mapList.DataList[x].MapID);mapSelector.options[x]=newOption;}}}
catch(e)
{}}
function GDDForListingPopup(mode,index)
{var startAddress;var endAddress;var currentListing=g_sResult.BusinessList[index-g_sResult.FirstListing];if(mode=='TO')
{startAddress=document.getElementById('toAddress'+index).value;endAddress=currentListing.Address+"@"+currentListing.Latitude+","+currentListing.Longitude;if(startAddress.trim()=='')return;}
else
{endAddress=document.getElementById('fromAddress'+index).value;startAddress=currentListing.Address+"@"+currentListing.Latitude+","+currentListing.Longitude;if(endAddress.trim()=='')return;}
HideCurrentEro(null);TopNav('DrivingDirections');document.getElementById("txtFrom").value=startAddress;document.getElementById("txtTo").value=endAddress;mapManager.GetNewDirections(startAddress,endAddress);}
function GNBForListingPopup(index,name,address,phone)
{this.isGNBForListingPopup=true;GlobalListing.name=name;GlobalListing.address=address;GlobalListing.phone=phone;var txtNB=document.getElementById('nearby'+index).value;if(txtNB.trim()=='')
{return;}
var currentListing=g_sResult.BusinessList[index-g_sResult.FirstListing];document.getElementById('txtBusLocation').value=currentListing.Address;document.getElementById('txtBusName').value=txtNB;if(index==0)
{mapManager.NewFindBusiness(true);}
else
{mapManager.NewFindBusiness(false);}}
function GDDForLocationPopup(mode,index){index=index==null?locationIndex:index;this.isGNBForListingPopup=true;var startAddress;var endAddress;if(g_Locations.length-1<index)
{return;}
var currentLocation=g_Locations[index];if(mode=='TO'){startAddress=document.getElementById('l_toAddress'+index).value;endAddress=currentLocation.Name;if(startAddress.trim()=='')
return;}
else
{endAddress=document.getElementById('l_fromAddress'+index).value;startAddress=currentLocation.Name;if(endAddress.trim()=='')
return;}
HideCurrentEro(null);TopNav('DrivingDirections');document.getElementById("txtFrom").value=startAddress;document.getElementById("txtTo").value=endAddress;mapManager.GetNewDirections(startAddress,endAddress);this.isGNBForListingPopup=false;}
function GNBForLocationPopup(index){index=index==undefined?locationIndex:index;var txtNB=document.getElementById('l_nearby'+index).value;if(txtNB.trim()=='')
{return;}
if(g_Locations.length-1<index)
{return;}
var currentLocation=g_Locations[index];document.getElementById('txtBusLocation').value=(Math.round(currentLocation.LatLong.Latitude*100)/100)+", "+(Math.round(currentLocation.LatLong.Longitude*100)/100);document.getElementById('txtBusName').value=txtNB;if(index==0)
{mapManager.NewFindBusiness(true);}
else
{mapManager.NewFindBusiness(false);}}
function SaveListingToCustomMap(pinIndex)
{var currentListing=g_sResult.BusinessList[pinIndex-g_sResult.FirstListing];var yellowDart=(currentListing.PushpinType=='YellowDart');var dartImg=(yellowDart?"dartweb.gif":"dartwebwhitegrey.gif");var mapSelector=document.getElementById('mapSelect');var selectedMapId=mapSelector.options[mapSelector.selectedIndex].value;PersistenceManager.SaveMapLocationDetailed(selectedMapId,currentListing.Latitude,currentListing.Longitude,currentListing.Name,currentListing.Address,'Images/'+dartImg);}
function SaveLocationToCustomMap(pinIndex){pinIndex=pinIndex==undefined?locationIndex:pinIndex;var currentLocation=g_Locations[pinIndex];var mapSelector=document.getElementById('mapSelect');var selectedMapId=mapSelector.options[mapSelector.selectedIndex].value;PersistenceManager.SaveMapLocationDetailed(selectedMapId,currentLocation.LatLong.Latitude,currentLocation.LatLong.Longitude,currentLocation.Name,(currentLocation.Address==null||currentLocation.Address==undefined?'':currentLocation.Address),"Images/dartblue.gif");}}
String.prototype.removeWhitespace=function(){return this.replace(/^\s+|\s+$/g,"");}
String.prototype.containsNumbers=function(){return/\d/.test(this);}
String.prototype.removeCommas=function(){return this.replace(/,/g,"");}
String.prototype.cleanse=function(){return this.removeWhitespace().removeCommas().toLowerCase().replace(/ô/g,'o');}
String.prototype.isSimpleSearchCity=function(){if(SimpleSearchCityList==null)return false;var cleanTerm=this.cleanse();if(cleanTerm=="canada")return false;var list=SimpleSearchCityList.split(',');for(var i=0;i<list.length;i++)
{var listItem=list[i].cleanse();if(listItem==cleanTerm)return true;}
return false;}