
	var map 					= null;
	
	var iconVault 				= new GIcon(); 
    iconVault.image 			= 'http://www.justwannadance.ca/wp-content/themes/cute-bubbles/images/marker-just-wanna-dance.png';
    iconVault.iconSize 			= new GSize(80, 77);
    iconVault.iconAnchor 		= new GPoint(40, 77);
    iconVault.infoWindowAnchor 	= new GPoint(40, 77);

    var customIcons = [];
    customIcons["vabdmarker"] = iconVault;
	
	function createMarker(point, nm, adr, icn)
	{
		var marker = new GMarker(point, customIcons[icn]);
		//var marker = new GMarker(point);
		var html = '<span class="map"><b>' + nm + '</b><br/>' + adr + '</span>';
		GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); });
		return marker;
	}
	
	function setDirections(fromAddress)
	{

		gdir.load("from: " + fromAddress + " to: #280-1125 Howe Street, Vancouver, BC, V6Z 2K8, Canada", { "locale": "en_US"});
	}
	
	function handleErrors()
	{
		if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		{
			alert("No corresponding geographic location could be found for the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\n\nMake sure your address is formatted this way:\n\n1234 Road St, City, Province, Postal Code");
		}
		else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
		{
			alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.");
		}
		else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
		{
			alert("Please enter an address.\n\nMake sure your address is formatted this way:\n\n1234 Road St, City, Province, Postal Code");
		}
		else if (gdir.getStatus().code == G_GEO_BAD_KEY)
		{
			alert("The given key is either invalid or does not match the domain for which it was given.");
		}
		else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
		{
			alert("A directions request could not be successfully parsed.");
		}
		else
		{
			 alert("An unknown error occurred.");
		}
	}
	
	function onGDirectionsLoad()
	{ 
			// Use this function to access information about the latest load()
      		// results.
      		// e.g.
      		// document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  		// and yada yada yada...
	}
	
	function mapInit()
	{
		if (GBrowserIsCompatible())
		{
			map = new GMap2(document.getElementById("map_canvas"));
			bounds = new GLatLngBounds();
			map.setCenter(new GLatLng(0,0),0);
			map.addControl(new GSmallMapControl());
        	map.addControl(new GMapTypeControl());
        	
        	var bounds = new GLatLngBounds();
        	
        	// add studio to map
        	var point = new GLatLng(49.2788384,-123.1257279);
			var marker = createMarker(point, "Just Wanna Dance!", "#280-1125 Howe Street,<br />Vancouver, BC V6Z 2K8", "vabdmarker");
			map.addOverlay(marker);
			bounds.extend(point);
			
			map.setZoom(map.getBoundsZoomLevel(bounds));
			map.setCenter(bounds.getCenter());
			
			var currentZoom = map.getZoom();
			map.setZoom(currentZoom-2);
			
			gdir = new GDirections(map, document.getElementById("map_directions"));
		    GEvent.addListener(gdir, "load", onGDirectionsLoad);
		    GEvent.addListener(gdir, "error", handleErrors);
		}
	}
	window.onload = mapInit;
	window.onunload = GUnload;
