//	Setup the GEPlugin Instance
google.load("earth", "1");
google.load("maps", "2.99");  // For JS geocoder

var ge = null;
var geocoder;

function startMission()
{
	
	init();
	
	$('#BondTitlesMenu').show();
	
	$('#BondGEInstance').show();
	
	swfobject.embedSWF( "/Application.swf", "menu", "280", "443", "9.0.0", "/expressinstall.swf", flashVars, params, attribs );	
	
}


/*
	emthod triggered on page Body load. Sets up the GEPlugin instance

*/
function init() {
  geocoder = new GClientGeocoder();
  google.earth.createInstance("map3d", initCB, failureCB);
}

function failureCB(object) {
  //alert('load failed');
}


/*
	If the plugin initated OK then execute

*/
function initCB(object) {
	
	
  	ge = object;
  	ge.getWindow().setVisibility(true);

	//	Make sure the 3D buildings are displayed by default.
	var buildingsLayer = ge.getLayerRoot().getLayerById(ge.LAYER_BUILDINGS);
	var inheritedVisibility = getInheritedVisibility(buildingsLayer);
	ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, !inheritedVisibility);


}


function getInheritedVisibility(layer) {
  if (layer.getVisibility() == false) {
    return false;
  } else {
    var parent = layer.getParentNode();
    if (!parent) {
      return true;
    }
    return getInheritedVisibility(parent);
  }
}