//Thoses variable must be filled dynamically in the HotelLocation.ascx user control
var hotelName='';
var hotelAddress='';
var hotelGeoPoint = null;

function googleMapInit() {
	if (GBrowserIsCompatible()) {
        
        if(hotelName=='' || hotelAddress=='' || hotelGeoPoint==null)
        {
            alert('Maps initialization failed. Please insure that all parameters were specified correctly.');
        }
        
		window.baseIcon = new GIcon();
			baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
			baseIcon.image = SitePath+"Images/UI/googleMapMarker.png";
			baseIcon.iconSize = new GSize(20, 34);
			baseIcon.shadowSize = new GSize(37, 34);	
			baseIcon.iconAnchor = new GPoint(6, 20);
			baseIcon.infoWindowAnchor = new GPoint(5, 1);

		function createMarker(point, name, htmlNode) {
			var marker = new GMarker(point, baseIcon);
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindow(htmlNode);
				});
			return marker;
			} 
			
		function createHTMLNode(id, address, friendlyName, point) {     
			// prepare the root node
			var root = document.createElement("div");
			root.className = "map-content";
			
			// title node
			var title = document.createElement("p");
			title.className = "map-title";
			title.innerHTML = friendlyName;
			root.appendChild(title);
								
			// address
			var addr = document.createElement("p");
			addr.innerHTML = address;
			root.appendChild(addr);
			
			return root;
			}					


    	var map = new GMap2(document.getElementById("google-map"));
		
		
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(hotelGeoPoint, 13);

		/* get the html node */
		var html = createHTMLNode("Loews", hotelAddress, hotelName, hotelGeoPoint);					
		/* add the marker with the html to the map as an overlay */
		map.addOverlay(createMarker(hotelGeoPoint, "Loews", html));
		} //GBrowserIsCompatible
	}
	
YAHOO.util.Event.addListener(window, "load", googleMapInit);
YAHOO.util.Event.addListener(window, "unload", GUnload);

function getDirection() {

	
	var elementID = "Get Google Map Direction";
    var elementCategory = "Get Google Map Direction";
    COREMETRICS.utils.cmCreatePageElementTag(escape(elementID),escape(elementCategory),COREMETRICS.tagging.pageName,COREMETRICS.tagging.categoryID,null);

	var g_daddr = document.getElementById("daddr").value;
	var g_h1 = document.getElementById("h1").value;
	var g_saddr = document.getElementById("saddr").value;
	
	if(g_saddr) {
		popWin("http://maps.google.com/maps?daddr="+g_daddr+"&h1="+g_h1+"&saddr="+g_saddr,800,600,1,0,'gmap',1);
		}
	return false;
	}
