var map;
var geoXml; 
var toggleState	= 0;
var currentItem	= '';
/*you must add the default overlay file names below*/
var mainKML		= new GGeoXml('http://'+location.host+'/KMZ/South-China-Sea-Project.kmz');
var defaultKML	= new GGeoXml('http://'+location.host+'/KMZ/Demonstration-Sites.kml');

function initialize()
{
	if(GBrowserIsCompatible())
	{
		map = new GMap2(document.getElementById("map_canvas")); 
		map.setCenter(new GLatLng(8.0,108.5), 5, G_SATELLITE_MAP);
		map.addControl(new GLargeMapControl());
		map.addControl(new GLargeMapControl());
		map.addOverlay(mainKML);
		map.addOverlay(defaultKML);
	}
}

function toggleKML(kmlFile, itemID)
{
	if (toggleState == 1)
	{
		currentItem.style.border = "2px solid #ffffff";
		map.removeOverlay(geoXml);
		toggleState = 0;
	}
	currentItem	= document.getElementById(itemID);
	currentItem.style.border = "2px solid #0000ff";
	geoXml = new GGeoXml(kmlFile);
	map.addOverlay(geoXml);
	toggleState = 1;
	return false;
}

function clearOverlay()
{
	if(toggleState == 1)
	{
		currentItem.style.border = "2px solid #ffffff";
		map.removeOverlay(geoXml);
		toggleState = 0;
	}
	currentItem	= '';
	return false;
}

window.onload = function()
{
	initialize();
}

window.onunload = function()
{
	GUnload();
}
