/* 	map.js - Gives a specified nav item the class name "current".
------------------------------------------------------------------------
	Usage
------------------------------------------------------------------------
   	
   	Each nav item must have the prefix "nav_" followed by a unique name:

		<li id="nav_home">
			<a href="#">home</a>
		</li>
   	
   	Add the onload function to the body element and reference the unique part of the nav id.
   	
		<body onload="highlight('home')">
   	
------------------------------------------------------------------------*/


$(document).ready(function(){
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map_canvas"));
		//use geocoding service to convert SIAs address to a marker on the map
		var geocoder = new GClientGeocoder();
		var address="39 High Street, Steyning, West Sussex, BN44 3YE"
		
		geocoder.getLatLng(address,function(point) {
		  if (!point) {
			alert(address + " not found");
		  } else {
			map.setCenter(point, 10);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			//include a directions link in the info window
			var info="<strong>SIA Group</strong><br /><p>39 High Street, Steyning<br />West Sussex<br />BN44 3YE<br /><a href='http://maps.google.com/maps?saddr=&daddr=" + point.toUrlValue() + "' target ='_blank'>Get Directions...<\/a></p>"
			marker.openInfoWindowHtml(info);
			//add click event to show the info window whenever the marker is clicked
			GEvent.addListener(marker, "click", function() {
			  marker.openInfoWindowHtml(info);
			});
		  }
		}
		);
	
		map.setUIToDefault();
	}
});

