  var ge;
  
  // store the object loaded for the given file... initially none of the objects
  // are loaded, so initialize these to null
  var currentKmlObjects = {
    'red': null,
    'yellow': null,
	'green': null,
    'blue': null
  };
  
  google.load("earth", "1");
 
  function init() {
    google.earth.createInstance('urf', initCB, failureCB);
  }
  
  function larseijssen() {
     var la = ge.createLookAt('');
     la.set(52.358478, 4.921671, 0, ge.ALTITUDE_RELATIVE_TO_GROUND, -8.541, 66.213, 20000);
     ge.getView().setAbstractView(la);
  }
  
  function performances() {
     var la = ge.createLookAt('');
     la.set(51.36769, 4.79719, 0, ge.ALTITUDE_RELATIVE_TO_GROUND, -19.80, 47.28, 166939.84);
     ge.getView().setAbstractView(la);
  }
  
  function shows() {
     var la = ge.createLookAt('');
     la.set(41.90598, -15.15054, 0, ge.ALTITUDE_RELATIVE_TO_GROUND, -0.18, 13.75, 6012833.82);
     ge.getView().setAbstractView(la);
  }
  
  function friends() {
     var la = ge.createLookAt('');
     la.set(49.19976, 14.09635, 0, ge.ALTITUDE_RELATIVE_TO_GROUND, -1.91, 28.09, 2028172.01);
     ge.getView().setAbstractView(la);
  }
  
  function initCB(instance) {
    ge = instance;
    ge.getWindow().setVisibility(true);
    
    // add a navigation control
    ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);
	
	// Eikenweg 9m
	larseijssen();
    
    // if the page loaded with checkboxes checked, load the appropriate
    // KML files
    if (document.getElementById('kml-red-check').checked)
      loadKml('red');
    
    if (document.getElementById('kml-yellow-check').checked)
      loadKml('yellow');
    
    if (document.getElementById('kml-green-check').checked)
      loadKml('green');
	  
    if (document.getElementById('kml-blue-check').checked)
      loadKml('blue');
    
    document.getElementById('installed-plugin-version').innerHTML =
      ge.getPluginVersion().toString();
  }
  
  function failureCB(errorCode) {
  }
  
  function toggleKml(file) {
    // remove the old KML object if it exists
    if (currentKmlObjects[file]) {
      ge.getFeatures().removeChild(currentKmlObjects[file]);
      currentKmlObject = null;
    }
    
    // if the checkbox is checked, fetch the KML and show it on Earth
    var kmlCheckbox = document.getElementById('kml-' + file + '-check');
    if (kmlCheckbox.checked)
      loadKml(file);
	  
	if (document.getElementById('kml-red-check').checked) 
	  larseijssen();
	  
    if (document.getElementById('kml-yellow-check').checked)
      performances();
    
    if (document.getElementById('kml-green-check').checked)
      shows();
	  
    if (document.getElementById('kml-blue-check').checked)
      friends();
  }
  
  function loadKml(file) {
    var kmlUrl = 'http://larseijssen.com/' + file + '.kml';  
    // fetch the KML
    google.earth.fetchKml(ge, kmlUrl, function(kmlObject) {
      // NOTE: we still have access to the 'file' variable (via JS closures)
      
      if (kmlObject) {
        // show it on Earth
        currentKmlObjects[file] = kmlObject;
        ge.getFeatures().appendChild(kmlObject);
      } else {
        // bad KML
        currentKmlObjects[file] = null;
  
        // 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);
        
        // uncheck the box
        document.getElementById('kml-' + file + '-check').checked = '';
      }
    });
  }