  	var ge;
    google.load("earth", "1");
    
    function init() {
      var content = document.getElementById('earth2');
      content.innerHTML = '';
      google.earth.createInstance('earth2', initCB, failureCB);
	  
	  addSampleButton('Ground Overlay Map', toggleGroundOverlay);
	  
    }
    
    function initCB(instance) {
      ge = instance;
      ge.getWindow().setVisibility(true);
	  
        
      // add a navigation control
      ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
	  	  
    
      // add some layers
      ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
      ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, true);
    
      // in this sample we will purposely attempt
      // to fetch a bad KML file (one that doesnt exist)
    
     // function finished(object) {
     //   if (!object) {
     //     alert('bad or NULL kml');
     //   }
      //}
      createGroundOverlay();
	  groundOverlay.setVisibility(false);
	  
    function finished(object) {
      if (!object) {
        // wrap alerts in API callbacks and event handlers
        // in a setTimeout to prevent deadlock in some browsers
        setTimeout(function() {
          alert('Bad or null KML.');
        }, 0);
        return;
      }
      ge.getFeatures().appendChild(object);
      var la = ge.createLookAt('');
      la.set(54.43267501665455, 160.1399940165077, 55, ge.ALTITUDE_RELATIVE_TO_GROUND,
             118, 75, 3780);
      ge.getView().setAbstractView(la); 
    }
      
      google.earth.fetchKml(ge, 'http://valleyofgeysers.com/includes/landslide.kml', finished);
    
      document.getElementById('installed-plugin-version').innerHTML =
          ge.getPluginVersion().toString();
    }
    
    function failureCB(errorCode) {
    }
    	
var groundOverlay;
	
	function createGroundOverlay() {
 groundOverlay = ge.createGroundOverlay('');
 groundOverlay.setIcon(ge.createIcon(''))
 groundOverlay.getIcon().setHref("http://valleyofgeysers.com/images/overlay2.jpg");
  groundOverlay.setLatLonBox(ge.createLatLonBox(''));

  var center = ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
  var north = 54.46309779103012;
 var south = 54.42319488154573;
 var east = 160.2346162925796;
 var west = 160.072634640312;
  var rotation = 50.50823804424713;
  var latLonBox = groundOverlay.getLatLonBox();
 latLonBox.setBox(north, south, east, west, rotation);

 ge.getFeatures().appendChild(groundOverlay);
     
}


function toggleGroundOverlay(){

if (groundOverlay.getVisibility() == true) {
   groundOverlay.setVisibility(false);
 } else {
  groundOverlay.setVisibility(true);
 }
 
} 

function buttonClick() {
  toggleGroundOverlay();
}
    google.setOnLoadCallback(init);