
//<![CDATA[
		var geocoder = new GClientGeocoder();	// geocoder class 
		var map = null;				// map
		
		var gMarkers = [];			// this is a list of all the markers that are placed by the db on the map
		var gMarkersPlaces = [];	// the names of the places that the markers are placed at (desc)
		var meMarker;				// the 'memarker' - where you are getting distances or directions to
		var meAddress;				// the address that someone has entered
		var counter = 0;			// counter variable

		var usedirectionsPanel = true;
		var directionsPanelId = "directions";// directions panel - want to give text based routes?

		var directions;

			
		/* u can use a custom marker icons */
		var useicon = false;
		
		var icon = new GIcon();
			
		icon.image = "http://xblocal/googlemaps/httpdocs/images/new_20_blue.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.printImage = "http://xblocal/googlemaps/httpdocs/images/new_20_blue.png";
		icon.mozPrintImage = "http://xblocal/googlemaps/httpdocs/images/new_20_blue.png";
		icon.printShadow = "http://xblocal/googlemaps/httpdocs/images/new_20_blue.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);
		
		
		/* u can use a custom me marker icons */
		var usemeicon = false;
		
		var meIcon = new GIcon();
			
		meIcon.image = "http://xblocal/googlemaps/httpdocs/images/new_20_blue.png";
		meIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		meIcon.printImage = "http://xblocal/googlemaps/httpdocs/images/new_20_blue.png";
		meIcon.mozPrintImage = "http://xblocal/googlemaps/httpdocs/images/new_20_blue.png";
		meIcon.printShadow = "http://xblocal/googlemaps/httpdocs/images/new_20_blue.png";

		meIcon.iconSize = new GSize(12, 20);
		meIcon.shadowSize = new GSize(22, 20);
		meIcon.iconAnchor = new GPoint(6, 20);
		meIcon.infoWindowAnchor = new GPoint(5, 1);
		
		
		function initialisethemap(start_lat, start_long, start_zoom)
		{

			//where the map will goto to begin with
			if(start_lat == ''){start_lat = 53.97494;}
			if(start_long == ''){start_long = -1.09965;}
			if(start_zoom == ''){start_zoom = 13;}

			if (GBrowserIsCompatible()) 
			{
				
				map = new GMap2(document.getElementById("map"));

				map.setCenter(new GLatLng(start_lat, start_long), start_zoom);
				map.addControl(new GSmallMapControl()); // zoom controls

				map.addControl(new GMapTypeControl()); // map types - top right

				// this is where some php would go to pull out all the locations that you want to make on the map
				// if you have the long/lats of stores (this is much quicker than geocoding each address)

				var point = new GLatLng(53.7953758239746094, -1.5506348609924316);var marker = new GMarker(point);gMarkers[0] = marker;gMarkersPlaces[0] = "Kinloch Finance";map.addOverlay(createMarker(point, "Kinloch Finance"));
map.setCenter(point, 10);
	      	}
		}
		

		
		// Creates a marker at the given point with the given number label
		function createMarker(point, sometext) {
			if(useicon == true){
				var marker = new GMarker(point, icon);
			}
			else{
				var marker = new GMarker(point);
			}
		  GEvent.addListener(marker, "click", function() {
		    marker.openInfoWindowHtml(sometext);
		  });
		  return marker;
		}
		
		
		function showAddress(address, desc, map, postcode) {
		  geocoder.getLatLng(
			address,
			function(point) {
			  if (!point) {
				//alert(address + " not found");
				
					if(postcode)
					{
						//alert(postcode);			
						showAddress(postcode, desc, map, "");
					}
				
			  } else {
				  	if(useicon == true){
						var marker = new GMarker(point, icon);
					}
					else{
						var marker = new GMarker(point);
					}
				gMarkers[counter] = marker;
				gMarkersPlaces[counter] = desc;
				counter++;
				map.addOverlay(marker);
				map.setCenter(point, 10);
				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml(desc);
				});
			  }
			}
		  );
		}
		
		
		
		function plotMe(address,longitude,latitude) 
		{
			
			var marker = meMarker;

			//map.removeOverlay(marker);		
		
		  geocoder.getLatLng
		  (
			address,
			function(point) 
			{
			  
			  var point = new GLatLng(latitude, longitude);
			  
			  if (!point) 
			  {
				alert(address + " not found");
			  } 
			  else 
			  {
					
					if(usemeicon == true)
					{
						var marker = new GMarker(point, meIcon);
					}
					else
					{
						var marker = new GMarker(point);
					}
					
				meMarker = marker;
				meAddress = address;
				//map.setCenter(point, 10);
				map.addOverlay(marker);
			  }
			}
		  );

		id = window.setTimeout("nowdisplay();", 600);		
		}
		
		
		function nowdisplay(){

			document.getElementById('distances').innerHTML = "";
			var stuff = "Distance from " + meAddress + " : \n<br /><br />";
			for(i=0;i<1;i++){
				 stuff += "To : " + gMarkersPlaces[i] + " " + ((gMarkers[i].getPoint().distanceFrom(meMarker.getPoint())/1000) / 1.609344).toFixed(2) + " miles - <a href=\"javascript:direction('" +  + "','" +  + "','" + -1.5506348609924316 + "','" + 53.7953758239746094 + "')\" title=\"get directions\" >get directions</a>\n<br />";
			}

			document.getElementById('distances').innerHTML = stuff;
		}
		
		
		
		function direction(f_lat, f_lng, to_lng, to_lat ) 
		{
			if(usedirectionsPanel == true)
			{
				directionsPanel = document.getElementById(directionsPanelId).innerHTML = '';
				directionsPanel = document.getElementById(directionsPanelId);
			}
			else
			{
				directionsPanel = document.getElementById("thiswillnotexist");
			}
	  
		  directions = new GDirections(map, directionsPanel);
	      directions.load(""+f_lng+", "+f_lat+" to "+to_lat+", "+to_lng+"");
		}
		
    //]]>