/**********************************************************************

  LICENSE FOR USE
  The contents of this file are copyright ©2008 Phil DeJarnett
  It is licensed for exclusive use by The Pentier Group on the
  website domains pentier.com and thepentiergroup.com, and any
  subdomains for those domains.
  
  The right to use the code listed below, in part or in full, in any
  other context is fully reserved.
  
  ANY AND ALL OTHER USE BY ANY PARTIES IS RESTRICTED WITHOUT EXPRESS
  CONSENT OF PHIL DEJARNETT.
  
  If you are interested in the using part or all of this code you may
  contact the author at http://www.overzealous.com/

**********************************************************************/
// Choose google key based on url
var gm_key = "";
if(document.location.href.indexOf("katiesspa.com") > -1) {
	// http://(www.)katiesspa.com/
	gm_key = "ABQIAAAAtMoR7FvEHKDNDOuUTJDHfhSE_zHQFwrL9b12m-J4zPIWrjg3_BSrbgNJ1RktElmwIwbNrvDKPjB6yQ";
} else if(document.location.href.indexOf("katiespa.com") > -1) {
	// http://(www.)katiespa.com/
	gm_key = "ABQIAAAAtMoR7FvEHKDNDOuUTJDHfhQpU2qRIhH4cO8QXOTZGB2IJ-s_-xQbFhmkdi0ORaxCpbK5E1w624ogyA";
}
// Write in google dependencies
if(gm_key != "") {
	document.write('<script src="http://maps.google.com/maps?file=api&v=2.58&key='+gm_key+'" type="text/javascript"></script>\n<script src="http://www.google.com/uds/api?file=uds.js&v=1.0&source=uds-msw&key='+gm_key+'" type="text/javascript"></script>\n<link href="http://www.google.com/uds/css/gsearch.css" rel="stylesheet" type="text/css"/>\n<script src="http://www.google.com/uds/solutions/mapsearch/gsmapsearch.js" type="text/javascript"></script>\n<link href="http://www.google.com/uds/solutions/mapsearch/gsmapsearch.css" rel="stylesheet" type="text/css"/>');

	function loadMap(event) {
		var address = document.mapAddress;
		if (GBrowserIsCompatible()) {
			var options = {
				zoomControl: GSmapSearchControl.ZOOM_CONTROL_ENABLE_ALL,
				title: 'Katie\'s Spa & Boutique',
				url: 'http://maps.google.com/maps?q='+escape(address),
				idleMapZoom: GSmapSearchControl.ACTIVE_MAP_ZOOM,
				activeMapZoom: GSmapSearchControl.ACTIVE_MAP_ZOOM
			}
			control = $("contact-info-map");
			control.update("<p>Loading</p>");
			new GSmapSearchControl(control,
								   address,
								   options);
			Event.observe(document, 'unload', GUnload);
			
			if(event) {
				Event.stop(event);
			}
		}
	}
	// load map AFTER page has loaded
	//Event.observe(document, "dom:loaded", loadMap);
	function updateMapLink() {
		var link = $$("#contact-info-map p a")[0];
		link.observe("click", loadMap);
	}
	Event.observe(document, "dom:loaded", updateMapLink);
}