/*
	**** GOOGLE EARTH PLUGIN CODE ****
	**** FROM SAILBLOGS.COM       ****
*/
	google.load("earth", "1");
	
	var ge = null;
	
	var fileOne = null;
	var fileTwo = null;
	var fileThree = null;
	var fileFive = null;
          
	function init() {
		google.earth.createInstance("map3d", initCB, failureCB);
	}
	
	function initCB(object) {

		ge = object;
		ge.getWindow().setVisibility(true);

		function getNL(kmlURL,fly){
			var nl = ge.createNetworkLink("");
			var link = ge.createLink("");
			
			link.setHref(kmlURL);
			nl.setLink(link);
			
			if (fly == 1) {
				nl.setFlyToView(true);
			}
			
			ge.getGlobe().getFeatures().appendChild(nl);
			
			return nl;
		}
    
		// fetch the KML
		fileOne = getNL('http://www.sailblogs.com/sailblogs.kml?t=256&a=40000',1);
		fileTwo = getNL('http://www.petegoss.com/sailblogs/Route_du_Rhum.kmz',0);
	//	fileThree = getNL('http://www.sailblogs.com/sailblogs.kml?t=256&a=40000',1);
	//	fileFour = getNL('http://bbs.keyhole.com/ubb/download.php?Number=123408',0);
	//	fileFour = getNL('http://www.gearthhacks.com/forums/downloads.php?do=file&act=down&id=380',0);
	//	fileFive = getNL('http://www.roaditravel.com/kml/goss/heli_evac.kml',0);
		
		updateOptions();
	}
	
	function failureCB(object) {
		/***
		* This function will be called if plugin fails to load...
		***/
	}
	
	function updateOptions() {
		var options = ge.getOptions();
		var form = document.options;
		
		options.setStatusBarVisibility(form.statusbar.checked);
		options.setGridVisibility(form.grid.checked);
		options.setOverviewMapVisibility(form.overview.checked);
		options.setScaleLegendVisibility(form.scaleLegend.checked);
		options.setAtmosphereVisibility(form.atmosphere.checked);
		options.setMouseNavigationEnabled(form.mouseNav.checked);
		
		// check boxes for files...
		fileOne.setVisibility(form.file1.checked);
		fileTwo.setVisibility(form.file2.checked);
	//	fileThree.setVisibility(form.file3.checked);
	//	fileFour.setVisibility(form.file4.checked);
	//	fileFive.setVisibility(form.file5.checked);
		
		if (form.nav.checked) {
			ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
		} else {
			ge.getNavigationControl().setVisibility(ge.VISIBILITY_HIDE);
		}
	}
	
/*
	**** END GOOGLE EARTH PLUGIN CODE ****
*/

