var flagMapMovingPanZoom=false;var defaultPointZoom=16;var neighbourhoodZoom=16;var minZoom=15;var maxZoom=17;var gMap=null;var gGeocoder=null;var currAddress="";var currAddress2="";var currZoom=defaultPointZoom;var addressLabel=null;var currAddrLblLoc=null;var controlZoom=null;var controlNorth=null;var controlSouth=null;var addressLocationCache=Array();function Location(address,latLng){this.address=address;this.latLng=latLng;}
function initMap(showFriendlyControls){try{gMap=new GMap2(document.getElementById("google_map"),{mapTypes:[G_NORMAL_MAP]});}
catch(e){var message="The Google map was unable to display correctly\n\n"+"This could be due to any one of the following:\n"+"1) You are using a browser other than IE 6+ or Firefox 1.5+\n"+"2) Your internet connection speed is too slow\n"+"3) The latest IE patches are not installed on your computer\n"+"4) Windows XP Service Pack 2 is not installed on your computer\n";alert(message);return;}
if(showFriendlyControls){gMap.addControl(new TextualZoomControl());gMap.addControl(new PanArrowsControl());}
var mt=gMap.getMapTypes();for(var i=0;i<mt.length;i++)mt[i].getMinimumResolution=function(){return minZoom;}
GEvent.addListener(gMap,'moveend',function(){CreateAddressLabel();updateGarages();});GEvent.addListener(gMap,'dragend',function(){flagMapMovingPanZoom=true;});gMap.disableDoubleClickZoom();gGeocoder=new GClientGeocoder();if(!gGeocoder){alert("Geocode google: can't create gGeocoder (map21e.js)");jserror(3,"");}
var ratesGradient=document.createElement('div');ratesGradient.id='rates_gradient';ratesGradient.style.visibility='hidden';ratesGradient.style.position='absolute';ratesGradient.style.right='5px';ratesGradient.style.top='35px';ratesGradient.style.zIndex=3000;ratesGradient.innerHTML='<img src="'+PATH_IMG+'images/rates.gif">';document.getElementById("google_map").appendChild(ratesGradient);setOpacityCompat(ratesGradient,0.9);if(NO_RESULT){if(CUSTOM)var imgNoResult='images/no_result.gif';else if(AIRPORT)var imgNoResult='images/no_result_airports.gif';else var imgNoResult='images/no_result_cities.gif';var txtNoResult=document.createElement('div');txtNoResult.id='no_result';txtNoResult.className="do_not_print";txtNoResult.innerHTML='<center><img src="'+PATH_IMG+imgNoResult+'"></center>';gMap.getContainer().appendChild(txtNoResult);setOpacityCompat(txtNoResult,0.9);}
DisplayElem("search_results","visible");DisplayElem("search_results","none");}
function setOpacityCompat(lyr,c){if(typeof(lyr.style.filter)=='string'){lyr.style.filter='alpha(opacity:'+c*100+')';}
if(typeof(lyr.style.KHTMLOpacity)=='string'){lyr.style.KHTMLOpacity=c;}
if(typeof(lyr.style.MozOpacity)=='string'){lyr.style.MozOpacity=c;}
if(typeof(lyr.style.opacity)=='string'){lyr.style.opacity=c;}}
function clearMap(){if(addressLabel !=null){gMap.removeTLabel(addressLabel);addressLabel=null;currAddrLblLoc=null;}
for(var id in garages){var g=garages[id];for(var n=0;n<g.entrances.length;n++)g.entrances[n].requireDisplay(false);}}
function rotateLatLng(p,theta){return new GLatLng(Math.sin(theta)*p.lng()+Math.cos(theta)*p.lat(),Math.cos(theta)*p.lng()- Math.sin(theta)*p.lat());}
function unionLatLngBounds(b1,b2){var sw1=b1.getSouthWest();var sw2=b2.getNorthEast();var ne1=b1.getSouthWest();var ne2=b2.getNorthEast();var swNew=new GLatLng(Math.min(sw1.lat(),sw2.lat()),Math.min(sw1.lng(),sw2.lng()));var neNew=new GLatLng(Math.max(ne1.lat(),ne2.lat()),Math.max(ne1.lng(),ne2.lng()));return new GLatLngBounds(swNew,neNew);}
function moveDetailLabelToLatLng(subjectLabel,oEntrance,yPos){var targetLatLng=oEntrance.latLng;var targetDivPos=gMap.fromLatLngToDivPixel(targetLatLng);var labelLeft=targetDivPos.x+gMap.getPane(G_MAP_MAP_PANE).parentNode.offsetLeft - Math.floor(subjectLabel.offsetWidth / 2);var overspillMargin=0;if(labelLeft<-overspillMargin)labelLeft=-overspillMargin;if(labelLeft+subjectLabel.offsetWidth>gMap.getContainer().offsetWidth+overspillMargin)labelLeft=gMap.getContainer().offsetWidth+overspillMargin - subjectLabel.offsetWidth;var ver_pos=0;var labelTop=targetDivPos.y+gMap.getPane(G_MAP_MAP_PANE).parentNode.offsetTop - subjectLabel.offsetHeight - 8;if(labelTop<-overspillMargin)ver_pos=1;if(yPos !=undefined)ver_pos=yPos;if(ver_pos){var iconHeight=oEntrance.garageLabel.layer.offsetHeight;if(parseInt(iconHeight)==25)iconHeight=13;else if(parseInt(iconHeight)==31)iconHeight=19;else iconHeight=iconHeight/2;labelTop=targetDivPos.y+gMap.getPane(G_MAP_MAP_PANE).parentNode.offsetTop+iconHeight;}
else
labelTop -=3;var absPos=getAbsolutePositionOf(gMap.getContainer());subjectLabel.style.left=absPos[0]+labelLeft+"px";subjectLabel.style.top=absPos[1]+labelTop+"px";return ver_pos;}
function focusOnNeighbourhood(lng,lat,zoom){PerformTimer=new Date();if(addressLabel !=null){gMap.removeTLabel(addressLabel);addressLabel=null;}
currAddrLblLoc=null;showResultOptions();var loc=new Location(null,new GLatLng(lat,lng));if(!zoom)zoom=neighbourhoodZoom;focusOnLocation(loc,zoom);}
function focusOnAddress(addr,zoom,geocoder,text){if(!gMap)return false;PerformTimer=new Date();if(geocoder==null || typeof geocoder=='undefined')geocoder=MAP_GEOCODE;if(addressLocationCache[addr] !=null){loc=addressLocationCache[addr];}
else{if(MAP_GEOCODE=="google" && geocoder=='google'){currAddress=addr;currAddress2='';if(text)if(text !='')currAddress2=text;if(addr.indexOf(" "+CITY_NAME)==-1){if(CITY_NAME=="New York")addr+=", Manhattan";addr+=", "+CITY_NAME;}
if(addr.indexOf(" "+CITY_STATE)==-1)addr+=", "+CITY_STATE;currZoom=zoom;if(gGeocoder)gGeocoder.getLocations(addr,doneGoogleGeocode);return true;}
else{loc=getLocationFromAddress(addr);if(loc==null){alert("Could not find "+CITY_NAME+" City location:\n"+addr);jserror(2,addr);return false;}
if(text)if(text !='')loc.address=text;addressLocationCache[addr]=loc;}}
showResultOptions();focusOnLocation(loc,zoom);return true;}
function doneGoogleGeocode(response){if(!response || response.Status.code !=200){focusOnAddress(currAddress,null,'yahoo',currAddress2);jserror(4,currAddress+"(redirected)");}
else{place=response.Placemark[0];var arrAddr=place.address.split(",");var locAddress=arrAddr[0];var loc=new Location(locAddress,new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]));showResultOptions();if(currAddress2 !='')loc.address=currAddress2;focusOnLocation(loc,currZoom);addressLocationCache[currAddress]=loc;}}
function focusOnSelectedAttraction(){if(selectedAttractionOpt==null){alert('Please select an attraction.');return false;}
PerformTimer=new Date();var name=selectedAttractionOpt.value.split("@")[0];var addr=selectedAttractionOpt.value.split("@")[1];if(addr !="")name+="<br>"+addr+"";var coords=selectedAttractionOpt.value.split("@")[2].split(",");var loc=new Location(name,new GLatLng(coords[0],coords[1]));showResultOptions();focusOnLocation(loc);return true;}
function focusOnLocation(loc,zoom,iconImage){if(!gMap)return false;DisplayElem("search_results","block");if(STREET_CASE)DisplaySearchSidePanel();DisplayElem("garage_list_div","none");if(globJSBrowser !="Safari")document.getElementsByName("#level2")[0].scrollIntoView();HideAllGarages();if(loc.address !=null)currAddrLblLoc=loc;gMap.setCenter(loc.latLng,(zoom !=null)?zoom:defaultPointZoom);if(lastSelectedGarage !=null)lastSelectedGarage.deselect();}
function ByAllManhattan(numManh){PerformTimer=new Date();DisplayElem("garage_list_div","none");showResultOptions();if(globJSBrowser !="Safari")document.getElementsByName("#level2")[0].scrollIntoView();num_currAllManh=numManh;if(parking_vehicle==VEHICLE_MOTORCYCLE)var loc_exists=arrAllManhattanMC[num_currAllManh];else
var loc_exists=arrAllManhattan[num_currAllManh];if(!loc_exists){sort_results=SORT_RATE;InitPopMap();fetchGaragesAroundBounds(0,numManh);}
else{listGarages(numManh);}};function CreateAddressLabel(){if(currAddrLblLoc==null)return;try{if(addressLabel !=null){gMap.removeTLabel(addressLabel);addressLabel=null;}
addressLabel=new TLabel();addressLabel.id="label_address";addressLabel.anchorLatLng=currAddrLblLoc.latLng;gMap.addTLabel(addressLabel);addressLabel.layer.style.zIndex=2;addressLabel.setImage(PATH_IMG+"images/marker_address.gif");addressLabel.layer.onmouseover=function(){var addressDetailLabel=document.getElementById("address_detail_label");moveDetailLabelToLatLng(addressDetailLabel,currAddrLblLoc);DisplayElem("address_detail_label","visible");};addressLabel.layer.onmouseout=function(){DisplayElem("address_detail_label","hidden");};var addressDetailLabel=document.getElementById("address_detail_label");DisplayElem("address_detail_label","hidden");GetElement('address_detail_label_cont').innerHTML=currAddrLblLoc.address;}catch(e){}}
function TextualZoomControl(){}
TextualZoomControl.prototype=new GControl();TextualZoomControl.prototype.initialize=function(map){var container=document.createElement("div");controlZoom=container;var zoomZoom=document.createElement("div");zoomZoom.className="zoomButton";setOpacityCompat(zoomZoom,0.9);container.appendChild(zoomZoom);zoomZoom.appendChild(document.createTextNode("Zoom:"));zoomZoom.style.marginRight="4px";zoomZoom.style.cursor="default";zoomZoom.style.width="58px";var zoomInDiv=document.createElement("div");zoomInDiv.id="zoomInDiv";zoomInDiv.className="zoomButton";if(defaultPointZoom==maxZoom)zoomInDiv.className+=" zoomButtonDis";setOpacityCompat(zoomInDiv,0.9);container.appendChild(zoomInDiv);zoomInDiv.appendChild(document.createTextNode("+"));zoomInDiv.style.marginRight="4px";zoomInDiv.style.width="25px";GEvent.addDomListener(zoomInDiv,"click",function(){if(gMap.getZoom()==maxZoom)return false;EnableZoom(1);HideAllGarages();flagMapMovingPanZoom=true;gMap.zoomIn();});var zoomOutDiv=document.createElement("div");zoomOutDiv.id="zoomOutDiv";zoomOutDiv.className="zoomButton";if(defaultPointZoom==minZoom)zoomOutDiv.className+=" zoomButtonDis";setOpacityCompat(zoomOutDiv,0.9);container.appendChild(zoomOutDiv);zoomOutDiv.appendChild(document.createTextNode(String.fromCharCode(8722)));zoomOutDiv.style.width="25px";zoomOutDiv.style.fontWeight="900";GEvent.addDomListener(zoomOutDiv,"click",function(){if(gMap.getZoom()==minZoom){return false;}
EnableZoom(-1);HideAllGarages();flagMapMovingPanZoom=true;gMap.zoomOut();});gMap.getContainer().appendChild(container);return container;}
TextualZoomControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(3,3));}
function EnableZoom(addVal){var currZoom=parseInt(gMap.getZoom())+addVal;if(addVal==0)currZoom=defaultPointZoom;if(currZoom==minZoom)GetElement("zoomOutDiv").className="zoomButton zoomButtonDis";else
GetElement("zoomOutDiv").className="zoomButton";if(currZoom==maxZoom)GetElement("zoomInDiv").className="zoomButton zoomButtonDis";else
GetElement("zoomInDiv").className="zoomButton";}
function SetZooms(isDaily){if(!STREET_CASE)return;if(isDaily){minZoom=16;defaultPointZoom=neighbourhoodZoom=16;}
else{minZoom=15;defaultPointZoom=neighbourhoodZoom=16;}
EnableZoom(0);}
function PanArrowsControl(){}
PanArrowsControl.prototype=new GControl();PanArrowsControl.prototype.initialize=function(map){var container=gMap.getContainer();var arrowDiv,arrowImg,arrowTextDiv;arrowDiv=document.createElement("div");controlNorth=arrowDiv;container.appendChild(arrowDiv);this.setButtonStyle_(arrowDiv);arrowDiv.style.left="46%";arrowDiv.style.top="0px";arrowDiv.style.margin="0 auto 0 auto";arrowImg=document.createElement("img");arrowDiv.appendChild(arrowImg);arrowImg.src=PATH_IMG+"images/pan_up_c.gif";arrowTextDiv=document.createElement("div");arrowDiv.appendChild(arrowTextDiv);arrowTextDiv.appendChild(document.createTextNode("North"));this.setTextStyle_(arrowTextDiv);GEvent.addDomListener(arrowDiv,"click",function(){gMap.panDirection(-PAN_NUMBER_1,1);flagMapMovingPanZoom=true;});arrowDiv=document.createElement("div");arrowDiv.className="mapArrE";container.appendChild(arrowDiv);this.setButtonStyle_(arrowDiv);arrowDiv.style.right="0px";arrowDiv.style.top=((gMap.getSize().height - arrowDiv.offsetHeight)/ 2)+"px";arrowTextDiv=document.createElement("div");arrowDiv.appendChild(arrowTextDiv);arrowTextDiv.style.cssFloat=arrowTextDiv.style.styleFloat="left";arrowTextDiv.appendChild(document.createTextNode("East"));this.setTextStyle_(arrowTextDiv);arrowImg=document.createElement("img");arrowDiv.appendChild(arrowImg);arrowImg.src=PATH_IMG+"images/pan_right_c.gif";arrowImg.style.cssFloat=arrowImg.style.styleFloat="left";arrowImg.style.margin="7px 0 0 0";GEvent.addDomListener(arrowDiv,"click",function(){gMap.panDirection(-1,-PAN_NUMBER_2);flagMapMovingPanZoom=true;});arrowDiv=document.createElement("div");controlSouth=arrowDiv;container.appendChild(arrowDiv);this.setButtonStyle_(arrowDiv);arrowDiv.style.left="46%";arrowDiv.style.bottom="0px";arrowDiv.style.margin="0 auto 0 auto";arrowTextDiv=document.createElement("div");arrowDiv.appendChild(arrowTextDiv);arrowTextDiv.appendChild(document.createTextNode("South"));this.setTextStyle_(arrowTextDiv);arrowImg=document.createElement("img");arrowDiv.appendChild(arrowImg);arrowImg.src=PATH_IMG+"images/pan_down_c.gif";GEvent.addDomListener(arrowDiv,"click",function(){gMap.panDirection(PAN_NUMBER_1,-1);flagMapMovingPanZoom=true;});arrowDiv=document.createElement("div");arrowDiv.id="mapArrW";arrowDiv.className="mapArrW";container.appendChild(arrowDiv);this.setButtonStyle_(arrowDiv);arrowDiv.style.left="0px";arrowDiv.style.top=((gMap.getSize().height - arrowDiv.offsetHeight)/2)+"px";arrowImg=document.createElement("img");arrowDiv.appendChild(arrowImg);arrowImg.src=PATH_IMG+"images/pan_left_c.gif";arrowImg.style.cssFloat=arrowImg.style.styleFloat="left";arrowImg.style.margin="7px 0 0 0";arrowTextDiv=document.createElement("div");arrowDiv.appendChild(arrowTextDiv);arrowTextDiv.style.cssFloat=arrowTextDiv.style.styleFloat="left";arrowTextDiv.appendChild(document.createTextNode("West"));this.setTextStyle_(arrowTextDiv);GEvent.addDomListener(arrowDiv,"click",function(){gMap.panDirection(1,PAN_NUMBER_2);flagMapMovingPanZoom=true;});return document.createElement("div");}
PanArrowsControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(0,0));}
PanArrowsControl.prototype.setButtonStyle_=function(button){button.style.position="absolute";button.style.cursor="pointer";button.style.textAlign="center";}
PanArrowsControl.prototype.setTextStyle_=function(button){button.style.color="000096";button.style.fontSize="20px";button.style.fontWeight="bold";button.style.textAlign="center";button.style.backgroundColor="white";button.style.margin="0px";button.style.padding="2px 5px 2px 5px";setOpacityCompat(button,0.9);}
var addrW='350px';if(navigator.userAgent.indexOf("MSIE")>-1)addrW='100%';document.write('<table id="address_detail_label" class="menu_pop_red plain" cellspacing="0" '+'style="position:absolute;visibility:hidden;display:block!important;z-index:3015;width:200px;">'+'<tr><td class="tl_mb_red"><img src="'+PATH_IMG+'images/blank.gif" width="9"></td>'+'<td class="bar_mb_red" rowspan="2" width="'+addrW+'"></td><td class="tr_mb_red"><img src="'+PATH_IMG+'images/blank.gif" width="9"></td></tr>'+'<tr class="bar_mb_red" style="height:3px;"><td></td><td></td></tr>'+'<tr><td colspan="3" id="address_detail_label_cont" class="main" style="text-align:center;padding:4px;color:#191919;font-size:13px;">'+'</td></tr>'+'<tr class="bar_mb_red" style="height:3px;"><td></td><td rowspan="2">'+'</td><td></td></tr>'+'<tr><td class="bl_mb_red"></td><td class="br_mb_red"></td></tr>'+'</table>');
