function LclMapItem(poi,latlng){this.poi=poi;
this.latlng=latlng;
}function LclResult(){this.venuename="";
this.venuepostalcode="";
this.venuestate="";
this.venuephonenumber="";
this.venueaddress=null;
this.venuecity=null;
this.venuedescription="";
this.flon=null;
this.flat=null;
this.venuehasphoto=null;
this.venuephotourl=null;
this.hasreviews=null;
this.reviewrating=null;
this.numberofreviews=null;
this.lastreviewdate="";
this.websiteurl="";
this.cityguideurl="";
this.mapItem=null;
this.bs_distance=null;
this.category="";
this.eventname="";
this.directionsUrl="";
this.adhasphoto="";
this.citybest=false;
}var local={debug:true,smallMap:false,defaultRadius:5,mapItems:[],imagesDir:"",cssDir:"",myMap:null,myVControl:null,myLZControl:null,wnDiv:null,nDiv:null,wDiv:null,paginDiv:null,mapWindow:null,local_hits:null,cmn:null,panTimeout:null,query:null,currResSet:null,roWin:null,roWinTimeout:null,poiWinTimeout:null,b_star:null,resultsPages:new Array(),currPoi:null,currStickyRes:null,ddSessionID:null,ddEntryText:"",myPxyServer:"",myPxyPort:"",myPxyPath:"/JSAPIProxy/JSReqHandler",mqPort:"80",mqPath:"mq",mapExpanded:false,mqConsts:null,mqIcon:null,myGExec:null,myRExec:null,myTAddress:null,myFAddress:null,myGcColl:null,myOrColl:null,myRtColl:null,myBB:null,detMapCntr:null,mapTopLimit:null,mapBotLimit:null,nonMapLis:[],initVals:function(){this.mapWindow=$("mapWindow");
this.mqIcon=new MQA.Icon(this.imagesDir+"sml_balloon1.png",24,27);
},startMap:function(){var pois=new Array(),x=1,prnt,hasLatLong=true,myPoint,myIcon;
var resColl;
this.mapItems.push(resColl=new Array());
var poiColl=new MQA.ShapeCollection();
var mapResults=0;
this.searchCoords=null;
try{this.searchCoords=eval("("+$("searchCoords").innerHTML+")");
}catch(e){}prnt=$$("ul.search-results #listing"+x)[0];
while(prnt!=null){var resObj;
resColl.push(resObj=new LclResult());
var resultJson=eval("("+prnt.getElementsBySelector("div.result_json")[0].firstChild.nodeValue+")");
prnt.resultJson=resultJson;
var lat=resObj.flat=parseFloat(resultJson.lat);
var lon=resObj.flon=parseFloat(resultJson.lon);
resObj.adhasphoto=resultJson.photo;
resObj.citybest=false;
var t;
resObj.venueaddress=((t=prnt.getElementsBySelector(".street-address")).length>0)?t[0].innerHTML.unescapeHTML():"";
if(!(isNaN(lat)||isNaN(lon))&&resObj.venueaddress.length>0){var latlong=new MQA.LatLng(resObj.flat,resObj.flon);
var container=prnt.parentNode;
var vlink=prnt.getElementsBySelector("a.fn")[0];
var name=resObj.venuename=vlink.innerHTML.unescapeHTML();
resObj.cityguideurl=vlink.href;
resObj.venuecity=((t=prnt.getElementsBySelector(".locality")).length>0)?t[0].innerHTML.unescapeHTML():"";
resObj.venuestate=((t=prnt.getElementsBySelector(".region")).length>0)?t[0].innerHTML.unescapeHTML():"";
resObj.websiteurl=((t=prnt.getElementsBySelector(".official-site")).length>0)?t[0].href:"";
resObj.directionsUrl=((t=prnt.getElementsBySelector(".dirs-url")).length>0)?t[0].href:"";
var tel;
if((tel=prnt.getElementsBySelector(".tel")).length>0){resObj.venuephonenumber=local.cmn.trim(tel[0].innerHTML).replace(/-/g,"");
}if(this.searchCoords!=null){if(latlong.arcDistance(new MQA.LatLng(this.searchCoords.lat,this.searchCoords.lon),0)<100){resObj.mapItem=new LclMapItem(null,latlong);
var resImg=prnt.getElementsBySelector("img.result-num")[0];
if(yp.browser.ie6){resImg.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+local.imagesDir+"sml_"+(resObj.citybest?"cb":"")+"balloon"+(++mapResults)+".png', sizingMethod='image')";
resImg.src="http://img.mqcdn.com/a/a";
}else{resImg.src=local.imagesDir+"sml_"+(resObj.citybest?"cb":"")+"balloon"+(++mapResults)+".png";
}resImg.alt=i18n.mapw_mapRefAlt+mapResults;
prnt.resultJson.resNum=mapResults;
resImg.show();
resObj.li=prnt;
resObj.li.resImg=resImg;
Event.observe(resObj.li,"mouseover",this.rolloverResult.bindAsEventListener(this));
Event.observe(resObj.li,"mouseout",this.rolloutResult.bindAsEventListener(this));
Event.observe(prnt.getElementsBySelector("a.map-link")[0],"click",this.mapLink.bindAsEventListener(this));
}else{resColl.pop();
this.nonMapLis.push(prnt);
var sp=prnt.getElementsBySelector("span.map-span")[0];
if(sp){sp.hide();
}}}}else{resColl.pop();
this.nonMapLis.push(prnt);
}x++;
prnt=$$("ul.search-results #listing"+x)[0];
}x=1;
prnt=$$("ul.search-results #slr_listing"+x)[0];
while(prnt!=null){var resObj;
resColl.push(resObj=new LclResult());
var resultJson=eval("("+prnt.getElementsBySelector("div.result_json")[0].firstChild.nodeValue+")");
prnt.resultJson=resultJson;
var lat=resObj.flat=parseFloat(resultJson.lat);
var lon=resObj.flon=parseFloat(resultJson.lon);
resObj.citybest=(!resultJson.cb)?false:true;
resObj.venuephotourl=resultJson.photo;
var t;
resObj.venueaddress=((t=prnt.getElementsBySelector(".street-address")).length>0)?t[0].innerHTML.unescapeHTML():"";
if(!(isNaN(lat)||isNaN(lon))&&resObj.venueaddress.length>0){var latlong=new MQA.LatLng(resObj.flat,resObj.flon);
var container=prnt.parentNode;
var vlink=prnt.getElementsBySelector("a.fn")[0];
var name=resObj.venuename=vlink.innerHTML.unescapeHTML();
resObj.cityguideurl=vlink.href;
resObj.venuecity=((t=prnt.getElementsBySelector(".locality")).length>0)?t[0].innerHTML.unescapeHTML():"";
resObj.venuestate=((t=prnt.getElementsBySelector(".region")).length>0)?t[0].innerHTML.unescapeHTML():"";
resObj.websiteurl=((t=prnt.getElementsBySelector(".official-site")).length>0)?t[0].href:"";
resObj.directionsUrl=((t=prnt.getElementsBySelector(".dirs-url")).length>0)?t[0].href:"";
var tel;
if((tel=prnt.getElementsBySelector(".tel")).length>0){resObj.venuephonenumber=local.cmn.trim(tel[0].innerHTML).replace(/-/g,"");
}resObj.mapItem=new LclMapItem(null,latlong);
var resImg=prnt.getElementsBySelector("img.result-num")[0];
if(yp.browser.ie6){resImg.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+local.imagesDir+"sml_"+(resObj.citybest?"cb":"")+"balloon"+(++mapResults)+".png', sizingMethod='image')";
resImg.src="http://img.mqcdn.com/a/a";
}else{resImg.src=local.imagesDir+"sml_"+(resObj.citybest?"cb":"")+"balloon"+(++mapResults)+".png";
}resImg.alt=i18n.mapw_mapRefAlt+mapResults;
prnt.resultJson.resNum=mapResults;
resImg.show();
resObj.li=prnt;
resObj.li.resImg=resImg;
Event.observe(resObj.li,"mouseover",this.rolloverResult.bindAsEventListener(this));
Event.observe(resObj.li,"mouseout",this.rolloutResult.bindAsEventListener(this));
Event.observe(prnt.getElementsBySelector("a.map-link")[0],"click",this.mapLink.bindAsEventListener(this));
}else{resColl.pop();
this.nonMapLis.push(prnt);
var sp=prnt.getElementsBySelector("span.map-span")[0];
if(sp){sp.hide();
}}x++;
prnt=$$("ul.search-results #slr_listing"+x)[0];
}if(mapResults>0&&$("map_results")!==null){this.currResSet=0;
this.resultsPages.push(0);
poiColl=this.redrawPois(resColl,poiColl);
var mInit=new MQA.MapInit();
mInit.setBestFitRect(poiColl.getBoundingRect());
mInit.setBestFitMargin(20);
this.myMap=new MQA.TileMap(this.mapWindow,9,new MQA.LatLng(),"map",mInit);
}else{var mapCenter=(this.searchCoords===null)?new MQA.LatLng():new MQA.LatLng(this.searchCoords.lat,this.searchCoords.lon);
this.myMap=new MQA.TileMap(this.mapWindow,9,mapCenter,"map");
}this.myMap.enableDragging(false);
this.myMap.setRolloversEnabled(true);
this.myMap.replaceShapes(poiColl);
this.nonMapLis.each(function(li){Event.observe(li,"mouseover",this.ordinaryLiHl.bindAsEventListener(this));
Event.observe(li,"mouseout",this.ordinaryLiHl.bindAsEventListener(this));
}.bind(this));
MQA.EventManager.addListener(this.myMap,"dragstart",this.hidePoiRollover.bind(this));
},startDetailsMap:function(){this.smallMap=true;
var pois=new Array(),x=1,prnt,hasLatLong=true,myPoint,myIcon;
var resColl;
this.mapItems.push(resColl=new Array());
var poiColl=new MQA.ShapeCollection();
var resObj;
resColl.push(resObj=new LclResult());
var resultJson=eval("("+$$("div#venue_json")[0].firstChild.nodeValue+")");
var lat=resObj.flat=parseFloat(resultJson.lat);
var lon=resObj.flon=parseFloat(resultJson.lon);
var prnt=$$("div.vcard")[0];
if(!(isNaN(lat)||isNaN(lon))){var name=resObj.venuename=prnt.getElementsBySelector(".fn")[0].innerHTML.unescapeHTML(),t,tel,container=prnt.parentNode,latlong=new MQA.LatLng(resObj.flat,resObj.flon);
resObj.venueaddress=((t=prnt.getElementsBySelector(".street-address")).length>0)?t[0].innerHTML.unescapeHTML():"";
resObj.venuecity=((t=prnt.getElementsBySelector(".locality")).length>0)?t[0].innerHTML.unescapeHTML():"";
resObj.venuestate=((t=prnt.getElementsBySelector(".region")).length>0)?t[0].innerHTML.unescapeHTML():"";
if((tel=prnt.getElementsBySelector(".tel")).length>0){resObj.venuephonenumber=local.cmn.trim(tel[0].innerHTML).replace(/-/g,"");
}resObj.mapItem=new LclMapItem(null,latlong);
}else{if($("map_results")!==null){$("map_results").hide();
}return ;
}this.currResSet=0;
this.resultsPages.push(0);
this.myMap=new MQA.TileMap(this.mapWindow,12,this.b_star,"map");
resObj.citybest=(!resultJson.cb)?false:true;
this.redrawPois(resColl);
this.myMap.setCenter(latlong);
this.myMap.enableDragging(false);
this.myMap.setRolloversEnabled(false);
},ordinaryLiHl:function(e){var targetEle;
if(e){targetEle=e.relatedTarget;
}else{targetEle=event.toElement;
}e=e||event;
var el=Event.findElement(e,"li"),poi;
while(el.id.indexOf("listing")==-1){el=el.up("li");
}if(e.type.indexOf("mouseout")>-1&&targetEle!==null){while(targetEle.id.indexOf("listing")==-1&&$(targetEle).up("li")!==undefined){targetEle=$(targetEle).up("li");
}if(el===targetEle){return ;
}}if(e.type.indexOf("mouseover")>-1){el.addClassName("over");
}else{el.removeClassName("over");
}},rolloverResult:function(e){if(this.currStickyRes!=null){return ;
}if(e.constructor==MQA.Poi){this.highlightPoi(e,true);
}else{e=e||event;
var el=Event.findElement(e,"li"),poi;
while(el.id.indexOf("listing")==-1){el=el.up("li");
}poi=local.mapItems[0][el.resultJson.resNum-1].mapItem.poi;
this.highlightPoi(poi,true);
}},rolloutResult:function(e){if(this.currStickyRes!=null){return ;
}if(e.constructor==MQA.Poi){this.highlightPoi(e,false);
}else{var targetEle;
if(e){targetEle=e.relatedTarget;
}else{targetEle=event.toElement;
}e=e||event;
var el=Event.findElement(e,"li"),poi;
while(el.id.indexOf("listing")==-1){el=el.up("li");
}if(targetEle!==null){while(targetEle.id.indexOf("listing")==-1&&$(targetEle).up("li")!==undefined){targetEle=$(targetEle).up("li");
}if(el===targetEle){return ;
}}poi=local.mapItems[0][el.resultJson.resNum-1].mapItem.poi;
this.highlightPoi(poi,false);
}},highlightPoi:function(poi,hl){var newUrl;
var oldUrl=poi.icon.imageURL;
if(hl){newUrl=oldUrl.replace(/\/sml_/,"/o_sml_");
poi.setValue("altStateFlag",true);
poi._setZIndex("91");
}else{newUrl=oldUrl.replace(/\/o_sml_/,"/sml_");
poi.setValue("altStateFlag",false);
poi._setZIndex("90");
}var poiKey,poiNum;
poiKey=poi.getKey();
poiNum=parseInt(poiKey.substr(3));
var res=local.mapItems[0][poiNum];
if(hl){res.li.addClassName("over");
}else{res.li.removeClassName("over");
}if(yp.browser.ie6){res.li.resImg.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+newUrl+"', sizingMethod='image')";
}else{res.li.resImg.src=newUrl;
}},createLclPOI:function(latlng,img,imgW,imgH,key){var myIcon=new MQA.Icon(img,imgW,imgH);
var myPoint=new MQA.Poi(latlng,myIcon);
myPoint.setValue("shadow",new MQA.Icon(this.imagesDir+"empty.png",0,0));
myPoint.setValue("draggable",false);
myPoint.setValue("altIcon",new MQA.Icon(img.replace(/\/sml_/,"/o_sml_"),imgW,imgH));
if(key){myPoint.setKey(key);
}return myPoint;
},poiRollover:function(poi,cMulti){if(!this.mapExpanded){return ;
}if(this.currStickyRes!==null){this.closePoiRollover();
}var poiKey,poiNum,ll,xyLoc;
poiKey=poi.getKey();
poiNum=parseInt(poiKey.substr(3));
ll=poi.getLatLng();
xyLoc=this.myMap.llToPix(ll);
window.clearTimeout(local.poiWinTimeout);
window.clearTimeout(local.roWinTimeout);
this.currPoi=poiNum;
this.dispPoiRollover(this.mapItems[this.currResSet][poiNum],xyLoc);
this.highlightPoi(poi,true);
this.currStickyRes=poiNum;
},closePoiRollover:function(){this.highlightPoi(this.mapItems[0][this.currStickyRes].mapItem.poi,false);
this.mapItems[0][this.currStickyRes].mapItem.poi._setZIndex("90");
this.roWin.hide();
this.currStickyRes=null;
},poiRollout:function(poi){this.poiWinTimeout=window.setTimeout('local.hidePoiRollover("res")',500);
},dispPoiRollover:function(resObj,xyLoc){window.clearTimeout(this.poiWinTimeout);
var ce=local.cmn.ce,apTxt=local.cmn.apTxt,roCnt=$("RO_content"),el,el2;
local.cmn.removeChildren(roCnt);
var ximg=ce("span",null,"popup_x");
Event.observe(ximg,"click",local.closePoiRollover.bindAsEventListener(this));
roCnt.appendChild(ximg);
if(resObj.venuephotourl){el=roCnt.appendChild(ce("a"));
el.href=resObj.cityguideurl;
el=el.appendChild(ce("img"));
el.alt="Photo of "+resObj.venuename;
el.src=resObj.venuephotourl;
el.onerror=el.onload=function(){local.positionPopup(local.myMap.llToPix(local.mapItems[local.currResSet][local.currPoi].mapItem.poi.getLatLng()));
};
roCnt.appendChild(ce("br"));
}el=roCnt.appendChild(ce("div",null,"puUrl"));
if(resObj.cityguideurl){el=el.appendChild(ce("a"));
el.setAttribute("target","_parent");
el.href=resObj.cityguideurl;
}this.searchTermNodes(el,resObj.venuename.replace(/<STRONG>/g,"").replace(/<\/STRONG>/g,"").replace(/<B>/g,"").replace(/<\/B>/g,"").replace(/<strong>/g,"").replace(/<\/strong>/g,"").replace(/<b>/g,"").replace(/<\/b>/g,""),this.query);
roCnt.appendChild(ce("br"));
el.style.paddingBottom="4px";
if(resObj.venueaddress){apTxt(roCnt,resObj.venueaddress+", ");
}if(resObj.venuecity){apTxt(roCnt,resObj.venuecity+", ");
}apTxt(roCnt,resObj.venuestate);
roCnt.appendChild(ce("br"));
var ph;
ph=(resObj.venuephonenumber.indexOf("-")==-1)?this.formatPhoneNum(resObj.venuephonenumber):resObj.venuephonenumber;
if(resObj.venuephonenumber){el=ce("b");
apTxt(el,ph);
roCnt.appendChild(el);
}roCnt.appendChild(ce("br"));
if(resObj.category){el=roCnt.appendChild(ce("div",null,"grey"));
apTxt(el,i18n.mapw_category+resObj.category);
el.style.paddingBottom="7px";
}el=roCnt.appendChild(ce("br"));
el=el.parentNode;
if(resObj.websiteurl!=""){apTxt(roCnt,"- ");
el=roCnt.appendChild(ce("a"));
el.target="_blank";
el.href=resObj.websiteurl;
apTxt(el,"Website");
roCnt.appendChild(ce("br"));
}apTxt(roCnt,"- ");
el=roCnt.appendChild(ce("a"));
apTxt(el,i18n.mapw_directions);
el.href=resObj.directionsUrl;
if(resObj.adhasphoto!==""){roCnt.appendChild(ce("br"));
el=roCnt.appendChild(ce("a"));
el.href=resObj.cityguideurl;
el=el.appendChild(ce("img"));
el.className="ad-photo";
el.alt=i18n.mapw_venuePhotoAlt+resObj.venuename;
el.src=resObj.adhasphoto;
el.onerror=el.onload=function(){local.positionPopup(local.myMap.llToPix(local.mapItems[local.currResSet][local.currPoi].mapItem.poi.getLatLng()));
};
}this.roWin.style.display="";
this.positionPopup(xyLoc);
},hidePoiRollover:function(typ){this.roWin.style.display="none";
},positionPopup:function(xyLoc){var flip=this.decideFlip(xyLoc);
var offset=Position.cumulativeOffset(this.mapWindow);
var flippedTop=xyLoc.y+offset[1]-this.roWin.offsetHeight+15;
if(flip&&flippedTop>0){this.roWin.style.top=(xyLoc.y+offset[1]-this.roWin.offsetHeight+19)+"px";
this.roWin.style.left=(xyLoc.x+offset[0]-this.roWin.offsetWidth-26)+"px";
}else{this.roWin.style.top=(xyLoc.y+offset[1]-22)+"px";
this.roWin.style.left=(xyLoc.x+offset[0]+25)+"px";
flip=false;
}$("popup_middle").className=(flip)?"puMiddle_r":"puMiddle";
$("offArrowR").style.display=(flip)?"":"none";
$("offArrow").style.display=(!flip)?"":"none";
},decideFlip:function(xyLoc){var wW=(window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth);
var wH=(window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)+(document.documentElement.scrollTop||document.body.scrollTop);
var x=xyLoc.x+Position.cumulativeOffset(this.mapWindow)[0];
var y=xyLoc.y+Position.cumulativeOffset(this.mapWindow)[1];
if(x+this.roWin.offsetWidth+50<wW&&((y+this.roWin.offsetHeight-30)>wH&&y-(document.documentElement.scrollTop||document.body.scrollTop)-this.roWin.offsetHeight<0)){return false;
}else{if(x+this.roWin.offsetWidth+50>wW||y+(this.roWin.offsetHeight-30)>wH){return true;
}else{return false;
}}},onload:function(){this.roWin=$("RO_window");
this.initVals();
if(this.mapWindow){this.myLZControl=new MQA.LargeZoomControl(this.myMap);
this.myVControl=new MQA.ViewControl(this.myMap);
this.isResultsPage=(this.template=="listings"||this.template=="whatsnearby");
this.isDetailsPage=(this.template=="ypdetails"||this.template=="freedetails");
if(this.roWin){$$("body")[0].appendChild(this.roWin);
}if(this.isResultsPage){this.startMap();
}else{if(this.isDetailsPage){this.startDetailsMap();
}}if(this.isResultsPage){this.scrollMapWithViewport();
}if((this.isResultsPage||this.isDetailsPage)&&this.mapWindow&&$("mqtiledmap")){$("mqtiledmap").addClassName("no-cursor");
}if(this.template==="directions"){if($("from_input").value.length>0){this.getDirections();
}Event.observe($("from_input").form,"submit",function(e){e=e||event;
Event.stop(e);
this.popUpMapQuest();
}.bindAsEventListener(this));
}}},removeAllPois:function(){var limit=0;
while(this.myMap.getPois().getSize()>limit){var poi=this.myMap.getPois().getAt(limit);
if(poi.key=="bs"){limit++;
}else{this.myMap.removePoi(poi);
}}},searchTermNodes:function(prnt,itm,st){var idx=0,el,apTxt=local.cmn.apTxt,str,lwst=itm.length,lwstI=-1;
var sts=st.split(" ");
sts.each(function(v,i){var m;
if((m=v.match(/[a-zA-Z0-9-]+/g))!=null){sts[i]=m[0];
}else{sts[i]=null;
}});
sts.each(function(v,i){if(v==null){return ;
}if(itm.toLowerCase().indexOf(v.toLowerCase())>-1&&itm.toLowerCase().indexOf(v.toLowerCase())<lwst){lwst=itm.toLowerCase().indexOf(v.toLowerCase());
lwstI=i;
}});
if(lwstI==-1){apTxt(prnt,itm);
}else{str=idx=lwst;
apTxt(prnt,itm.substring(0,str));
st=sts[lwstI];
do{apTxt(prnt,itm.substring(str,idx));
el=local.cmn.ce("b");
apTxt(el,itm.substr(idx,st.length));
prnt.appendChild(el);
str=idx=idx+st.length;
lwst=itm.length;
}while(void (sts.each(function(v,i){if(v==null){return ;
}if(itm.toLowerCase().indexOf(v.toLowerCase(),str)>-1&&itm.toLowerCase().indexOf(v.toLowerCase(),str)<lwst){idx=lwst=itm.toLowerCase().indexOf(v.toLowerCase(),str);
st=sts[lwstI=i];
}}))||lwst<itm.length);
apTxt(prnt,itm.substr(str));
}},formatPhoneNum:function(num){if(!num){return"";
}num=num.toString();
return num.substr(0,3)+"-"+num.substr(3,3)+"-"+num.substr(6);
},dbgmsg:function(txt){if(!local.debug){return ;
}if(window.console){window.console.log(txt);
}},redrawPois:function(resObj,poiColl){if(!resObj){return ;
}if(typeof (poiColl)=="undefined"){poiColl=false;
}var img;
for(var i=0;
i<resObj.length;
i++){if(resObj[i].mapItem.poi!=null){if(poiColl){poiColl.add(resObj[i].mapItem.poi);
}else{this.myMap.addPoi(resObj[i].mapItem.poi);
}continue;
}if(resObj[i].citybest){img=this.imagesDir+"sml_cbballoon"+(i+1)+".png";
}else{img=this.imagesDir+"sml_balloon"+(i+1)+".png";
}pnt=this.createLclPOI(resObj[i].mapItem.latlng,img,24,(resObj[i].citybest?34:27),"res"+i);
if(!this.smallMap){MQA.EventManager.addListener(pnt,"mouseover",function(){local.rolloverResult(this);
});
MQA.EventManager.addListener(pnt,"click",function(){local.poiRollover(this);
});
MQA.EventManager.addListener(pnt,"mouseout",function(){local.rolloutResult(this);
});
}if(poiColl){poiColl.add(pnt);
}else{this.myMap.addPoi(pnt);
}if(resObj[i].mapItem.poi==null){resObj[i].mapItem.poi=pnt;
}}if(poiColl){return poiColl;
}},popUpMapQuest:function(){var destJson;
$("direct_error").hide();
try{destJson=eval("("+$("dest_json").firstChild.nodeValue+")");
}catch(e){}if(typeof destJson!=="undefined"&&destJson.mq==="true"){var tmp;
var lineAddress=$("from_input").value;
if(lineAddress=="undefined"||lineAddress.replace(/^\s+|\s+$/g,"")==""){var inpId="from_input";
var sBox=$("direct_error");
var str=i18n.mapw_couldntFind;
sBox.update(str);
sBox.show();
return ;
}var lineAddress="&1ai="+escape(lineAddress);
var y1="&1y=US";
var c2=((tmp=$$("#bus_vcard .locality")).length>0)?"&2c="+tmp[0].innerHTML:"";
var s2=((tmp=$$("#bus_vcard .region")).length>0)?"&2s="+tmp[0].innerHTML:"";
var a2=((tmp=$$("#bus_vcard .street-address")).length>0)?"&2a="+tmp[0].innerHTML:"";
var z2=((tmp=$$("#bus_vcard .postal-code")).length>0)?"&2z="+tmp[0].innerHTML:"";
var y2="&2y=US";
var addinfo=lineAddress+y1+c2+s2+a2+z2+y2;
var mqurl="http://www.mapquest.com/maps?"+addinfo.replace(/\s+/g,"+");
window.open(mqurl);
return ;
}},formatAddress:function(thisAddress,cropRanges){var str="";
str=thisAddress.getStreet();
var hasState=false;
if(thisAddress.getCity().length>0){if(str==""){str+=thisAddress.getCity();
}else{str+=", "+thisAddress.getCity();
}}if(thisAddress.getState().length>0){if(str==""){str+=thisAddress.getState();
}else{str+=", "+thisAddress.getState();
}hasState=true;
}if(thisAddress.getPostalCode().length>0){var zip=thisAddress.getPostalCode();
if(cropRanges==true&&zip.indexOf("-")>0){zip=zip.substring(0,zip.indexOf("-"));
}if(str==""){str+=zip;
}else{if(hasState){str+=" "+zip;
}else{str+=", "+zip;
}}}return str;
},toggleMap:function(){if(!this.mapExpanded){this.detMapCntr=local.myMap.getCenter();
$("container").addClassName("map-expanded");
local.myMap.setSize(new MQA.Size(497,502));
$("mapWindow").setStyle({width:"497px",height:"502px"});
if(this.isResultsPage){local.myMap.bestFit();
}this.myMap.enableDragging(true);
this.myMap.addControl(this.myLZControl,new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT,new MQA.Size(0,20)));
this.myMap.addControl(this.myVControl,new MQA.MapCornerPlacement(MQA.MapCorner.TOP_LEFT,new MQA.Size(110,0)));
$("map_expand_link").innerHTML=i18n.mapw_reduceMap;
$("mqtiledmap").removeClassName("no-cursor");
this.mapExpanded=true;
}else{if(this.currStickyRes!==null){this.closePoiRollover();
}this.myMap.enableDragging(false);
this.myMap.removeControl(this.myLZControl);
this.myMap.removeControl(this.myVControl);
local.myMap.setSize(new MQA.Size(304,250));
$("mapWindow").setStyle({width:"304px",height:"250px"});
if(this.isResultsPage){local.myMap.bestFit();
}else{if(this.isDetailsPage){local.myMap.setCenter(this.detMapCntr,12);
}}$("map_expand_link").innerHTML=i18n.mapw_enlargeMap;
$("container").removeClassName("map-expanded");
$("mqtiledmap").addClassName("no-cursor");
this.mapExpanded=false;
}if(this.template=="listings"||this.template=="whatsnearby"){this.mapBotLimit=$("content").offsetHeight-$("content_right").offsetHeight;
this.positionMap();
}},mapLink:function(e){e=e||event;
Event.stop(e);
var el=Event.findElement(e,"li");
while(el.id.indexOf("listing")==-1||el===undefined){el=el.up("li");
}var poiNum=el.resultJson.resNum-1;
if(!this.mapExpanded){this.toggleMap();
}if(this.currStickyRes!=null){this.closePoiRollover();
}this.myMap.bestFit();
this.poiRollover(this.mapItems[0][poiNum].mapItem.poi);
this.mapItems[0][poiNum].mapItem.poi._setZIndex("91");
},scrollMapWithViewport:function(e){$("content_right").relativize();
this.contentRoffset=$("content_right").offsetTop;
this.mapBotLimit=$("content").offsetHeight-$("content_right").offsetHeight;
Event.observe(window,"scroll",this.positionMap.bindAsEventListener(this));
},positionMap:function(e){if($("content").offsetHeight<local.mapWindow.offsetHeight){return ;
}var newPos=document.viewport.getScrollOffsets().top-local.mapWindow.offsetTop-this.contentRoffset+5;
if(newPos<0){newPos=0;
}else{if(newPos>this.mapBotLimit){newPos=this.mapBotLimit;
}}$("content_right").style.top=newPos+"px";
if(this.currStickyRes!=null){this.positionPopup(this.myMap.llToPix(this.mapItems[this.currResSet][this.currStickyRes].mapItem.poi.getLatLng()));
}}};
local.cmn={removeChildren:function(node){if(node==null){return ;
}while(node.childNodes.length>0){node.removeChild(node.firstChild);
}},ce:function(en,eid,ecl){var e=document.createElement(en);
if(eid!=null){e.id=eid;
}if(ecl!=null){e.className=ecl;
}return e;
},apTxt:function(ele,txt){return ele.appendChild(document.createTextNode(txt));
},trim:function(str){return str.replace(/^\s*|\s*$/g,"");
},stripHTML:function(str){return str.replace(/<(.|\n)+?>/g,"");
},checkForEnter:function(e){if(!e){e=event;
}if(e.keyCode==13){return true;
}else{return false;
}},submitenter:function(myfield,e){var keycode;
if(window.event){keycode=window.event.keyCode;
}else{if(e){keycode=e.which;
}else{return true;
}}if(keycode==13){return local.submitLocal(myfield.form);
}else{return true;
}},getText:function(node){var txt="";
if(!node.nodeType){return ;
}if(node.nodeType==3){return(node.nodeValue.strip()!="")?node.nodeValue:"";
}else{if(node.childNodes.length>0){for(var i=0;
i<node.childNodes.length;
i++){txt+=this.getText(node.childNodes[i]);
}}}return(this.getText.caller!=this.getText)?txt.strip():txt;
}};
document.observe("dom:loaded",function(){local.onload();
});
