var map;var gdir;var marker;var streetviewclient;var streetviewpanorama;var geocoder=new GClientGeocoder();function get_html(a,b){point=a.getPoint();if(b==1){html='End address:<form action="javascript:get_directions();"><input type="text" size="50" maxlength="50" name="daddr" id="daddr" value="" autofocus /><br /><input value="Get Directions" type="submit"><input type="hidden" id="saddr" value="'+name+"@"+point.lat()+","+point.lng()+'"/></form>'}if(b==2){html='Start address:<form action="javascript:get_directions();"><input type="text" size="50" maxlength="50" name="saddr" id="saddr" value="" autofocus /><br /><input value="Get Directions" type="submit"><input type="hidden" id="daddr" value="'+name+"@"+point.lat()+","+point.lng()+'"/></form>'}if(b==0){html='Directions: <a href="javascript:tohere();" style="color:blue;">To here</a> - <a href="javascript:fromhere();"  style="color:blue;">From here</a>'}return html}function load_map(){if(GBrowserIsCompatible()){map=new GMap2($("#map")[0]);map.enableGoogleBar();gdir=new GDirections(map,$("#map_directions")[0]);GEvent.addListener(gdir,"load",onGDirectionsLoad);GEvent.addListener(gdir,"error",handleErrors);var a=new GLatLng(map_lat,map_lng);map.addControl(new GLargeMapControl3D());map.addControl(new GOverviewMapControl());map.addControl(new GScaleControl());map.addControl(new ExtMapTypeControl({showTraffic:true,showTrafficKey:true}));switch(map_type){case"1":map_type=G_SATELLITE_MAP;break;case"16":map_type=G_HYBRID_MAP;break;case"2":case"4":default:map_type=G_NORMAL_MAP;break}map.setMapType(map_type);map.setCenter(a,14);marker=new GMarker(a,{draggable:false});map.addOverlay(marker);streetviewclient=new google.maps.StreetviewClient();streetviewpanorama=new google.maps.StreetviewPanorama($("#map_streetview")[0]);google.maps.Event.addListener(streetviewpanorama,"error",streetviewpanorama_error);if(map_lat==0&&map_lng==0){show_address(address)}else{streetviewpanorama.setLocationAndPOV(a);streetviewclient.getNearestPanorama(a,streetviewclient_callback)}}else{alert("Your browser dosn't support map service.")}}function show_address(a){geocoder.getLatLng(a,function(b){if(!b){alert(a+" not found")}else{map.setCenter(b,18);streetviewpanorama.setLocationAndPOV(b);streetviewclient.getNearestPanorama(b,streetviewclient_callback);marker=new GMarker(b,{draggable:false});map.addOverlay(marker);info_window_html='<div style="color: #000;"><b>'+a+"</b><br />"+get_html(marker,0)+"</div>";marker.bindInfoWindowHtml(info_window_html);marker.openInfoWindowHtml(info_window_html)}})}function get_directions(){hide_streetview();var c={};var b=$("#map_directions").css("width");b=b.substring(0,b.indexOf("px"));b=parseInt(b);var e=$("#map").css("left");e=e.substring(0,e.indexOf("px"));e=parseInt(e);$("#map_directions").css("left",(e+content_width-b)+"px");$("#map_directions").css("display","block");$("#map").css("width",(content_width-b)+"px");var d=$("#saddr").val();var a=$("#daddr").val();gdir.load("from: "+d+" to: "+a);map.checkResize();marker.closeInfoWindow()}function hide_directions(){$("#map_directions").css("display","none");$("#map").css("width",content_width+"px");map.checkResize()}function hide_streetview(){$("#map_streetview").css("display","none");$("#map").css("width",content_width+"px");map.checkResize()}function showhide_streetview(){if($("#map_streetview").css("display")=="none"){hide_directions();var a=$("#map_streetview").css("width");a=a.substring(0,a.indexOf("px"));a=parseInt(a);var c=$("#map").css("left");c=c.substring(0,c.indexOf("px"));c=parseInt(c);$("#map_streetview").css("left",(c+content_width-a)+"px");$("#map_streetview").css("display","block");$("#map").css("width",(content_width-a)+"px");map.checkResize();var b='<div style="color: #000;"><b>'+address+"</b><br />"+get_html(marker,0)+'&nbsp;&nbsp;<a href="javascript:showhide_streetview();" style="color:blue;">Show/Hide Street View</a></div>';marker.bindInfoWindowHtml(b);marker.openInfoWindowHtml(b)}else{hide_streetview()}}function tohere(a){marker.openInfoWindowHtml('<div style="color: #000;">'+get_html(marker,2)+"</div>")}function fromhere(a){marker.openInfoWindowHtml('<div style="color: #000;">'+get_html(marker,1)+"</div>")}function handleErrors(){if(gdir.getStatus().code==G_GEO_UNKNOWN_ADDRESS){alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: "+gdir.getStatus().code)}else{if(gdir.getStatus().code==G_GEO_SERVER_ERROR){alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: "+gdir.getStatus().code)}else{if(gdir.getStatus().code==G_GEO_MISSING_QUERY){alert("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.\n Error code: "+gdir.getStatus().code)}else{if(gdir.getStatus().code==G_GEO_BAD_KEY){alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: "+gdir.getStatus().code)}else{if(gdir.getStatus().code==G_GEO_BAD_REQUEST){alert("A directions request could not be successfully parsed.\n Error code: "+gdir.getStatus().code)}else{alert("An unknown error occurred.")}}}}}hide_directions()}function onGDirectionsLoad(){}function streetviewclient_callback(a){if(a.code!=google.maps.StreetviewClient.ReturnValues.SUCCESS){return}var b='<div style="color: #000;"><b>'+address+"</b><br />"+get_html(marker,0)+'&nbsp;&nbsp;<a href="javascript:showhide_streetview();" style="color:blue;">Show/Hide Street View</a></div>';marker.bindInfoWindowHtml(b);marker.openInfoWindowHtml(b);if(show_streetview_by_default){showhide_streetview()}streetviewpanorama.setLocationAndPOV(a.location.latlng)}function oncustomclick(a){streetviewclient.getPanoramaById(a,streetviewclient_callback)}function streetviewpanorama_error(a){if(a==google.maps.StreetviewPanorama.ErrorValues.FLASH_UNAVAILABLE){alert("You need Flash player to view the street view");return}};