var map=null;var sv=null;var bounds=null;var myPano=null;var gmarkers=[];var gmarker_selected=null;var i=0;function initMap(mapid){if(GBrowserIsCompatible()){map=new GMap2(document.getElementById(mapid));map.addControl(new GSmallMapControl());map.setCenter(new GLatLng(38.632,-90.191),13);var mapTypeControl=new GMapTypeControl();var topRight=new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10));map.addControl(mapTypeControl,topRight)}}function initMapwSV(mapid,svid){if(GBrowserIsCompatible()){map=new GMap2(document.getElementById(mapid));sv=document.getElementById(svid);GEvent.addListener(sv,"error",function(errorCode){sv.style.display="none"});map.addControl(new GLargeMapControl());map.setCenter(new GLatLng(38.632,-90.191),13);var mapTypeControl=new GMapTypeControl();var topRight=new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(10,10));map.addControl(mapTypeControl,topRight);initSVControl();map.addControl(new SVControl(map))}}function AddMarkerBusiness(latitude,longitude,bAdvertiser,name,address,city_state,phone){if(GBrowserIsCompatible()){name=name.replace("'","");address=address.replace("'","");city_state=city_state.replace("'","");var pnt;if(latitude==0&&longitude==0){var geocoder=new GClientGeocoder();var strAddress=address+" "+city_state;geocoder.getLatLng(strAddress,function(point){if(point){latitude=point.lat();longitude=point.lng()}else{}})}pnt=new GLatLng(latitude,longitude);var icon=new GIcon(G_DEFAULT_ICON);if(bAdvertiser){icon.image="images/map_advertiser_icon.gif";icon.shadow="images/map_advertiser_icon_shadow.png";icon.iconSize=new GSize(25,32);icon.shadowSize=new GSize(42,32);icon.iconAnchor=new GPoint(12,16);icon.infoWindowAnchor=new GPoint(12,16)}else{icon.image="images/map_listing_icon.gif";icon.shadow="images/map_listing_icon_shadow.png";icon.iconSize=new GSize(22,32);icon.shadowSize=new GSize(39,32);icon.iconAnchor=new GPoint(11,16);icon.infoWindowAnchor=new GPoint(11,16)}var marker=new GMarker(pnt,icon);GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml("<p style='FONT-SIZE: 11px; FONT-FAMILY: Arial; text-align:left;'><b>"+name+"</b><br>"+address+"<br>"+city_state+"<br>"+phone+"</p>")});map.addOverlay(marker);if(latitude!=0&&longitude!=0){if(bounds==null){bounds=new GLatLngBounds(new GLatLng(latitude-0.0001,longitude-0.0001),new GLatLng(latitude+0.0001,longitude+0.0001))}bounds.extend(marker.getPoint())}}}function AddMarker(latitude,longitude,name,address,city_state,phone){if(GBrowserIsCompatible()){name=name.replace("'","");address=address.replace("'","");city_state=city_state.replace("'","");var pnt;if(latitude==0&&longitude==0){var geocoder=new GClientGeocoder();var strAddress=address+" "+city_state;geocoder.getLatLng(strAddress,function(point){if(point){latitude=point.lat();longitude=point.lng()}else{}})}pnt=new GLatLng(latitude,longitude);var marker=new GMarker(pnt);GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml("<p style='FONT-SIZE: 11px; FONT-FAMILY: Arial; text-align:left;'><b>"+name+"</b><br>"+address+"<br>"+city_state+"<br>"+phone+"</p>")});map.addOverlay(marker);if(latitude!=0&&longitude!=0){if(bounds==null){bounds=new GLatLngBounds(new GLatLng(latitude-0.0001,longitude-0.0001),new GLatLng(latitude+0.0001,longitude+0.0001))}bounds.extend(marker.getPoint())}}}function AddMarker2(latitude,longitude,city,state){if(GBrowserIsCompatible()){city=city.replace("'","");state=state.replace("'","");var pnt;if(latitude==0&&longitude==0){var geocoder=new GClientGeocoder();var strLocation=city+", "+state;geocoder.getLatLng(strLocation,function(point){if(point){latitude=point.lat();longitude=point.lng()}else{}})}pnt=new GLatLng(latitude,longitude);var marker=new GMarker(pnt);GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml("<p style='FONT-SIZE: 14px; FONT-FAMILY: Arial; text-align:left;'><b>"+city+", "+state+"</p>")});map.addOverlay(marker);if(latitude!=0&&longitude!=0){if(bounds==null){bounds=new GLatLngBounds(new GLatLng(latitude-0.0001,longitude-0.0001),new GLatLng(latitude+0.0001,longitude+0.0001))}bounds.extend(marker.getPoint())}}}function AddMarker3(aid,sid,intposition,bAdvertiser,bReview,url,latitude,longitude,name,address,city_state,phone){if(GBrowserIsCompatible()){aid=aid.replace("'","");sid=sid.replace("'","");name=name.replace("'","");address=address.replace("'","");city_state=city_state.replace("'","");var pnt;if(latitude==0&&longitude==0){var geocoder=new GClientGeocoder();var strAddress=address+" "+city_state;geocoder.getLatLng(strAddress,function(point){if(point){latitude=point.lat();longitude=point.lng()}else{sv.style.display="none"}})}pnt=new GLatLng(latitude,longitude);var icon=new GIcon(G_DEFAULT_ICON);if(bAdvertiser){icon.image="images/map_advertiser_icon.gif";icon.shadow="images/map_advertiser_icon_shadow.png";icon.iconSize=new GSize(25,32);icon.shadowSize=new GSize(42,32);icon.iconAnchor=new GPoint(12,16);icon.infoWindowAnchor=new GPoint(12,16)}else{icon.image="images/map_listing_icon.gif";icon.shadow="images/map_listing_icon_shadow.png";icon.iconSize=new GSize(22,32);icon.shadowSize=new GSize(39,32);icon.iconAnchor=new GPoint(11,16);icon.infoWindowAnchor=new GPoint(11,16)}var marker=new GMarker(pnt,icon);GEvent.addListener(marker,"click",function(){gmarker_selected=marker;if(sv.style.display=="block"){initStreetViewLookup(marker.getLatLng())}var html="<p style='FONT-SIZE: 11px; FONT-FAMILY: Arial; text-align:left;'><b><a href='"+url+"' target='_self'><b>"+name+"</b></a></b><br>"+address+"<br>"+city_state+"<br>"+phone+"</p>";html=html+"<div class='map_marker_window_icon'><a href=\"javascript:loadBusAdd('"+aid+"','"+sid+"');\">Add</a></div><div class='map_marker_window_icon'>|</div>";html=html+"<div class='map_marker_window_icon'><a href=\"javascript:loadC2Call('"+aid+"','"+sid+"');\">Call</a></div><div class='map_marker_window_icon'>|</div>";html=html+"<div class='map_marker_window_icon'><a href=\"javascript:loadSendListing('"+aid+"','"+sid+"');\">Friends</a></div><div class='map_marker_window_icon'>|</div>";html=html+"<div class='map_marker_window_icon'><a href=\"javascript:loadSend2Mobile('"+aid+"','"+sid+"');\">Mobile</a></div><div class='map_marker_window_icon'>|</div>";if(bReview){html=html+"<div class='map_marker_window_icon'><a href=\"javascript:loadBusReview('"+aid+"','"+sid+"');\">Review</a></div><div class='map_marker_window_icon'>|</div>"}html=html+"<div class='map_marker_window_icon'><a href=\""+url+'">More...</a></div>';marker.openInfoWindowHtml(html)});map.addOverlay(marker);gmarkers[intposition]=marker;if(latitude!=0&&longitude!=0){if(bounds==null){bounds=new GLatLngBounds(new GLatLng(latitude-0.0001,longitude-0.0001),new GLatLng(latitude+0.0001,longitude+0.0001))}bounds.extend(marker.getPoint())}}}function setMapCenter(){var zoom=13;var centerLat=0;var centerLong=0;var SW;var NE;if(GBrowserIsCompatible()){if(bounds!=null){zoom=map.getBoundsZoomLevel(bounds);var SW=bounds.getSouthWest();var NE=bounds.getNorthEast();var centerLat=NE.lat()-(NE.lat()-SW.lat())/2;var centerLong=SW.lng()-(SW.lng()-NE.lng())/2;map.setCenter(new GLatLng(centerLat,centerLong),zoom)}}}function setMapCenterLatLon(latitude,longitude,zoom){map.setCenter(new GLatLng(latitude,longitude),zoom)}function ShowRecord(latitude,longitude,name,address,city_state,phone){name=name.replace("'","");address=address.replace("'","");city_state=city_state.replace("'","");if(map){map.setCenter(new GLatLng(latitude,longitude),15);map.openInfoWindowHtml(map.getCenter(),"<p style='FONT-SIZE: 11px; FONT-FAMILY: Arial; text-align:left;'><b>"+name+"</b><br>"+address+"<br>"+city_state+"<br>"+phone+"</p>")}}function ShowRecordWSV(latitude,longitude,name,address,city_state,phone){name=name.replace("'","");address=address.replace("'","");city_state=city_state.replace("'","");if(map){map.setCenter(new GLatLng(latitude,longitude),15);map.openInfoWindowHtml(map.getCenter(),"<p style='FONT-SIZE: 11px; FONT-FAMILY: Arial; text-align:left;'><b>"+name+"</b><br>"+address+"<br>"+city_state+"<br>"+phone+"</p>");if(sv){if(sv.style.display=="block"){initStreetViewLookup(new GLatLng(latitude,longitude))}}}}function ShowMarker(latitude,longitude,markerposition){map.setCenter(new GLatLng(latitude,longitude),15);if(gmarkers[markerposition]!=null){gmarker_selected=gmarkers[markerposition];GEvent.trigger(gmarker_selected,"click")}}function initStreetViewLookup(glatlng){var panoramaOptions={latlng:glatlng};if(myPano==null){myPano=new GStreetviewPanorama(sv,panoramaOptions)}else{myPano.setLocationAndPOV(glatlng)}}function toggleStreetView(){if(sv.style.display=="block"){sv.style.display="none";map.getContainer().style.height="550px"}else{sv.style.display="block";map.getContainer().style.height="348px";var marker=gmarker_selected;if(marker!=null){initStreetViewLookup(marker.getLatLng())}}}function SVControl(){}function initSVControl(){SVControl.prototype=new GControl();SVControl.prototype.initialize=function(map){var container=document.createElement("divSV");container.style.width="350px";var zoomInDivOuter=document.createElement("div");var zoomInDivInner=document.createElement("div");var isActive=false;this.setOuterButtonStyle_(zoomInDivOuter);this.setInnerButtonStyleInactive_(zoomInDivInner,"Street View");container.appendChild(zoomInDivOuter);zoomInDivOuter.appendChild(zoomInDivInner);GEvent.addDomListener(zoomInDivOuter,"click",toggleStreetView);map.getContainer().appendChild(container);return container};SVControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(100,12))};SVControl.prototype.setInnerButtonStyleInactive_=function(button,name){button.style.borderStyle="solid";button.style.borderColor="white";button.style.borderWidth="1px";button.style.fontSize="12px";button.style.fontWeight="bold";button.title=name;button.innerHTML=name;button.style.display="inline-block"};SVControl.prototype.setOuterButtonStyle_=function(button){button.style.border="1px solid black";button.style.backgroundColor="white";button.style.textAlign="center";button.style.width="6em";button.style.cursor="pointer";button.style.display="inline-block"};SVControl.prototype.setInnerButtonStyleActive_=function(button,name){button.style.borderStyle="solid";button.style.borderColor="white";button.style.borderWidth="1px";button.style.fontSize="12px";button.style.fontWeight="bold";button.title=name;button.innerHTML=name}};
