
function load(pageElement, JSParms, JSLocationInfo) 
{
	if (GBrowserIsCompatible()) 
    {
	    var array = JSParms.split(";");
	    var locationInfo = JSLocationInfo.split(";");
	    
	    var bounds = null;

	    var centerLat = array[0].split(",")[0];
	    var centerLong = array[0].split(",")[1];
	   	var firstPoint = new GLatLng(centerLat, centerLong);
	    
	    var map = new GMap2(document.getElementById(pageElement))

	    map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(firstPoint, 15);
        bounds = map.getBounds();
        
        for (i=0; i<array.length; i++)
        {
        	var lat = array[i].split(",")[0];
        	var long = array[i].split(",")[1];        	
        	        	
			var point = new GLatLng(lat, long);
			var marker = createMarker(point, locationInfo[i], i);
			map.addOverlay(marker);
			
			bounds.extend(marker.getPoint());
		}
		map.setZoom(map.getBoundsZoomLevel(bounds));
		map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds) - 1);
	}
	else
	{
		alert("Your browser is not capable of displaying Google Maps data correctly");
	}
}    

// Creates a marker at the given point with the given letter label
function createMarker(point, locationInfo, index)
{
  	var letterIcon = new GIcon();
	letterIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
	letterIcon.iconSize = new GSize(20, 34);
	letterIcon.shadowSize = new GSize(37, 34);
	letterIcon.iconAnchor = new GPoint(9, 34);
	letterIcon.infoWindowAnchor = new GPoint(9, 2);
	letterIcon.infoShadowAnchor = new GPoint(18, 25);
	letterIcon.image = "/Style Library/BOSCH/images/marker" + (index + 1) + ".png";

	var marker = new GMarker(point, {icon:letterIcon});
	GEvent.addListener(marker, "click", function() {
    	marker.openInfoWindowHtml(locationInfo);
		});
	return marker;
}


function GoogleDirections(mapPageElement, directionsPageElement, startingLocation, endingLocation)
{
	if (GBrowserIsCompatible()) 
    {
	   var map = new GMap2(document.getElementById(mapPageElement));
	   map.addControl(new GLargeMapControl());
       map.addControl(new GMapTypeControl());
	   directionsPanel = document.getElementById(directionsPageElement);
	   var directions = new GDirections(map, directionsPanel);
	   
       directions.clear();

       directions.load('from: ' + startingLocation + ' to: ' + endingLocation);

	}
}





