// Mapping Software (main)
//
// © 2007 Gary B. Little
//
// May 24, 2007
//

function mapMain() {

	gMarkerCount = 0;
	gScrollList = true;
	
	document.getElementById(kHotID).style.backgroundColor = kListOffColor;

	loadProperties();
	loadRegions();
	
	gStartCoordinates = regionDB[1].theLocation;
	gStartZoom = regionDB[1].theZoomLevel;
	gStartMode = G_PHYSICAL_MAP;
	
	gMap = new GMap2(document.getElementById(kMapID), {draggableCursor: 'move', draggingCursor: 'crosshair'});
	gMap.setCenter(gStartCoordinates, gStartZoom, gStartMode);
	
	gMap.addMapType(G_PHYSICAL_MAP);
	
	gMap.addControl(new GSmallMapControl());
	gMap.addControl(new GHierarchicalMapTypeControl());
	gMap.addControl(new GScaleControl());

	// Add the KeyDragZoom feature.
	//
	gMap.enableKeyDragZoom({
		key: "shift", 
		boxStyle: {
			border: "4px solid #736AFF",
			backgroundColor: "transparent",
			opacity: 1.0
		},
		veilStyle: {
			backgroundColor: "gray",
			opacity: 0.4,
			cursor: "crosshair"
		},
		visualEnabled: true,
		visualPosition: new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(17, 110))
	});
	
	if ( kShowCoordinates ) { addLatLongDisplay(gMap, kCoordinatesID); }
	if ( kShowDateDisplay ) { addDateDisplay(gMap, kUpdatedID); }
	
	
	addMapTypeChangedListener();
	addMarkers();
	
	
	// Attach fixed-position controls:
	//
	//	-- Branding graphics
	//	-- Copyright notice
	//
	if ( document.getElementById(kBrandID) != null ) {
	
		gPosControl = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(3, 35));
		gPosControl.apply(document.getElementById(kBrandID));
		gMap.getContainer().appendChild(document.getElementById(kBrandID));
	}
	
	if ( document.getElementById(kCopyrightID) != null ) {
	
		document.getElementById(kCopyrightID).innerHTML = kCopyrightNotice;
		gPosControl = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(3, 13));
		gPosControl.apply(document.getElementById(kCopyrightID));
		gMap.getContainer().appendChild(document.getElementById(kCopyrightID));
	}
	
	if ( kBillboardID ) { beginAdvertising(); }
}
