
var gLoaded = false;

function init() {
	gLoaded = true;
	// Turn on appropriate tab
	var tabFunction = eval("turnon_" + gActiveTab);
	tabFunction();
	setTimeout(loadMap, 250);
}

function loadMap() {
	// Google Map stuff
	if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        var latLng = new GLatLng(gLatitude, gLongitude);
        map.setCenter(latLng, gZoomLevel);
        // Allow for map control
        map.addControl(new GLargeMapControl());
        // Allow for map type control
        var mapControl = new GMapTypeControl();
        map.addControl(mapControl);
		// Set map type
	    map.setMapType(gMapType);
        
        // Create a point
        var point = new GPoint(gLongitude, gLatitude);
        // Create a marker
        var marker = new GMarker(point);
		        
		// Add onclick event
        //GEvent.addListener(marker,"click", function() {
        //	var myHtml = "HRP Ltd - Head Office";
        //	map.openInfoWindowHtml(latLng, myHtml);
	    //  	} );
        
        // Add a marker to the map
        map.addOverlay(marker);
        
        // Add traffic options
		//var trafficOptions = {incidents:true};
        //var  trafficInfo = new GTrafficOverlay(trafficOptions);
        //map.addOverlay(trafficInfo);
   	}
}

function enterKey(event) {
  if (getKeyEvent(event) == 13)
    return getDirections();
  return true;;
}

function getDirections() {
	document.directions.saddr.value = document.main.saddr.value;
	document.directions.submit();
	return true;
}
