
var map;var infowindow;var directionsService;var directionsDisplay;var infowindow;var stWindows={};function getMarkerOptions(latLng,icon){var m={position:latLng,animation:google.maps.Animation.DROP,clickable:true,map:map,icon:icon};return m;}
function getInfoWindow(marker,content){infowindow=new google.maps.InfoWindow({maxWidth:320});google.maps.event.addListener(marker,'click',function(){infowindow.setContent(content);infowindow.open(map,marker);});}
function createIcon(sIconURL,iIconHeight,iIconWidth){var oIcon=new GIcon();oIcon.image=sIconURL;oIcon.iconSize=new GSize(iIconWidth,iIconHeight);oIcon.iconAnchor=new GPoint(iIconWidth/2,iIconHeight/2);oIcon.infoWindowAnchor=new GPoint(iIconWidth/2,iIconHeight/5);return oIcon;}
function calcRoute(start,end){var request={origin:start,destination:end,travelMode:google.maps.TravelMode.DRIVING};directionsService.route(request,function(response,status){if(status==google.maps.DirectionsStatus.OK){directionsDisplay.setDirections(response);}});}
function openRegionWindow(windowID){var newwindow=stWindows[windowID];var latLng=new google.maps.LatLng(newwindow.lat,newwindow.lng)
if(infowindow){infowindow.close();};infowindow=new google.maps.InfoWindow({content:newwindow.content,position:latLng});infowindow.open(map);}
function getMap(m,opts,items,bAuto){opts.mapTypeId=google.maps.MapTypeId.ROADMAP;opts.scrollwheel=false;opts.mapTypeControl=true;opts.mapTypeControlOptions={style:google.maps.MapTypeControlStyle.HORIZONTAL_BAR,position:google.maps.ControlPosition.TOP_RIGHT};opts.panControl=false;opts.panControlOptions={position:google.maps.ControlPosition.TOP_RIGHT};opts.zoomControl=true;opts.zoomControlOptions={style:google.maps.ZoomControlStyle.LARGE,position:google.maps.ControlPosition.RIGHT_TOP};opts.scaleControl=false;opts.scaleControlOptions={position:google.maps.ControlPosition.RIGHT_TOP};opts.streetViewControl=true;opts.streetViewControlOptions={position:google.maps.ControlPosition.TOP_RIGHT};map=new google.maps.Map(document.getElementById(m),opts);directionsService=new google.maps.DirectionsService();directionsDisplay=new google.maps.DirectionsRenderer();directionsDisplay.setMap(map);directionsDisplay.setPanel(document.getElementById("directions"));var bounds=new google.maps.LatLngBounds();for(var i=0;i<items.length;i++){var latLng=new google.maps.LatLng(items[i].lat,items[i].lng)
var marker=new google.maps.Marker(getMarkerOptions(latLng,items[i].icon));getInfoWindow(marker,items[i].info);bounds.extend(latLng);}
if(bAuto)map.fitBounds(bounds);}
function getMiniMap(m,opts,items,bAuto){opts.mapTypeId=google.maps.MapTypeId.ROADMAP;opts.mapTypeControl=false;opts.mapTypeControlOptions={style:google.maps.MapTypeControlStyle.HORIZONTAL_BAR,position:google.maps.ControlPosition.TOP_RIGHT};opts.panControl=false;opts.panControlOptions={position:google.maps.ControlPosition.TOP_RIGHT};opts.zoomControl=false;opts.zoomControlOptions={style:google.maps.ZoomControlStyle.LARGE,position:google.maps.ControlPosition.RIGHT_TOP};opts.scaleControl=false;opts.scaleControlOptions={position:google.maps.ControlPosition.RIGHT_TOP};opts.streetViewControl=false;opts.streetViewControlOptions={position:google.maps.ControlPosition.TOP_RIGHT};map=new google.maps.Map(document.getElementById(m),opts);directionsService=new google.maps.DirectionsService();directionsDisplay=new google.maps.DirectionsRenderer();directionsDisplay.setMap(map);directionsDisplay.setPanel(document.getElementById("directions"));var bounds=new google.maps.LatLngBounds();for(var i=0;i<items.length;i++){var latLng=new google.maps.LatLng(items[i].lat,items[i].lng)
var marker=new google.maps.Marker(getMarkerOptions(latLng,items[i].icon));getInfoWindow(marker,items[i].info);bounds.extend(latLng);}
if(bAuto)map.fitBounds(bounds);}

