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;this.GenerateName=GenerateName;this.GenerateAddress=GenerateAddress;this.GeneratePhone=GeneratePhone;this.GenerateImage=GenerateImage;this.GenerateDescription=GenerateDescription;this.GetMPData=GetMPData;this.ProcessFullMerchant=ProcessFullMerchant;var g_MPResult=new Object;var g_GNBSelectedData=new Object;var g_FullMPSelectedData=new Object;var g_FullMPLocationsForZoom=new Array();this.toggleLinkedSection=toggleLinkedSection;this.toggleToFromDDSection=toggleToFromDDSection;var mpShapeId;var ranGNBOnce=false;this.g_mapRadiusInPixels=null;var visitedListings=new Object();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;var tempIndex=1;var meterPerPixelAtZoom=["0","78271.52","39135.76","19567.88","9783.94","4891.97","3445.98","1222.99","611.5","305.75","152.87","76.44","38.22","19.11","9.55","4.78","2.39","1.19","0.6","0.3"];this.includePlaces=function(veplaces){g_Locations=veplaces};this.updateListingShapeMap=function(index,value){g_listingShapeMap[index]=value};this.updateFullMPLocationsForZoom=function(lat,lon){g_FullMPLocationsForZoom.push(new VELatLong(lat,lon));mapManager.Map.SetMapView(g_FullMPLocationsForZoom)};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){return;var argv=hbxSearch.arguments;var argc=hbxSearch.arguments.length;if(searchType!="business"){SetCookie("HBXinternalSearch",keyword+"^"+count+"^"+location,null,"/")}var _hbEC=0,_hbE=new Array;var ev1=_hbEvent("search");var cv=_hbEvent("cv");cv.c13=lastCV.c13;cv.c15=lastCV.c15;cv.c19=lastCV.c19;ev1.keywords=keyword!=null&&keyword!=""?_hbxStrip(keyword):null;ev1.results=count;ev1.attr1=location!=null&&location!=""?_hbxStrip(_hbxAccentStrip(location)):null;ev1.attr2="map";var catHeadings="";if(g_sResult.relevantCategories!=undefined&&g_sResult.relevantCategories!=null&&g_sResult.relevantCategories.length>0){if(debug){console.log("g_sResult.relevantCategories: ",g_sResult.relevantCategories)}catHeadings=g_sResult.relevantCategories.join("_1,")+"_1"}if(g_sResult.nonRelevantCategories!=undefined&&g_sResult.nonRelevantCategories!=null&&g_sResult.nonRelevantCategories.length>0){catHeadings+=catHeadings!=""?",":"";catHeadings+=g_sResult.nonRelevantCategories.join("_0,")+"_0"}ev1.attr3=catHeadings;if(g_sResult.directories!=undefined&&g_sResult.directories!=null&&g_sResult.directories.length>0){ev1.attr4=g_sResult.directories.join(",")}else{ev1.attr4=""}switch(searchType){case"minimerchant":ev1.attr2="mmb";cv.c5=(argc>4)?argv[4]:"";break;case"business":ev1.attr2="map";break}_hbSend()}function m_Search(keyOrBus,navMap,vePlaces){searchingLock=new Object();recommendMode=false;tempIndex=1;var businessSearch=(keyOrBus=="bus");var personSearch=(keyOrBus=="per");var sbn=(businessSearch)?(document.getElementById("cbBusOnly")!=null?document.getElementById("cbBusOnly").checked:false):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}ShowLoading();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+"_EnteredLocationInput").cleanse();var keyword=ClientCache.Retrieve("pane_"+paneNumber+"_NameInput").cleanse();if(debug){console.log("YPSM.Search: paneNumber:%s what:%s, where:%s, [entered where: %s]",paneNumber,keyword,location,ClientCache.Retrieve("pane_"+paneNumber+"_EnteredLocationInput"))}var qString="?what="+keyword+"&where="+location+"&sbn="+sbn;var vePlace=vePlaces[0];qString+="&lat="+vePlace.LatLong.Latitude+"&lon="+vePlace.LatLong.Longitude+"&confidence="+vePlace.MatchConfidence;mapManager.Map.SetCenter(new VELatLong(vePlace.LatLong.Latitude,vePlace.LatLong.Longitude));ClientCache.Save("LatLongSpecified","true");ClientCache.Save("Latitude",vePlace.LatLong.Latitude);ClientCache.Save("Longitude",vePlace.LatLong.Longitude);ClientCache.Save("Confidence",vePlace.MatchConfidence);if(this.isGNBForListingPopup){if(businessSearch){AddLocationPinToMap()}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")}var s1=mapManager.Map.LatLongToPixel(mapManager.Map.GetCenter()).y;var s2=mapManager.Map.LatLongToPixel(mapManager.Map.GetCenter()).x;if(debug){console.log("Center pixel x y ",mapManager.Map.LatLongToPixel(mapManager.Map.GetCenter()).x,mapManager.Map.LatLongToPixel(mapManager.Map.GetCenter()).y)}var s3=Math.sqrt(s1*s1+s2*s2);this.g_mapRadiusInPixels=s3;var curZoomLevel=mapManager.Map.GetZoomLevel();var mppaz=meterPerPixelAtZoom[curZoomLevel];var s3km=Math.round(s3*mppaz/1000);qString+="&dist="+s3km;if(debug){console.log("s1:%f s2:%f s3:%f s3km:%f",s1,s2,s3,s3km)}if(isFrench()){qString+="&language=FR"}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("/ajax/businesses.html"+qString,ProcessResultNew);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(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()}this.mapBranchResults=function(rText){ClientCache.Save("pane_-1_EnteredLocationInput","");ClientCache.Save("pane_-1_NameInput","");ProcessResultNew(rText)};function ProcessResultNew(rText){try{document.getElementById("txtBusLocation").value="";g_sResult=eval("("+rText+")");if(g_sResult!=null&&false==isMerchantPage){}UpdateSummaryHeading();if(g_sResult!=undefined&&g_sResult.businessList!=null){var listingAdTypeMap={Ad:100,NonAd:101};clusterManager.PoiPresent=true;var returnedShapesAds=new Array();for(var x=0;x<g_sResult.businessList.length;x++){if(isBranchSearch==true){var listingAdTypeId=102}else{var listingAdTypeId=listingAdTypeMap[g_sResult.businessList[x].pushpinType]}returnedShapesAds.push(AddListingShape(x,listingAdTypeId))}}}catch(e){if(debug){console.log("Catch Block: ProcessResultNew: %s",e.message)}}if(returnedShapesAds!=null&&returnedShapesAds.length>0){clusterManager.DeleteShapes(100);clusterManager.AddShapes(returnedShapesAds,100)}if(isBranchSearch){var locations=new Array();for(var y=0;y<g_sResult.businessList.length;y++){var business=g_sResult.businessList[y];if(business.address.location){locations.push(new VELatLong(business.address.location.latitude,business.address.location.longitude))}}if(locations.length>0){mapManager.Map.SetMapView(locations);g_FullMPLocationsForZoom=locations}}HideLoading();ClientCache.Save("zoomSearch",mapManager.Map.GetZoomLevel());if(!isBranchSearch){if(debug){console.log("In YPSM.ProcessResultNew:  Connected: %s.",mapManager.MapSearchAttachedPZ)}if(!mapManager.MapSearchAttachedPZ){if(debug){console.log("In YPSM.ProcessResultNew:  Connected: %s.  Going to connect.",mapManager.MapSearchAttachedPZ)}mapManager.AttachPanZoomEventMapSearch()}}}function AddListingShape(listingIndex,typeId){var currentListing=g_sResult.businessList[listingIndex];var pinVELatLong=new VELatLong(currentListing.address.location.latitude,currentListing.address.location.longitude);var shape=new VEShape(VEShapeType.Pushpin,pinVELatLong);if(currentListing.pushpinType=="Ad"){if(visitedListings[currentListing.listingId]==1){shape.SetCustomIcon("<div class='pin_v_wf'></div>")}else{shape.SetCustomIcon("<div class='pin_wf'></div>")}}else{if(visitedListings[currentListing.listingId]==1){shape.SetCustomIcon("<div class='pin_v_nonad'></div>")}else{shape.SetCustomIcon("<div class='pin_nonad'></div>")}}if(isBranchSearch==true){shape.SetCustomIcon("<div class='mapIcon'>"+currentListing.index+"</div>")}var imKey=InfoBoxManager.GenerateKey("imListing"+typeId,listingIndex);var description=imKey;shape.SetDescription(description+GenerateOnHoverDescription(listingIndex,typeId));return shape}function GetIcon(pushpinType,listingId){var imageExt=(browserManager.BrowserName=="msie"&&browserManager.BrowserVersion<7?".gif":".png");var imageName="";switch(pushpinType){case"Ad":if(visitedListings[listingId]==1){imageName="black"}else{imageName="y_arrow"}return imageName+imageExt;case"NonAd":if(visitedListings[listingId]==1){imageName="small_v"}else{imageName="small"}return imageName+imageExt;default:return"y_arrow"+imageExt}}function toggleLinkedSection(section,closeSection){if(section&&section!=""){var collapse=section+"Toggle";if("none"==document.getElementById(section).style.display){document.getElementById(section).style.display="block";$(collapse).addClassName("ypSmCollapse");$(collapse).removeClassName("ypSmExpand")}else{document.getElementById(section).style.display="none";$(collapse).addClassName("ypSmExpand");$(collapse).removeClassName("ypSmCollapse")}}var collapse=closeSection+"Toggle";document.getElementById(closeSection).style.display="none";$(collapse).addClassName("ypSmExpand");$(collapse).removeClassName("ypSmCollapse")}function toggleToFromDDSection(index){if(index&&index!=""){if("none"==document.getElementById("A_FROM_"+index).style.display){document.getElementById("A_FROM_"+index).style.display="block";document.getElementById("A_TO_"+index).style.display="none"}else{document.getElementById("A_FROM_"+index).style.display="none";document.getElementById("A_TO_"+index).style.display="block"}}}function GenerateDescription(listingIndex,poiType,gnbListing){if(gnbListing!=undefined&&gnbListing!=null){var mpListing=gnbListing.listing;var hbxWhat=gnbListing.what;var hbxWhere=gnbListing.where}else{var mpListing=g_MPResult.listing;var hbxWhat=g_MPResult.what;var hbxWhere=g_sResult.where}if(mpListing.merchantMapURL!=undefined&&mpListing.merchantMapURL!=null){var staticMapURL=mpListing.merchantMapURL.href}else{var staticMapURL=""}if(mpListing.categoryDirectoryList!=undefined&&mpListing.categoryDirectoryList!=null){var catDirList=mpListing.categoryDirectoryList}else{var catDirList=new Array()}var description='<div class="ypgMerchantMiniBubbleWrapper">';description+='<div class="ypgTopRoundedRow">';description+='<div class="tl"></div>';description+='<div class="tm"></div>';description+='<div class="tr"></div>';description+="</div>";description+='<div class="ypgMerchantMiniBubble">';description+='<div class="ypgMerchantMiniBubbleInner">';description+='<div class="popupLeft">';staticMapURL="http://api.tiles.virtualearth.net/api/GetMap.ashx?c="+mpListing.address.location.latitude+","+mpListing.address.location.longitude+"&w=180&h=180&b=r,shading.hill,mkt.en-US&z=15&token="+mapManager.VEtoken;description+='<div class="ypgMMBStaticMap" style="background: url('+staticMapURL+') no-repeat"></div>';description+='<div class="ypgMMBStaticMapPin"><div class="pin_selected pin_staticAdjust"></div></div>';if(isMerchantPage==false){description+='<div class="ypgMMBNB">';description+='<div class="ypgActionTitle">';description+="<a class=\"ypWhatsNearby\" href=\"#\" onclick=\"javascript:YPSearchManager.toggleLinkedSection('ypWhatsNearbyContent','ypDrivingDirectionsContent');return false;\" onmousedown=\"hbxFromExpandToggle('ypWhatsNearbyContent', 'whats_nearby', 'in_bubble');\" rel=\"nofollow\">"+resourceWhatsNearby+"</a><br/>";description+="</div>";description+='<div class="toggleWrapper">';description+="<a id=\"ypWhatsNearbyContentToggle\" class=\"ypSmExpand\" href=\"javascript:YPSearchManager.toggleLinkedSection('ypWhatsNearbyContent', 'ypDrivingDirectionsContent');\" onmousedown=\"hbxFromExpandToggle('ypWhatsNearbyContent', 'whats_nearby', 'in_bubble');\" rel=\"nofollow\">&nbsp;</a><br/>";description+="</div>";description+='<div class="clearboth"></div>';description+='<div id="ypWhatsNearbyContent" class="ypgMMBSmText" style="display:none;">';description+=resourceFind+' <input type="text" id="nearby'+listingIndex+'" style="width:120px;" onkeydown="ExecuteFindFromInput(\'imgNear'+(listingIndex)+"', event);\"/><br/>";description+='<div><img id="imgNear'+(listingIndex)+'" src="http://cdn.cb.yp.ca/ypca/rc28.111024/images/buttons/find-md-'+lang+".gif\" class=\"handicon ypgActionContentButton\" onclick=\"_hbSet('lid','search_button');_hbSet('lpos','nearby_in_bubble');_hbSend();YPSearchManager.GNBForListingPopup("+listingIndex+');"/></div>';description+='<div class="clearboth"></div>';description+="</div>";description+="</div>";description+='<div class="ypgMMBDD">';description+='<div class="ypgActionTitle">';description+="<a class=\"ypDrivingDirections\" href=\"#\" onclick=\"javascript:YPSearchManager.toggleLinkedSection('ypDrivingDirectionsContent','ypWhatsNearbyContent');return false;\" onmousedown=\"hbxFromExpandToggle('ypDrivingDirectionsContent', 'driving_directions', 'in_bubble');\" rel=\"nofollow\">"+resourceDD+"</a><br/>";description+="</div>";description+='<div class="toggleWrapper">';description+="<a id=\"ypDrivingDirectionsContentToggle\" class=\"ypSmExpand\" href=\"javascript:YPSearchManager.toggleLinkedSection('ypDrivingDirectionsContent', 'ypWhatsNearbyContent');\" onmousedown=\"hbxFromExpandToggle('ypDrivingDirectionsContent', 'driving_directions', 'in_bubble');\" rel=\"nofollow\">&nbsp;</a><br/>";description+="</div>";description+='<div class="clearboth"></div>';description+='<div id="ypDrivingDirectionsContent" class="ypgMMBSmText" style="display:none;">';description+='<div id="A_TO_'+listingIndex+'" style="display:none;">';description+='<a href="#" onclick="javascript:YPSearchManager.toggleToFromDDSection('+listingIndex+');return false;" name="&amp;lid=information&amp;lpos=in_bubble" rel="nofollow">'+resourceFrom+"</a> / "+resourceTo+"<br/>";description+='<input type="text" id="toAddress'+listingIndex+'" style="width:120px;" onkeydown="ExecuteFindFromInput(\'imgTo'+(listingIndex)+"', event);\"/><br/>";description+='<div><img id="imgTo'+(listingIndex)+'" src="http://cdn.cb.yp.ca/ypca/rc28.111024/images/buttons/find-md-'+lang+".gif\" class=\"handicon ypgActionContentButton\" onclick=\"_hbSet('lid','search_button');_hbSet('lpos','directions_in_bubble');_hbSend();YPSearchManager.GDDForListingPopup('TO', "+(listingIndex)+');" /></div>';description+='<div class="clearboth"></div>';description+="</div>";description+='<div id="A_FROM_'+listingIndex+'" style="display:block;">';description+=resourceFrom+' / <a href="#" onclick="javascript:YPSearchManager.toggleToFromDDSection('+listingIndex+');return false;" name="&amp;lid=information&amp;lpos=in_bubble" rel="nofollow">'+resourceTo+"</a><br/>";description+='<input type="text" id="fromAddress'+listingIndex+'" style="width:120px;" onkeydown="ExecuteFindFromInput(\'imgFrom'+(listingIndex)+"', event);\"/><br/>";description+='<div><img id="imgFrom'+(listingIndex)+'" src="http://cdn.cb.yp.ca/ypca/rc28.111024/images/buttons/find-md-'+lang+".gif\" class=\"handicon ypgActionContentButton\" onclick=\"_hbSet('lid','search_button');_hbSet('lpos','directions_in_bubble');_hbSend();YPSearchManager.GDDForListingPopup('FROM', "+(listingIndex)+');"/></div>';description+='<div class="clearboth"></div>';description+="</div>";description+="</div>";description+="</div>"}description+="</div>";description+='<div class="popupRight">';if(mpListing.thumbnailURL!=null){if(mpListing.thumbnailURL.href.search("Video.html")>0){description+='<div style="position: relative;">';description+='<div class="photoFrame1">';description+='<a href="'+mpListing.thumbnailURL.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|video_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('lid','video_th');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\">";description+='<img border="0" src="/images/th_frame.gif"/></a>';description+="</div>";description+='<img class="noborder" src="'+mpListing.thumbnailURL.src+'" alt="'+mpListing.thumbnailURL.alt+'"/>';description+="</div>"}else{description+='<a href="'+mpListing.thumbnailURL.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|logo_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','logo');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\"><img class=\"noborder\" src=\""+mpListing.thumbnailURL.src+'" alt="'+mpListing.thumbnailURL.alt+'"/></a>';description+="<br />"}}var clsLinkClass="";if(mpListing.presentation.nameBold&&mpListing.presentation.nameColour){clsLinkClass="elpBoldColour"}else{if(mpListing.presentation.nameBold){clsLinkClass="elpBold"}else{if(mpListing.presentation.nameColour){clsLinkClass="elpColour"}else{clsLinkClass="listingTitle"}}}description+='<a href="'+mpListing.merchantURL.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|busname_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','busname');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\"><span class=\"ypgMMBmerchantName "+clsLinkClass+'">'+mpListing.name+"</span></a><br />";if((true==isMerchantPage&&true==isMerchantNonPaidListing)||(mpListing.pushpinType=="NonAd")){description+='<div class="phoneLink">'+mpListing.phone+"</div>"}else{description+='<div class="phoneLink"><a class="ypgCallButton" href="javascript: openWin(\''+mpListing.freecallURL.href+"', '477', '405');\" class=\"freeCallLink\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|free_call_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','free_call');_hbSet('lpos','in_bubble');_hbSend();\" rel=\"nofollow\" >"+mpListing.phone+"</a></div>"}description+='<div class="ypgMMBaddress">'+mpListing.address.street+", <br/>"+mpListing.address.city+", "+mpListing.address.province+" "+mpListing.address.postalCode+"</div>";if(mpListing.hsText!=null&&mpListing.hsText!=""){description+='<div class="ypgMMBhsText">'+mpListing.hsText+"</div>"}var prodCount=0;var tProducts="",gProducts="";for(var key in mpListing.tabURLs){if(key!="map"){prodCount++}tProducts+=key+" "}if(debug){console.log("mmb: Products [TAB]: [%s]",tProducts)}for(var key in mpListing.productURLs){if(key!="eco"){prodCount++}gProducts+=key+" "}if(debug){console.log("mmb: Products [General]: [%s]",gProducts)}if(mpListing.webURL!=null){prodCount++}if(mpListing.email!=null&&mpListing.email!=""){prodCount++}if(debug){console.log("mmb: prodCount:",prodCount)}if(prodCount>0){var divider="<span> | </span>";var notFirst=false;description+='<div class="ypgMMBLinks">';if(mpListing.webURL!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.webURL.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|website_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','website');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\">"+resourceWebsite+"</a>";notFirst=true}if(mpListing.email!=null&&mpListing.email!=""){description+=(notFirst?divider:"")+'<a href="mailto:'+mpListing.email+"?subject="+resourceEmailSubject+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|email_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','email');_hbSet('lpos','in_bubble');_hbSend();\" rel=\"nofollow\">"+resourceEmail+"</a>";notFirst=true}if(mpListing.tabURLs.dspad!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.tabURLs.dspad.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|information_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','information');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\" title=\""+mpListing.tabURLs.dspad.title+'">'+mpListing.tabURLs.dspad.content+"</a>";notFirst=true}if(mpListing.tabURLs.video!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.tabURLs.video.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|video_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','camera_ico');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\">"+mpListing.tabURLs.video.content+"</a>";notFirst=true}if(mpListing.tabURLs.photos!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.tabURLs.photos.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|photos_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','photo_ico');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\">"+mpListing.tabURLs.photos.content+"</a>";notFirst=true}if(mpListing.tabURLs.promo!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.tabURLs.promo.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|promotion_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','promotion');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\" title=\""+mpListing.tabURLs.promo.title+'">'+mpListing.tabURLs.promo.content+"</a>";notFirst=true}if(mpListing.tabURLs.coupon!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.tabURLs.coupon.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|coupons_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','coupons');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\" title=\""+mpListing.tabURLs.coupon.title+'">'+mpListing.tabURLs.coupon.content+"</a>";notFirst=true}if(mpListing.tabURLs.menu!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.tabURLs.menu.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|menu_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','menu');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\" title=\""+mpListing.tabURLs.menu.title+'">'+mpListing.tabURLs.menu.content+"</a>";notFirst=true}if(mpListing.tabURLs.trader!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.tabURLs.trader.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|trader_link_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','trader');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\">"+mpListing.tabURLs.trader.content+"</a>";notFirst=true}if(mpListing.tabURLs.eco!=null){description+=(notFirst?divider:"")+'<a class="ecoLogo " href="'+mpListing.tabURLs.eco.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|eco_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','information');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\" title=\""+mpListing.tabURLs.eco.title+'">&nbsp</a>';notFirst=true}if(mpListing.productURLs.profile!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.productURLs.profile.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|profile_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','profile');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\">"+mpListing.productURLs.profile.content+"</a>";notFirst=true}if(mpListing.productURLs.hotellink!=null){description+=(notFirst?divider:"")+'<a href="'+mpListing.productURLs.hotellink.href+"\" onmousedown=\"_hbSet('cv.c2','"+mpListing.reportingId+"_"+mpListing.listingType+"|check_rates_"+hbxWhat+"');_hbSet('cv.c3','"+catDirList.join(",")+"');_hbSet('cv.c5','"+mpListing.reportingId+"_"+mpListing.listingType+"');_hbSet('lid','check_rates');_hbSet('lpos','in_bubble');_hbSend();\" target=\"_blank\" rel=\"nofollow\">"+mpListing.productURLs.hotellink.content+"</a>";notFirst=true}description+="</div>"}description+="</div>";description+='<div class="clearboth"></div>';description+="</div>";description+="</div>";if(browserManager.BrowserName=="msie"){if(browserManager.BrowserVersion>6){description+='<div class="clearboth"></div>'}else{if(browserManager.BrowserVersion<7){description+='<div class="clearboth" style="font-size: 0px;">&nbsp;</div>'}}}description+='<div class="ypgBottomRoundedRow">';description+='<div class="bl"></div>';description+='<div class="bm"></div>';description+='<div class="br"></div>';description+="</div>";description+="</div>";return description}function ProcessFullMerchant(rText){try{YPSearchManager.g_FullMPSelectedData=eval("("+rText+")");AddLocationPinToMap()}catch(e){alert(e.message)}}function GetMPData(shapeId,listingIndex){mpShapeId=shapeId;if(mpShapeId==-1){mpShapeId=g_listingShapeMap[listingIndex]}if(listingIndex==null){var shape=mapManager.Map.GetShapeByID(mpShapeId);if(shape._customIcon!=undefined){var curCustomIconClass=shape._customIcon.match(/class=(["'])?(\w+)\1/)[2];if(curCustomIconClass.match(/^pin_wf|pin_v_wf|pin_nonad|pin_v_nonad|^mapIcon/i)!=null){var keyInSpan=shape.GetDescription();var imKey=InfoBoxManager.StripSpan(keyInSpan);if(InfoBoxManager.IsFormattedKey(imKey)){var fields=imKey.split("||");var type=fields[0];listingIndex=parseInt(fields[1])}}}}var currentListing=g_sResult.businessList[listingIndex];visitedListings[currentListing.listingId]=1;if(debug){console.log("YPSM.GetMPData paneNumber: ",paneNumber)}var location=ClientCache.Retrieve("pane_"+paneNumber+"_EnteredLocationInput").cleanse();var keyword=ClientCache.Retrieve("pane_"+paneNumber+"_NameInput").cleanse();var qString="?listId="+currentListing.listingId+"&what="+keyword+"&where="+location+"&lat="+currentListing.address.location.latitude+"&lon="+currentListing.address.location.longitude+"&le="+currentListing.relevantEntryKeys+"&dist=10";ShowLoading();var request=new AjaxRequest("/ajax/merchant.html"+qString,ProcessMiniMerchant);request.Execute()}function ProcessMiniMerchant(rText){try{g_MPResult=eval("("+rText+")");HideLoading();ShowMiniMerchantBubble(mpShapeId)}catch(e){alert(e.message)}}function GenerateOnHoverDescription(listingIndex,poiType){var currentListing=g_sResult.businessList[listingIndex];if(poiType==100){var hbxPinType="num_icon"}else{if(poiType==101){var hbxPinType="dot_icon"}}var description="<a href=\"#\" onmousedown=\"_hbSet('lid','"+hbxPinType+"');_hbSet('lpos','imap_sr');_hbSend();\" onclick=\"javascript:YPSearchManager.GetMPData(-1, "+listingIndex+');return false;">'+currentListing.name+"</a>";return description}function GenerateName(listingIndex,poiType){var currentListing=g_sResult.businessList[listingIndex];return("<strong>"+currentListing.name+"</strong>");return description}function GenerateAddress(listingIndex,poiType){var currentListing=g_sResult.businessList[listingIndex];return(currentListing.address.street+", "+currentListing.address.city)}function GeneratePhone(listingIndex,poiType){var currentListing=g_sResult.businessList[listingIndex];return(currentListing.phone)}function GenerateImage(listingIndex,poiType){var currentListing=g_sResult.businessList[listingIndex];var listingImg=GetIcon(currentListing.pushpinType,currentListing.listingId);return(listingImg='<img class="png clusterPinPos'+currentListing.pushpinType+'" src="/images/shared/common/map/'+listingImg+'"></img>')}function ProcessResult(rText){YPSearchManager.ClearFind();g_sResult=eval("("+rText+")");UpdateSummaryHeading();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])}g_navMap=true;if(g_navMap){if(g_sResult.ListingTotal==1){m_CenterListing(1)}}searchingLock=null;HideLoading();return}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+"_EnteredLocationInput");if(locn==undefined){var locationBox=((ClientCache.Retrieve("lastSearch")=="bus")?document.getElementById("txtBusLocation"):document.getElementById("txtPersonLocation"));locn=locationBox==null?g_sResult.where:locationBox.value}if(g_sResult.listingTotal==0){var noResultText="";if(mapManager.GetIsCategorySearch()!=undefined&&mapManager.GetIsCategorySearch()){noResultText=String.format(resourceElementNoResultsCategory,g_sResult.what,locn);mapManager.SetCategorySearch(false)}else{noResultText=String.format(resourceElementNoResults,g_sResult.what,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="";var textElement=document.createElement("span");textElement.innerHTML=resourceResultsFor+" ";pNode.appendChild(textElement);var keyNode=document.createElement("strong");var keyn=ClientCache.Retrieve("pane_"+paneNumber+"_NameInput");if(keyn==undefined){keyn==g_sResult.what}keyNode.appendChild(document.createTextNode(keyn));pNode.appendChild(keyNode);pNode.appendChild(document.createTextNode(", "));var locNode=document.createElement("strong");locNode.appendChild(document.createTextNode(locn));pNode.appendChild(locNode);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.address.location){return}var yellowDart=true;var divHeight=(yellowDart?"318px":"170px");var topMargin=(yellowDart?"15px":"8px");var listingType="bus";var description='<div style="height: '+divHeight+";margin-top:"+topMargin+';">';description+='<div class="popupTop">';description+='<div class="popupTopLeft">';var latLong=new VELatLong(currentListing.address.location.latitude,currentListing.address.location.longitude);var shape=new VEShape(VEShapeType.Pushpin,latLong);description+=currentListing.name+"<br />";description+=currentListing.address.street+", "+currentListing.address.city+", "+currentListing.address.province+" "+currentListing.address.postalCode;description+="<br />";description+=currentListing.phone;description+="</div>";description+="</div>";description+="</div>";description=(yellowDart?"(B)":"(S)")+description;var currentListingIndex=tempIndex++;var key=InfoBoxManager.StoreDescription("Listing",currentListingIndex,description);shape.SetDescription(key);var cIndex=currentListingIndex;var txtStyle="triple";if(cIndex<10){txtStyle="single"}else{if(cIndex<100){txtStyle="double"}}if(currentListing.pushpinType=="Ad"){shape.SetCustomIcon("<div class=pin_wf></div>")}else{shape.SetCustomIcon("<div class=pin_nonad></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){var index=0;if(isMerchantPage==true){var currentListing=YPSearchManager.g_FullMPSelectedData}else{var currentListing=YPSearchManager.g_GNBSelectedData}var description=YPSearchManager.GenerateDescription(index,100,currentListing);var shape=new VEShape(VEShapeType.Pushpin,new VELatLong(currentListing.listing.address.location.latitude,currentListing.listing.address.location.longitude));var key=InfoBoxManager.StoreDescription("Location",index,description);shape.SetDescription(key+"<strong>"+currentListing.listing.name+"</strong>");if(currentListing.listing.pushpinType=="Ad"){if(isMerchantPage==true){shape.SetCustomIcon("<div class=pin_selected></div>")}else{shape.SetCustomIcon("<div class=pin_star></div>")}}else{if(isMerchantPage==true){shape.SetCustomIcon("<div class=pin_selected></div>")}else{shape.SetCustomIcon("<div class=pin_star></div>")}}mapManager.Map.AddShape(shape);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;if(isMerchantPage==true){var currentListing=YPSearchManager.g_FullMPSelectedData.listing}else{if(index==0){var currentListing=YPSearchManager.g_GNBSelectedData.listing}else{var currentListing=g_sResult.businessList[index]}}if(mode=="TO"){endAddress=document.getElementById("toAddress"+index).value;startAddress=currentListing.address.street+", "+currentListing.address.city+", "+currentListing.address.postalCode;if(endAddress.trim()==""){return}}else{startAddress=document.getElementById("fromAddress"+index).value;endAddress=currentListing.address.street+", "+currentListing.address.city+", "+currentListing.address.postalCode;if(startAddress.trim()==""){return}}HideCurrentEro(null);document.getElementById("txtFrom").value=startAddress;document.getElementById("txtTo").value=endAddress;mapManager.GetNewDirections(startAddress,endAddress)}function GNBForListingPopup(index,name,address,phone){this.isGNBForListingPopup=true;this.ranGNBOnce=false;var txtNB=document.getElementById("nearby"+index).value;if(txtNB.trim()==""){return}if(isMerchantPage==true){var currentListing=YPSearchManager.g_FullMPSelectedData.listing;YPSearchManager.g_GNBSelectedData=YPSearchManager.g_FullMPSelectedData}else{var currentListing=g_MPResult.listing;YPSearchManager.g_GNBSelectedData=g_MPResult}document.getElementById("txtBusLocation").value=currentListing.address.street+", "+currentListing.address.city+", "+currentListing.address.postalCode;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};
