
/*****************************************************
*  ElectricStorm's Google Map Script                 *
*  this script uses the Google Maps API to add an    * 
*  interactive map to the contact page.              *
*  (this page configures our specific map)           *
/****************************************************/


function initialize() { 

	//check the map_canvas div exists (i.e. that this is the contact page):
	if (document.getElementById('map_canvas')) {
		
		//check browser compatibility:
		if (GBrowserIsCompatible()) { 
		
			
			//making the map
			var centerCoords = new GLatLng(32.769003, -117.010609); //(using communitys coords as the center)
			var map = new GMap2(document.getElementById("map_canvas")); //create new map in the map_canvas div	
			map.setCenter(centerCoords, 11); //initialize map by setting lat and long co-ords and zoom
			map.addControl(new GLargeMapControl()); //add full pan/zoom controls
			
			
			//making the markers
			
			//1. eldorado:
			var eldoradoCoords = new GLatLng(32.788078, -116.955682); 
			var marker1 = new GMarker(eldoradoCoords); //create a marker object with hospitals co-ords
			
			GEvent.addListener(marker1, "click", function() { //add event listener to activate this function when marker is clicked	
				var htmlToShow = 'Eldorado Care Center<br />510 E. Washington<br />El Cajon, CA 92020<br /><br /><br />';
				marker1.openInfoWindowHtml(htmlToShow); //open info window on marker containing above html
			});
			
			map.addOverlay(marker1); //add the marker to the map
			
			//2. community:
			var communityCoords = new GLatLng(32.769003, -117.010609); 
			var marker2 = new GMarker(communityCoords); //create a marker object with hospitals co-ords
			
			GEvent.addListener(marker2, "click", function() { //add event listener to activate this function when marker is clicked	
				var htmlToShow = 'Community Convalescent Hosp.<br />of La Mesa<br />8665 La Mesa Blvd.<br />La Mesa, CA 91941<br /><br /><br />';
				marker2.openInfoWindowHtml(htmlToShow); //open info window on marker containing above html
			});
			
			map.addOverlay(marker2); //add the marker to the map
			
			//3. jacobs:
			var jacobsCoords = new GLatLng(32.750198, -117.077476); 
			var marker3 = new GMarker(jacobsCoords); //create a marker object with hospitals co-ords
			
			GEvent.addListener(marker3, "click", function() { //add event listener to activate this function when marker is clicked	
				var htmlToShow = 'Jacob Healthcare Center<br />4075 54th St.<br />San Diego, CA 92105<br /><br /><br />';
				marker3.openInfoWindowHtml(htmlToShow); //open info window on marker containing above html
			});
			
			map.addOverlay(marker3); //add the marker to the map

		}
		
	}
	
}


// window.onload = initialize; //(initialized in everypage.php)
window.onunload = GUnload; //free up memory associated with this app
