var globalMapState=null;function distance(J,G,H){var C=Math.PI*J.getLat()/180;var B=Math.PI*G.getLat()/180;var E=Math.PI*J.getLng()/180;var D=Math.PI*G.getLng()/180;var A=J.getLng()-G.getLng();var I=Math.PI*A/180;var F=Math.sin(C)*Math.sin(B)+Math.cos(C)*Math.cos(B)*Math.cos(I);F=Math.acos(F);F=F*180/Math.PI;F=F*60*1.1515;if(H=="K"){F*=1.609344}if(H=="N"){F*=0.8684}return F}var GlobalBaseIcon=null;function getBaseIcon(A){var B;if(A){B=new GIcon()}else{if(GlobalBaseIcon==null){GlobalBaseIcon=new GIcon()}B=GlobalBaseIcon}B.shadow="http://www.google.com/mapfiles/shadow50.png";B.iconSize=new GSize(37,39);B.shadowSize=new GSize(37,39);B.iconAnchor=new GPoint(18,34);B.infoWindowAnchor=new GPoint(9,2);B.infoShadowAnchor=new GPoint(18,25);return B}function DestinationInfo(M,O,K,F,H,B,C,L,E,D,A,G,J,I,N){this.lat=M;this.lng=O;this.entityUrl=K;this.id=F;this.photoParams=H;this.destType=B;this.name=C;this.startDay=L;this.endDay=E;this.treeNodeId=A;this.zoomedIn=D;this.minLongitude=G;this.maxLongitude=J;this.minLatitude=I;this.maxLatitude=N;this.point=new Point(M,O)}DestinationInfo.Site="site";DestinationInfo.Activity="activity";DestinationInfo.Hotel="hotel";DestinationInfo.Restaurant="restaurant";DestinationInfo.Flight="flight";DestinationInfo.Car="car";DestinationInfo.referencePoint="referencePoint";DestinationInfo.prototype.getLat=function(){return this.lat};DestinationInfo.prototype.getLng=function(){return this.lng};DestinationInfo.prototype.getPoint=function(){return this.point};DestinationInfo.prototype.getId=function(){return this.id};DestinationInfo.prototype.getPhotoParams=function(){return this.photoParams};DestinationInfo.prototype.getDestType=function(){return this.destType};DestinationInfo.prototype.getName=function(){return this.name};DestinationInfo.prototype.getLabel=function(){return new Label(new GLatLng(this.lat,this.lng),'<div class="map_tooltip" style="white-space: nowrap">'+this.name+"</div>",0.85,null,-30,-40)};DestinationInfo.prototype.getIcon=function(D,B,C){var E=getBaseIcon(C);E.shadow="images/map/shadow.png";var A="";if(B){A="_"+D}else{A="_0"}if(this.destType==DestinationInfo.Site){E.image="images/map/location"+A+".png"}else{if(this.destType==DestinationInfo.Activity){E.image="images/map/activity"+A+".png"}else{if(this.destType==DestinationInfo.Hotel){E.image="images/map/hotel"+A+".png"}else{if(this.destType==DestinationInfo.Restaurant){E.image="images/map/rest"+A+".png"}else{if(this.destType==DestinationInfo.Car){E.image="images/map/car"+A+".png"}else{if(this.destType==DestinationInfo.Flight){E.image="images/map/flight"+A+".png"}else{if(this.destType==DestinationInfo.referencePoint){E.image="images/map/flight_0.png"}}}}}}}return E};DestinationInfo.prototype.getInfoWindowHTML=function(){var A='<div align="center"><table cellpadding="0" cellspacing="2" style="padding:8x; width:300px "><tr><td colspan="2" class="text"><b>'+this.getName()+'</b></td></tr><tr><td valign="bottom"  style="width:20%"><TABLE style="border:1px #E4E4E6 solid;" cellpadding="4" cellspacing="0"><TR><TD><img '+this.getPhotoParams()+' width="120" height="90"/></TD></TR></TABLE></td><td valign="bottom"><div class="ver_space" style="height:6px">&nbsp;</div><div class="ver_space" style="height:6px">&nbsp;</div><div class="text"><b>Search nearby:</b></div><a onclick="c_on_search_activity_click('+this.startDay+", '"+this.id+'\');" class="more">Things to do</a><br><a onclick="c_on_search_hotel_click('+this.startDay+", '"+this.id+'\');" class="more">Accommodations</a><br><a onclick="c_on_search_restaurant_click('+this.startDay+", '"+this.id+'\');" class="more">Restaurants</a><br></td></tr><tr><td colspan="2" class="text"><table cellpadding="0" cellspacing="0" style="width:100%" cellpadding="0" cellspacing="0"><tr><td align="right">';var B=null;if(this.treeNodeId!=null){B="onclick=\"Itinerary.getItiNode('"+this.treeNodeId+"').selectItem(true, 'details');\""}else{if(this.entityUrl!=null){B='href="'+this.entityUrl+'"'}}if(B!=null){A+="<a "+B+' class="more">Details</a>'}A+="</td></tr></table></td></tr></table></div>";return A};DestinationInfo.prototype.getStartDay=function(){return this.startDay};DestinationInfo.prototype.getEndDay=function(){return this.endDay};function MapState(A,B,C){this.items=A;this.showTypes=new Array();this.showTypeStates=new Array();this.overlayContainerArr=new Array();this.showDays=-1;this.divName=B;this.onClickHandler=null;this.showMarkersBoundsIfMouseOver=false;this.isNeedOverview=false;this.showNumberedIcons=false;this.subRoutes=C;this.map=new GMap2(document.getElementById(B));this.initMap();this.geocoder=new GClientGeocoder();this.largeMapControl=null;this.mapTypeControl=new GMapTypeControl();this.smallMapControl=new GSmallMapControl();this.scaleControl=new GScaleControl();this.map.enableDoubleClickZoom();this.mapRouteControl=null}var itemMaxZoomLevel=15;var locationMaxZoomLevel=11;MapState.prototype.getMaxZoom=function(B,C){var A=C?locationMaxZoomLevel:itemMaxZoomLevel;return Math.min(B,A)};MapState.prototype.getItems=function(){return this.items};MapState.prototype.setItems=function(A){this.items=A};MapState.prototype.getShowTypes=function(){return this.showTypes};MapState.prototype.getShowDays=function(){return this.showDays};MapState.prototype.setShowDays=function(A){this.showDays=A};MapState.prototype.getDivName=function(){return this.divName};MapState.prototype.setDivName=function(A){this.showDays=A};MapState.prototype.getNeedOverview=function(){return this.isNeedOverview};MapState.prototype.setNeedOverview=function(A){this.isNeedOverview=A};MapState.prototype.getPlaceholderDivId=function(){return this.placeholderDivId};MapState.prototype.setPlaceholderDivId=function(A){this.placeholderDivId=A};MapState.prototype.isTypeVisible=function(A){for(var B=0;B<this.showTypes.length;B++){if(this.showTypes[B]==A){return this.showTypeStates[B]}}};MapState.prototype.setShowTypesAndState=function(A,C){for(var B=0;B<this.showTypes.length;B++){if(this.showTypes[B]==A){this.showTypeStates[B]=C;return }}};MapState.prototype.addShowTypesAndState=function(A,B){this.showTypes[this.showTypes.length]=A;this.showTypeStates[this.showTypeStates.length]=B};MapState.prototype.getOverlayContainers=function(){return this.overlayContainerArr};MapState.prototype.setOverlayContainers=function(A){this.overlayContainerArr=A};MapState.prototype.setOnClickHandler=function(A){this.onClickHandler=A;if(this.getOnClickHandler()!=null){GEvent.addListener(this.map,"click",this.getOnClickHandler())}};MapState.prototype.setShowMarkersBoundsIfMouseOver=function(A){this.showMarkersBoundsIfMouseOver=A};MapState.prototype.getOnClickHandler=function(){return this.onClickHandler};MapState.prototype.getSubRoutes=function(){return this.subRoutes};MapState.prototype.setSubRoutes=function(A){this.subRoutes=A};MapState.prototype.getMarker=function(D){var B=this.getItems();for(var C=0;C<B.length;C++){var A=B[C];if(A.getId()==D){return this.getOverlayContainers()[C].getMarker()}}return null};MapState.prototype.centerOnPoint=function(C,B){var A=this.getMarker(C);if(A==null){return }if(B){A.openInfoWindowHtml(A.destInfo.getInfoWindowHTML())}else{this.centerOnMarker(A)}};MapState.prototype.centerOnMarker=function(B){var A=B.destInfo;this.map.panTo(new GLatLng(A.getLat(),A.getLng()))};MapState.prototype.drawMapRectangle=function(C,G,F,H,D,E){var J=[];J.push(new GLatLng(F,C));J.push(new GLatLng(F,G));J.push(new GLatLng(H,G));var I=[];I.push(new GLatLng(H,G));I.push(new GLatLng(H,C));I.push(new GLatLng(F,C));var B=new GPolyline(J,D,E);var A=new GPolyline(I,D,E);this.map.addOverlay(B);this.map.addOverlay(A);return new Array(B,A)};MapState.prototype.removeMapRectanlge=function(A){if(A!=null&&A.length==2){this.map.removeOverlay(A[1]);this.map.removeOverlay(A[0])}};MapState.prototype.drawNavControls=function(A){if(disableMapForPerformaceText){return }if(this.mapRouteControl!=null){this.map.removeControl(this.mapRouteControl)}if(this.largeMapControl!=null){this.map.removeControl(this.largeMapControl);this.largeMapControl=null}if(A){this.map.removeControl(this.mapTypeControl);this.map.addControl(this.smallMapControl);this.map.removeControl(this.scaleControl)}else{this.map.removeControl(this.smallMapControl);this.largeMapControl=new GLargeMapControl();this.map.addControl(this.largeMapControl);this.map.addControl(this.mapTypeControl);this.map.addControl(this.scaleControl)}};MapState.prototype.drawTripMap=function(C,G,F,L,M,B,K,H){if(disableMapForPerformaceText){return }this.drawNavControls(M);this.showNumberedIcons=K;var A=null;if(C!=null){A=new GLatLngBounds(new GLatLng(F,C),new GLatLng(L,G))}var I=false;var J=this.getItems();for(var E=0;E<J.length;E++){var P=J[E];if(P.destType=="site"){I=true}if(P.zoomedIn){if(P.minLongitude){var O=new GLatLng(P.minLatitude,P.minLongitude);var D=new GLatLng(P.maxLatitude,P.maxLongitude);if(A==null){A=new GLatLngBounds(O,D)}else{A.extend(O);A.extend(D)}}else{var N=new GLatLng(P.getLat(),P.getLng());if(A==null){A=new GLatLngBounds(N)}else{A.extend(N)}}}}this.updateMap(!M);if(!A){A=new GLatLngBounds()}if(!H){this.map.setZoom(this.getMaxZoom(this.map.getBoundsZoomLevel(A),I));if(B!=null){this.centerOnPoint(B,true)}else{this.map.panTo(A.getCenter())}}};MapState.prototype.updateMap=function(D){var C=this.getItems();this.map.closeInfoWindow();this.map.clearOverlays();this.setOverlayContainers(new Array());for(var E=0;E<C.length;E++){var A=C[E];var B=this.createMarker(A,A.getIcon(E+1,this.showNumberedIcons,false),D,false);this.getOverlayContainers()[E]=new OverlayCont(B);this.map.addOverlay(B)}};MapState.prototype.createMarker=function(F,G,E,D){var I=F.getPoint().getGooglePoint();var B=new GMarker(I,{icon:G});B.destInfo=F;var A=this;var H=F.getLabel();var C;if(E){GEvent.addListener(B,"click",function(){A.centerOnMarker(B);B.openInfoWindowHtml(F.getInfoWindowHTML(),{maxWidth:300})})}if(H!=null){GEvent.addListener(B,"mouseover",function(J){A.map.addOverlay(H);if(D){A.map.addOverlay(B)}if((A.showMarkersBoundsIfMouseOver)&&(F.minLongitude!=null)){C=A.drawMapRectangle(F.minLongitude,F.maxLongitude,F.minLatitude,F.maxLatitude,"#FF0000",3)}if(!J&&F.treeNodeId!=null&&typeof Itinerary!=="undefined"){Itinerary.getItiNode(F.treeNodeId).onMouseOver(true)}});GEvent.addListener(B,"mouseout",function(J){A.map.removeOverlay(H);if(D){A.map.removeOverlay(B)}if((A.showMarkersBoundsIfMouseOver)&&(F.minLongitude!=null)){A.removeMapRectanlge(C)}if(!J&&F.treeNodeId!=null&&typeof Itinerary!=="undefined"){Itinerary.getItiNode(F.treeNodeId).onMouseOut(true)}})}return B};MapState.prototype.drawRoutes=function(H){if(this.subRoutes==null||this.subRoutes=="undefined"){return }if(GBrowserIsCompatible()){this.initMap();var A=new GLatLngBounds();for(var F=0;F<this.subRoutes.length;F++){var G=this.subRoutes[F];var B=G.getGooglePolyLine();this.map.addOverlay(B,"#FF0000",5);var D=G.getInstructions();for(var C=0;C<D.length;C++){var K=D[C].getPoint();A.extend(K.getGooglePoint());if(H!=null&&H!="undefined"&&H){var E=null;if(C==0){E=this.createMarker(D[C],D[C].getStartIcon(),false,false)}else{if(C+1==D.length){E=this.createMarker(D[C],D[C].getFinishIcon(),false,false)}}if(E!=null){this.map.addOverlay(E)}}}}this.map.setZoom(this.getMaxZoom(this.map.getBoundsZoomLevel(A)));var I=(A.getNorthEast().lat()+A.getSouthWest().lat())/2;var J=(A.getNorthEast().lng()+A.getSouthWest().lng())/2;this.map.setCenter(new GLatLng(I,J))}};MapState.prototype.initMap=function(){if(this.getNeedOverview()){this.map.addControl(new GOverviewMapControl(new GSize(200,200)))}this.map.setCenter(new GLatLng(0,0),0)};MapState.prototype.addMapEventListener=function(A,B){GEvent.addListener(this.map,A,B)};MapState.prototype.geocode=function(A,B){this.geocoder.getLatLng(A,B)};MapState.prototype.filterPointsByType=function(){var A=this.getShowTypes();var E=this.getItems();var G=new Array();var C=0;var H=this.getShowDays();if(A==null||A.length==0){return mapItems}for(var D=0;D<A.length;D++){var F=A[D];if(!this.isTypeVisible(F)){continue}for(var B=0;B<E.length;B++){var I=E[B];if(F==I.getDestType()&&(H==-1||(H>=I.getStartDay()&&H<=I.getEndDay()))){G[C++]=I}}}return G};MapState.prototype.triggerMarkerEvent=function(C,B){if(this.map.getContainer().style.display=="none"){return }var A=this.getMarker(C);if(A!=null){GEvent.trigger(A,B,true)}};MapState.prototype.addMapRouteControl=function(E,B,D,A,C){if(C){this.map.removeControl(this.mapTypeControl)}this.mapRouteControl=new RouteMapControl(E,B,D,A);this.map.addControl(this.mapRouteControl)};function getGlobalMap(B){updateGlobalMapStyle(B);var A=document.getElementById(B);document.getElementById("globalMap").style.display="";if(globalMapState==null){globalMapState=new MapState(null,"globalMap")}else{globalMapState.map.checkResize();GEvent.clearListeners(globalMapState.map,"click")}globalMapState.setPlaceholderDivId(B);return globalMapState}function updateGlobalMapStyle(D){var C=document.getElementById("globalMap").style;var B=document.getElementById(D);var A=YAHOO.util.Dom.getXY(B);C.left=A[0]+"px";C.top=A[1]+"px";C.width=B.style.width;C.height=B.style.height}function repositionGlobalMap(){if(globalMapState){var A=document.getElementById(globalMapState.getPlaceholderDivId());if(A!=null&&A.style.display!="none"){updateGlobalMapStyle(globalMapState.getPlaceholderDivId());globalMapState.map.checkResize();setTimeout(function(){updateGlobalMapStyle(globalMapState.getPlaceholderDivId())},100)}}}function showGlobalMap(){if(globalMapState!=null){globalMapState.map.getContainer().style.display=""}}function hideGlobalMap(){if(globalMapState==null){return }var A=globalMapState.map.getContainer().style;if(A.display=="none"){return }A.display="none"}function Label(A,E,B,D,C,F){this.point=A;this.content=E||"";this.css_class=D||"";this.opacity=B||0.5;this.xOffset=C||0;this.yOffset=F||0}Label.prototype=new GOverlay();Label.prototype.initialize=function(A){var B=document.createElement("div");B.style.position="absolute";B.innerHTML='<div class="'+this.css_class+'">'+this.content+"</div>";A.getPane(G_MAP_FLOAT_SHADOW_PANE).appendChild(B);this.map_=A;this.div_=B;if(typeof (B.style.filter)=="string"){B.style.filter="alpha(opacity:"+(this.opacity*100)+")"}if(typeof (B.style.KHTMLOpacity)=="string"){B.style.KHTMLOpacity=this.opacity}if(typeof (B.style.MozOpacity)=="string"){B.style.MozOpacity=this.opacity}if(typeof (B.style.opacity)=="string"){B.style.opacity=this.opacity}};Label.prototype.remove=function(){this.div_.parentNode.removeChild(this.div_)};Label.prototype.copy=function(){return new Label(this.point,this.content,this.css_class,this.opacity)};Label.prototype.redraw=function(B){var C=this.map_.fromLatLngToDivPixel(this.point);var A=parseInt(this.div_.clientHeight);this.div_.style.left=(C.x+this.xOffset)+"px";this.div_.style.top=((C.y+this.yOffset)-A)+"px"};function OverlayCont(A){this.marker=A}OverlayCont.prototype.getMarker=function(){return this.marker};function onTypeFilterChange(C,A){if(mapState==null||mapState=="undefined"){return }var B=mapState.getShowTypes();if(B==null||mapState.getItems()==0||mapState.getItems().length==0){return }mapState.setShowTypesAndState(C,A);mapState.drawTripMap()}function onDayFilterChange(B){if(mapState==null||mapState=="undefined"){return }if(mapState.getItems()==0||mapState.getItems().length==0){return }var A=-1;if(B!="all"){A=B}mapState.setShowDays(A);mapState.drawTripMap()}function splitByDay(A,H){var G=new Array();var E=new Array();for(var D=0;D<A.length;D++){var F=A[D];for(var C=F.getStartDay();C<=F.getEndDay();C++){var B=E[C];if(B==null||typeof (B)=="undefined"){B=new Array();E[C]=B}B[B.length]=F}}for(var D=1;D<E.length;D++){var B=E[D];if(B!=null&&typeof (B)!="undefined"){G[G.length]=buildMapState(B,H+D,D)}}return G}function buildMapState(C,D,A){var B=new MapState(C,D);B.addShowTypesAndState(DestinationInfo.Site,true);B.addShowTypesAndState(DestinationInfo.Activity,true);B.addShowTypesAndState(DestinationInfo.Hotel,true);B.addShowTypesAndState(DestinationInfo.Restaurant,true);B.addShowTypesAndState(DestinationInfo.Flight,true);B.addShowTypesAndState(DestinationInfo.Car,true);B.setNeedOverview(false);B.setShowDays(A);return B}function Point(B,A){this.lat=B;this.lng=A}Point.prototype.getLat=function(){return this.lat};Point.prototype.setLat=function(A){this.lat=A};Point.prototype.getLng=function(){return this.lng};Point.prototype.setLng=function(A){this.lng=A};Point.prototype.getGooglePoint=function(){return new GLatLng(this.lat,this.lng)};function RouteInstruction(B,A,C){this.point=B;this.instruction=A;this.distance=C}RouteInstruction.prototype.getPoint=function(){return this.point};RouteInstruction.prototype.setPoint=function(A){this.point=A};RouteInstruction.prototype.getInstruction=function(){return this.instruction};RouteInstruction.prototype.setInstruction=function(A){this.instruction=A};RouteInstruction.prototype.getDistance=function(){return this.distance};RouteInstruction.prototype.setDistance=function(A){this.distance=A};RouteInstruction.prototype.getLabel=function(A){return null};RouteInstruction.prototype.getIcon=function(){var A=getBaseIcon(false);A.image="http://labs.google.com/ridefinder/images/mm_20_red.png";return A};RouteInstruction.prototype.getDDBaseIcon=function(){var A=new GIcon();A.shadow="http://www.google.com/mapfiles/shadow50.png";A.iconSize=new GSize(20,34);A.shadowSize=new GSize(37,34);A.iconAnchor=new GPoint(9,34);A.infoWindowAnchor=new GPoint(9,2);A.infoShadowAnchor=new GPoint(18,25);return A};RouteInstruction.prototype.getStartIcon=function(){var A=this.getDDBaseIcon();A.image="http://www.google.com/mapfiles/dd-start.png";return A};RouteInstruction.prototype.getFinishIcon=function(){var A=this.getDDBaseIcon();A.image="http://www.google.com/mapfiles/dd-end.png";return A};RouteInstruction.prototype.getInfoWindowHTML=function(){var A='<div id="popup"><table><tr><td><b>';A+=this.getInstruction();A+="</td><td><b>"+this.getDistance()+"<b></td></tr></table></div>";return A};function SubRoute(B,A){this.points=B;this.instructions=A}SubRoute.prototype.getPoints=function(){return this.points};SubRoute.prototype.setPoints=function(A){this.points=A};SubRoute.prototype.getInstructions=function(){return this.instructions};SubRoute.prototype.setInstructions=function(A){this.instructions=A};SubRoute.prototype.getGooglePolyLine=function(){var B=new Array();for(var A=0;A<this.points.length;A++){B[A]=new GLatLng(this.points[A].getLat(),this.points[A].getLng())}return new GPolyline(B)};function LocalSearch(B,A){this.localSearch=new GlocalSearch();this.mapState=B;this.resultsDivId=A;this.localSearch.setSearchCompleteCallback(this,LocalSearch.prototype.onSearchComplete);this.localSearch.setResultSetSize(GSearch.LARGE_RESULTSET);this.localSearch.setNoHtmlGeneration();this.markerList=new Array()}LocalSearch.prototype.startSearch=function(C,A,B){if(A!=null){this.localSearch.setCenterPoint(A)}this.selectResultCallback=B;this.localSearch.execute(C)};LocalSearch.prototype.onNoResults=function(){};LocalSearch.prototype.onSearchComplete=function(){var E=this.localSearch.results;if(E&&E.length>0){this.drawResults(E);var A=new GLatLngBounds();var I=new GIcon();I.shadow="http://www.google.com/mapfiles/shadow50.png";I.iconSize=new GSize(20,34);I.shadowSize=new GSize(37,34);I.iconAnchor=new GPoint(9,34);I.infoWindowAnchor=new GPoint(9,2);I.infoShadowAnchor=new GPoint(18,25);for(var F=0;F<E.length;F++){var J=E[F];if(J.GsearchResultClass==GlocalSearch.RESULT_CLASS){var D=String.fromCharCode("A".charCodeAt(0)+F);var C=new GIcon(I);C.image="http://www.google.com/mapfiles/marker"+D+".png";var B={icon:C};var G=new Object();G.result=J;G.latLng=new GLatLng(parseFloat(J.lat),parseFloat(J.lng));G.gmarker=new GMarker(G.latLng,B);var H=method_closure(this,LocalSearch.prototype.OnMarkerClick,[G]);GEvent.bind(G.gmarker,"click",this,H);this.markerList.push(G);this.mapState.map.addOverlay(G.gmarker);J.__markerObject__=G;A.extend(G.latLng)}}this.mapState.map.setZoom(this.mapState.map.getBoundsZoomLevel(A));this.mapState.map.panTo(A.getCenter())}else{this.onNoResults()}};LocalSearch.prototype.drawResults=function(D){var E=document.createElement("table");var B=document.createElement("tbody");document.getElementById(this.resultsDivId).appendChild(E);E.appendChild(B);E.setAttribute("border","0");E.setAttribute("cellPadding","0");E.setAttribute("cellSpacig","0");E.setAttribute("width","100%");E.style.fontSize="11px";E.style.paddingRight="5px";for(var C=0;C<D.length&&C<8;C++){var A=D[C];this.drawResult(A,B,C)}};LocalSearch.prototype.drawResult=function(M,C,D){var K=buildAddressStr(M.streetAddress,M.city,M.regoin,M.country);var H=document.createElement("a");H.href=M.url;H.target="_blank";H.className="localSearchLink";H.setAttribute("textDecoration","underline");H.innerHTML=M.titleNoFormatting;var L=document.createElement("tr");var I=document.createElement("td");I.setAttribute("rowSpan","2");var F="http://www.google.com/mapfiles/marker"+String.fromCharCode("A".charCodeAt(0)+D)+".png";I.innerHTML='<img src="'+F+'"/>';var G=document.createElement("td");G.appendChild(H);var E=document.createElement("td");var A="localResultCooseButton"+C.childNodes.length;E.innerHTML='<input id="'+A+'" type="button" value="Choose" onclick="'+this.selectResultCallback+'(this.result)" class="inputbutton" style="width: 50px;"/>';E.setAttribute("width","40px");E.setAttribute("paddingTop","3px");E.style.paddingTop="3px";L.appendChild(I);L.appendChild(G);L.appendChild(E);var J=document.createElement("tr");var B=document.createElement("td");B.setAttribute("colSpan","2");B.innerHTML=K;J.appendChild(B);C.appendChild(L);C.appendChild(J);document.getElementById(A).result=M};LocalSearch.prototype.OnMarkerClick=function(A){this.mapState.map.closeInfoWindow();var B=A.result.html.cloneNode(true);A.gmarker.openInfoWindow(B)};function RouteMapControl(D,C,B,A){this.mapClickCallback=D;this.routeClickCallback=C;this.onShowDrivingDirections_callbackName=B;this.isMap=A}RouteMapControl.prototype=new GControl();RouteMapControl.prototype.initialize=function(F){var D=document.createElement("div");D.className="map_button_control_top";var C=document.createElement("div");C.className="map_view_div";C.innerHTML="View: ";D.appendChild(C);var E=document.createElement("div");E.appendChild(document.createTextNode("Map"));if(this.isMap){E.className="map_button_control map_button_control_selected"}else{E.className="map_button_control map_button_control_unselected"}D.appendChild(E);var B=document.createElement("div");B.className="map_button_control";B.appendChild(document.createTextNode("Route"));if(!this.isMap){B.className="map_button_control map_button_control_selected"}else{B.className="map_button_control map_button_control_unselected"}D.appendChild(B);if(!this.isMap){var A=document.createElement("div");A.innerHTML='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="blue_11" href="javascript:'+this.onShowDrivingDirections_callbackName+'();">View Driving Directions</a>';D.appendChild(A)}GEvent.addDomListener(E,"click",this.mapClickCallback);GEvent.addDomListener(B,"click",this.routeClickCallback);F.getContainer().appendChild(D);return D};RouteMapControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,0))};function DrivingDirections(C,D,B,A){this.gdir=new GDirections(C.map,document.getElementById(D));this.mapState=C;this.gdir.errCallback=B;this.mapItems=A;this.init()}DrivingDirections.prototype.init=function(){this.routes=new Array();GEvent.bind(this.gdir,"load",this,this.onDirectionsLoad);GEvent.addListener(this.gdir,"error",this.handleErrors);GEvent.addListener(this.gdir,"addoverlay",this.onAddOverlay);this.mapState.drawNavControls(false)};DrivingDirections.prototype.drawDirections=function(){var F=this.gdir.getPolyline();var G=F.getVertexCount();var H=this.gdir.getNumRoutes();var K=0;var J=new Array();J[0]="#ff0000";J[1]="#0ff000";J[2]="#00ff00";J[3]="#000ff0";J[4]="#0000ff";J[5]="#000000";for(var E=0;E<H;E++){var I=this.gdir.getRoute(E);var A=I.getStep(0).getLatLng();var D=I.getEndLatLng();var B=new Array();B[B.length]=F.getVertex(K++);while(Math.abs(F.getVertex(K).lng()-D.lng())>0.000001&&Math.abs(F.getVertex(K).lat()-D.lat())>0.000001){B[B.length]=F.getVertex(K++)}var C=null;if(H>6){C=new GPolyline(B,"#ff0000")}else{C=new GPolyline(B,J[E]);this.mapState.map.addOverlay(C)}this.mapState.map.addOverlay(C)}};DrivingDirections.prototype.getProximity2=function(D){var N=this.mapState.map.getZoom();var M=G_NORMAL_MAP.getProjection();var L=M.fromLatLngToPixel(mouseLatLng,N);var K=threshold;if(routePixels.length>1){for(var C=1;C<routePixels.length;C++){if(routePixels[C].x!=routePixels[C-1].x){var J=(routePixels[C].y-routePixels[C-1].y)/(routePixels[C].x-routePixels[C-1].x);var I=routePixels[C].y-J*routePixels[C].x;var H=Math.abs(J*L.x+I-L.y)/Math.sqrt(J*J+1)}else{var H=Math.abs(L.x-routePixels[C].x)}var B=Math.pow(routePixels[C].y-routePixels[C-1].y,2)+Math.pow(routePixels[C].x-routePixels[C-1].x,2);var A=Math.pow(routePixels[C].y-L.y,2)+Math.pow(routePixels[C].x-L.x,2);var G=Math.pow(routePixels[C-1].y-L.y,2)+Math.pow(routePixels[C-1].x-L.x,2);var F=Math.pow(H,2);var E=A-F+G-F;if(E>B){H=Math.sqrt(Math.min(A,G))}oStatusDiv.innerHTML+="<br>Mouse distance to line "+C+": "+H.toFixed(2);K=Math.min(K,H)}if(K<threshold){map.openInfoWindowHtml(mouseLatLng,"Proximity Alert<br>Mouse distance to line: "+K.toFixed(2))}else{map.closeInfoWindow()}}};function mouseOverPolyline(){}DrivingDirections.prototype.onDirectionsLoad=function(){};DrivingDirections.prototype.onAddOverlay=function(){if(this.isFirst){var A=this.destinationsInfoArr;this.isFirst=false}};var DDpatchBaseIcon=null;DrivingDirections.applyGooglePatch=function(D){D.pop();if(DDpatchBaseIcon==null){DDpatchBaseIcon=new GIcon();DDpatchBaseIcon.shadow="http://www.google.com/mapfiles/shadow50.png";DDpatchBaseIcon.iconSize=new GSize(24,38);DDpatchBaseIcon.iconAnchor=new GPoint(9,36);DDpatchBaseIcon.infoWindowAnchor=new GPoint(9,2);DDpatchBaseIcon.infoShadowAnchor=new GPoint(18,25)}var C=this.mapState;for(var B=1;B<D.length;B++){DDpatchBaseIcon.image="images/map/icon-dd-pause-trans.png";var A=C.createMarker(D[B],DDpatchBaseIcon,true,false);C.getOverlayContainers()[B]=new OverlayCont(A);C.map.addOverlay(A)}if(D.length>0){DDpatchBaseIcon.image="images/map/icon-dd-play-trans.png";var A=C.createMarker(D[0],DDpatchBaseIcon,true,false);C.getOverlayContainers()[0]=new OverlayCont(A);C.map.addOverlay(A)}};DrivingDirections.prototype.handleErrors=function(){var A=this;if(A.getStatus().code==G_GEO_UNKNOWN_ADDRESS){showStatusMessage("Trip Route Error","One of the specified trip items is missing a geographic location and preventing us from calculating the trip route. Please remove this address from the route calculation or send us feedback regarding this trip and we will do our best to fix it.",null,null,null,null,true)}else{if(A.getStatus().code==G_GEO_SERVER_ERROR){handleError("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.",false,"We could not generate a route for this trip")}else{if(A.getStatus().code==G_GEO_MISSING_QUERY){handleError("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input",false,"We could not generate a route for this trip")}else{if(A.getStatus().code==G_GEO_BAD_KEY){handleError("The given key is either invalid or does not match the domain for which it was given",false,"We could not generate a route for this trip")}else{if(A.getStatus().code==G_GEO_BAD_REQUEST){handleError("A directions request could not be successfully parsed",false,"We could not generate a route for this trip")}else{if(A.getStatus().code==G_GEO_UNKNOWN_DIRECTIONS){showStatusMessage("Trip Route Error","We couldn't calculate the route between some of your trip destinations. This is usually because there is no route available between these destinations (too far, ocean,...) or because Google data is missing for routing in that region. Please send us feedback regarding this trip and we will do our best to fix it.",null,null,null,null,true)}else{handleError("An unknown error occurred.",false,"We could not generate a route for this trip")}}}}}}if(A.errCallback!=null){A.errCallback()}};DrivingDirections.prototype.loadFromPoints=function(B){if(B==null||B=="undefined"||B.length<2){showStatusMessage("Trip Route","Not enough destinations to generate a route");return }var H=new Array();for(D=0;D<B.length;D++){var G=B[D];var A="";A=G.name;H[D]=A+" @"+G.lat+","+G.lng}this.gdir.destinationsInfoArr=B;this.gdir.isFirst=true;this.gdir.loadFromWaypoints(H,{"getPolyline":"true","getSteps":"true"});if(this.mapItems!=null){var I=this.mapItems;this.mapState.setOverlayContainers(new Array());this.mapState.setItems(I);for(var D=0;D<I.length;D++){var F=I[D];var E=F.destType!=DestinationInfo.Site;var C=this.mapState.createMarker(F,F.getIcon(D+1,false,true),false,E);this.mapState.getOverlayContainers()[D]=new OverlayCont(C)}}}