var ge;var tour;var currentKmlObjects={'elikoshubschrauber':null,'tour1p':null,'tour2p':null,'tour3p':null,'sentieroavventura':null,'laghi':null,'montagnealpi':null,'rifugibaite':null,'valli':null,'tour1':null,'tour2':null,'tour3':null};google.load("earth","1");function init(){google.earth.createInstance('map3d',initCallback,failureCallback);};function loadSingleKml(n){loadKml(n);loadKml(n+'p');};function initCallback(instance){ge=instance;ge.getWindow().setVisibility(true);ge.getNavigationControl().setVisibility(ge.VISIBILITY_AUTO);ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS,true);loadKml('elikoshubschrauber');loadKml('sentieroavventura');loadKml('laghi');loadKml('montagnealpi');loadKml('rifugibaite');loadKml('valli');};function failureCallback(errorCode){};function toggleKml(file){for(var i=1;i<4;i++){if(currentKmlObjects['tour'+i]){ge.getFeatures().removeChild(currentKmlObjects['tour'+i]);currentKmlObject=null;};if(currentKmlObjects['tour'+i+'p']){ge.getFeatures().removeChild(currentKmlObjects['tour'+i+'p']);currentKmlObject=null;}};loadKml(file);loadKml(file+'p');};function loadKml(file){if(file=='tour1'||file=='tour2'||file=='tour3'){var kmlUrl='http://www.elikos.com/kml2/'+file+'.kmz'}else{var kmlUrl='http://www.elikos.com/kml2/'+file+'.kml'};google.earth.fetchKml(ge,kmlUrl,function(kmlObject){if(kmlObject){currentKmlObjects[file]=kmlObject;ge.getFeatures().appendChild(kmlObject);if(kmlObject.getType()=='KmlTour'){walkKmlDom(kmlObject,function(){if(this.getType()=='KmlTour'){tour=this;return false;}});exitTour();enterTour();playTour();document.getElementById('kml-'+file+'p-check').checked=true;if(currentKmlObjects[file+'p']){ge.getFeatures().removeChild(currentKmlObjects[file+'p']);currentKmlObject=null;};loadKml(file+'p');}}else{currentKmlObjects[file]=null;setTimeout(function(){alert('Bad or null KML.');},0);document.getElementById('kml-'+file+'-check').checked='';}});};function enterTour(){if(!tour){alert('No tour found!');return;};ge.getTourPlayer().setTour(tour);};function playTour(){ge.getTourPlayer().play();};function pauseTour(){ge.getTourPlayer().pause();};function resetTour(){ge.getTourPlayer().reset();};function exitTour(){ge.getTourPlayer().setTour(null);};google.setOnLoadCallback(init);
