/****
Author:         James Condliffe
Date:           07/01/2007
Filename:       location.js
Description:    Hooks into the Google Maps API to display a location
                map for Majestic House.
****/

addLoadEvent(locationmap);

function locationmap() 
{
    if (!document.getElementById) return false;
	//check if the javascript supports document.getElementById 
    if (!document.getElementById("locationmap")) return false;
	//check if there is a page element with the required id

	//define the map coordinate
	var mapLatitude = 53.6513;
	var mapLongitude = -1.7819;
	
	if (GBrowserIsCompatible()) 
    {
        var mapContainer = document.getElementById("locationmap");

		//instanciate GoogleMap
		var map = new GMap2(mapContainer);
        //set map latitude (North) and longitude (East)
		var mapLocation = new GLatLng(mapLatitude, mapLongitude);
		//set map zoom factor
		var mapZoomFactor = 15;
		//set map type - 0 (map), 1 (satellite), 2 (hybrid)
		var mapType = G_DEFAULT_MAP_TYPES[0];
		//set map label
		var mapLabel = "<img src=\"images/majesticbuilding.jpg\" style=\"width: 88; height: 60; float: left; margin-right: 10px; display: inline;\" /><br /><span style=\"font-size: 85%;\"><strong style=\"font-weight: bold;\">Majestic Interactive</strong>,<br /> Majestic House,<br /> Huddersfield</span>";
        
        //add location, zoom factor and label to the map
        map.openInfoWindowHtml(mapLocation, mapLabel);
		//add panning, zooming controls
		map.addControl(new GLargeMapControl());
		//add map type (map, sattelite, hybrid) control
		map.addControl(new GMapTypeControl());
		//add marker to map in case user closes the location label
		//map.addOverlay(new GMarker(mapLocation));
		map.setCenter(mapLocation, mapZoomFactor,mapType);
		

		// Our info window content
		var infoTabs = [
		  new GInfoWindowTab("Address:", mapLabel)//,
		  //new GInfoWindowTab("Contact Numbers", "<strong>Phone :</strong> 01484 427 383<br /><strong>Fax :</strong> 01484 435 236")
		];

		// Create our marker icon
		var icon = new GIcon();
		/*icon.image = "images/buildingv2.gif";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(20, 123);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(10, 127);
		icon.infoWindowAnchor = new GPoint(8, 65);*/

		icon.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(12, 20);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);


		// Place a marker in the center of the map and open the info window automatically
		var marker = new GMarker(map.getCenter(), icon);
		GEvent.addListener(marker, "click", function() {
		  marker.openInfoWindowTabsHtml(infoTabs);
		});
		map.addOverlay(marker);
		marker.openInfoWindowTabsHtml(infoTabs);


		// Remove fake map if necessary
		var mapdiv = document.getElementById("locationmap");		
		if(mapdiv)
		{
		    mapdiv.style.background = "none";
		}
    }
}