
	var map 					= null;
	
	// COMFORT SUITES
	var iconBCS 				= new GIcon(); 
    iconBCS.image 				= 'images/marker-lodgingboise-ComfortSuites.png';
    iconBCS.iconSize 			= new GSize(30, 41);
    iconBCS.iconAnchor 			= new GPoint(15, 31);
    iconBCS.infoWindowAnchor 	= new GPoint(15, 31);
    
    // SLEEP INN
	var iconNSI 				= new GIcon(); 
    iconNSI.image 				= 'images/marker-lodgingboise-SleepInn.png';
    iconNSI.iconSize 			= new GSize(30, 41);
    iconNSI.iconAnchor 			= new GPoint(15, 31);
    iconNSI.infoWindowAnchor 	= new GPoint(15, 31);
    
    // MR SANDMAN
	var iconMSI 				= new GIcon(); 
    iconMSI.image 				= 'images/marker-lodgingboise-MrSandman.png';
    iconMSI.iconSize 			= new GSize(30, 41);
    iconMSI.iconAnchor 			= new GPoint(15, 31);
    iconMSI.infoWindowAnchor 	= new GPoint(15, 31);
    
    // BEST WESTERN
	var iconCBW 				= new GIcon(); 
    iconCBW.image 				= 'images/marker-lodgingboise-BestWestern.png';
    iconCBW.iconSize 			= new GSize(30, 41);
    iconCBW.iconAnchor 			= new GPoint(15, 31);
    iconCBW.infoWindowAnchor 	= new GPoint(15, 31);
    
    // AIRPORT
	var iconAirport				= new GIcon(); 
    iconAirport.image 			= 'images/Marker-Airport.png';
    iconAirport.iconSize 		= new GSize(30, 41);
    iconAirport.iconAnchor 		= new GPoint(15, 31);
    iconAirport.infoWindowAnchor= new GPoint(15, 31);
    
    // RESTAURANT
	var iconRest				= new GIcon(); 
    iconRest.image 				= 'images/Marker-Restaurant.png';
    iconRest.iconSize 			= new GSize(30, 41);
    iconRest.iconAnchor 		= new GPoint(15, 31);
    iconRest.infoWindowAnchor	= new GPoint(15, 31);
    
    // EVENTS
	var iconEvents				= new GIcon(); 
    iconEvents.image 			= 'images/Marker-Events.png';
    iconEvents.iconSize 		= new GSize(30, 41);
    iconEvents.iconAnchor 		= new GPoint(15, 31);
    iconEvents.infoWindowAnchor	= new GPoint(15, 31);
    
    // ATTRACTION
	var iconAttr				= new GIcon(); 
    iconAttr.image 				= 'images/Marker-Attractions.png';
    iconAttr.iconSize 			= new GSize(30, 41);
    iconAttr.iconAnchor 		= new GPoint(15, 31);
    iconAttr.infoWindowAnchor	= new GPoint(15, 31);

    var customIcons = [];
    customIcons["comfortsuites"]= iconBCS;
    customIcons["sleepinn"] 	= iconNSI;
    customIcons["mrsandman"] 	= iconMSI;
    customIcons["bestwestern"] 	= iconCBW;
    customIcons["airport"]		= iconAirport;
    customIcons["restaurant"]	= iconRest;
    customIcons["event"]		= iconEvents;
    customIcons["attraction"]	= iconAttr;
    
    function showFrom(from_val)
    {
	    if (from_val == 'other')
	    {
		    document.getElementById("fromAddress2").style.visibility = "visible";
	    }
	    else
	    {
		    document.getElementById("fromAddress2").style.visibility = "hidden";
	    }
    }
    
    function showTo(to_val)
    {
	    if (to_val == 'other')
	    {
		    document.getElementById("toAddress2").style.visibility = "visible";
	    }
	    else
	    {
		    document.getElementById("toAddress2").style.visibility = "hidden";
	    }
    }
	
	function createMarker(point, nm, adr, typ, pid, pagetyp)
	{
		switch(typ)
		{
			case 'airport':
			case 'restaurant':
			case 'event':
			case 'attraction':
			case 'property':
				var marker = new GMarker(point, customIcons[pid]);
				break;
				
			default:
				var marker = new GMarker(point);
		}
		
		var mySplitResult = adr.split(",");
		var html = '<p><b>' + nm + '</b><br/>';
		html += mySplitResult[0] + '<br />';
		html += mySplitResult[1] + ', ' + mySplitResult[2] + '&nbsp;&nbsp;' + mySplitResult[3] + '</p>';
		if ((pagetyp == 'boise') && (typ != 'property'))
		{
			html += '<p><a href="javascript:void(0);" onclick="setDirections2(\'boise\',\'\', \'' + adr + '\',\'en_US\');">Directions from Comfort Suites Boise</a></p>';
		}
		else if ((pagetyp == 'nampa') && (typ != 'property'))
		{
			html += '<p><a href="javascript:void(0);" onclick="setDirections2(\'nampa\',\'\', \'' + adr + '\',\'en_US\');">Directions from Sleep Inn Nampa</a></p>';
		}
		else if ((pagetyp == 'caldwell') && (typ != 'property'))
		{
			html += '<p><a href="javascript:void(0);" onclick="setDirections2(\'caldwell\',\'\', \'' + adr + '\',\'en_US\');">Directions from Best Western Caldwell Inn and Suites</a></p>';
		}
		else if ((pagetyp == 'meridian') && (typ != 'property'))
		{
			html += '<p><a href="javascript:void(0);" onclick="setDirections2(\'meridian\',\'\', \'' + adr + '\',\'en_US\');">Directions from Mr Sandman Inn and Suites</a></p>';
		}
		/*else if (pagetyp == 'directions')
		{
			
		}*/
		else // DEEP PAGE / DIRECTIONS
		{
			if (typ != 'property')
			{
				html += '<p><a href="javascript:void(0);" onclick="setDirections2(\'boise\',\'\', \'' + adr + '\',\'en_US\');">Directions from Comfort Suites Boise</a><br />';
				html += '<a href="javascript:void(0);" onclick="setDirections2(\'meridian\',\'\', \'' + adr + '\',\'en_US\');">Directions from Mr Sandman Inn and Suites</a><br />';
				html += '<a href="javascript:void(0);" onclick="setDirections2(\'nampa\',\'\', \'' + adr + '\',\'en_US\');">Directions from Sleep Inn Nampa</a><br />';
				html += '<a href="javascript:void(0);" onclick="setDirections2(\'caldwell\',\'\', \'' + adr + '\',\'en_US\');">Directions from Best Western Caldwell Inn and Suites</a></p>';
			}
		}

		GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(html); });
		return marker;
	}
	
	function setDirections(fromAddress, toAddress, toAddress2, locale)
	{	
		switch(toAddress)
		{
			case 'meridian':
				toAddr = '1575 S Meridian Road,Meridian,ID,83642';
				break;
			
			case 'caldwell':
				toAddr = '908 Specht Avenue,Caldwell,ID,83605';
				break;
			
			case 'nampa':
				toAddr = '1315 Industrial Road,Nampa,ID,83687';
				break;
			
			case 'boise':
				toAddr = '2906 Vista Avenue,Boise,ID,83705';
				break;
				
			case 'other':
				toAddr = toAddress2;
				break;
			
			default:
				toAddr = '1575 S Meridian Road,Meridian,ID,83642';
				break;
		} // END SWITCH
		
		switch(fromAddress)
		{
			case 'airport':
			case 'boiseairport':
			case 'boise airport':
				fromAddress = '3201 Airport Way,Boise,ID, 83705';
				break;
				
			case 'highway84east':
			case 'highway 84 east':
			case 'highway84 east':
			case 'highway84eastbound':
			case 'highway 84 eastbound':
				fromAddress = 'I-84 E @43.673450, -116.682070';
				break;
				
			case 'highway84west':
			case 'highway 84 west':
			case 'highway84 west':
			case 'highway84westbound':
			case 'highway 84 westbound':
				fromAddress = 'I-84 W @43.549971, -116.170964';
				break;
				
		} // END fromAddress SWITCH
		
		
		
		gdir.load("from: " + fromAddress + " to: " + toAddr, { "locale": locale });
	}
	
	function setDirections2(fromAddress, fromAddress2, toAddress, locale)
	{	
		switch(fromAddress)
		{
			case 'meridian':
				fromAddr = '1575 S Meridian Road,Meridian,ID,83642';
				break;
			
			case 'caldwell':
				fromAddr = '908 Specht Avenue,Caldwell,ID,83605';
				break;
			
			case 'nampa':
				fromAddr = '1315 Industrial Road,Nampa,ID,83687';
				break;
			
			case 'boise':
				fromAddr = '2906 Vista Avenue,Boise,ID,83705';
				break;
				
			case 'other':
				fromAddr = fromAddress2;
				break;
			
			default:
				toAddr = '1575 S Meridian Road,Meridian,ID,83642';
				break;
		} // END SWITCH

		gdir.load("from: " + fromAddr + " to: " + toAddress, { "locale": locale });
	}
	
	function handleErrors()
	{
		if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		{
			alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().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.\n Error code: " + gdir.getStatus().code);
		}
		else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
		{
			alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
		}
		//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
		//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().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. \n Error code: " + gdir.getStatus().code);
		}
		else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
		{
			alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
		}
		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());
        	
        	//GDownloadUrl("http://www.lodgingboise.com/sandbox/gmaps_idaho_xml.php?id=" + shortName, function(data) 
        	
        	//GDownloadUrl("http://www.lodgingboise.com/sandbox/gmaps&id=" + shortName, function(data) 
        	GDownloadUrl("http://www.lodgingboise.com/gmaps&id=" + shortName, function(data) 
										  {
											  var bounds = new GLatLngBounds();
											  var xml = GXml.parse(data);
											  var markers = xml.documentElement.getElementsByTagName("marker");
											  for (var i = 0; i < markers.length; i++)
											  {
												  var nme = markers[i].getAttribute("name");
												  var adr = markers[i].getAttribute("address");
												  var typ = markers[i].getAttribute("typ");
												  var pid = markers[i].getAttribute("id");
												  var lat = markers[i].getAttribute("lat");
												  var lng = markers[i].getAttribute("lng");
												  
												  var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("lng")));
												  var marker = createMarker(point, nme, adr, typ, pid, shortName);
												  
												  map.addOverlay(marker);
												  bounds.extend(point);
											  }
											  map.setZoom(map.getBoundsZoomLevel(bounds));
											  map.setCenter(bounds.getCenter());
										   }
			);
			
			gdir = new GDirections(map, document.getElementById("map_directions"));
		    GEvent.addListener(gdir, "load", onGDirectionsLoad);
		    GEvent.addListener(gdir, "error", handleErrors);
		}
	}
	window.onunload = GUnload;