
 google.load("earth", "1");



 var ge = null; 
 var LayerWheatProduction=null;
 var Produccion=null;
 var link2=null;  var lookAt;
 var PathWay=null;
  var countries=null;
  var Races2008= null;
  var Pre_2008_races=null;
  var Screening_sites=null;
  var SurveyFeb09=null;   var SurveyMarch09=null;   var SurveyApr09=null;   var SurveyMay09=null;   var SurveyJun09=null;   var SurveyJul09=null;   var SurveyAug09=null;   var SurveySep09=null;   var SurveyOct09=null;
  
 var SurveySite2009=null;
 var SurveySiteFeb2009=null; 
 var SurveySiteMarch2009=null; 
 var SurveySiteApril2009=null; 
 var SurveySiteMay2009=null; 
 var SurveySiteJun2009=null; 
 var SurveySiteJuly2009=null; 
 var SurveySiteAug2009=null; 
 var SurveySiteSep2009=null; 
 var SurveySiteOct2009=null; 
 

 
function init() 
 {  google.earth.createInstance("map3d", initCallback, failureCallback); }
function initCallback(object)  
{  ge = object;  
   ge.getWindow().setVisibility(true);  
   ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
   ge.getOptions().setStatusBarVisibility(true);
   lookAt= ge.getView().copyAsLookAt(ge.ALTITUDE_RELATIVE_TO_GROUND);
   lookAt.setLatitude(14.093957); lookAt.setLongitude(42.363281);
   Produccion = ge.createNetworkLink("");   
   Produccion.setDescription("Production wheat");
   Produccion.setName("production");
   Produccion.setFlyToView(true);
   link2 = ge.createLink("");   
   link2.setHref("http://www.cimmyt.org/gis/rustmapper/RustMapper_web.kmz");
   Produccion.setLink(link2);
   ge.getGlobe().getFeatures().appendChild(Produccion); 
   LayerWheatProduction=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/WheatProduction.kmz');  
   PathWay=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/Pathway.kmz');
   countries=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/Countries.kmz');
   Races2008=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/2008_races.kmz');
   Pre_2008_races=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/Pre_2008_races.kmz');
   Screening_sites=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/screening_sites.kmz');
   SurveyFeb09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveyFeb09.kmz'); 
   SurveyMarch09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveyMarch09.kmz');   
   SurveyApr09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveyApr09.kmz');   
   SurveyMay09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveyMay09.kmz'); 
   SurveyJun09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveyJun09.kmz');   
   SurveyJul09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveyJul09.kmz');
   SurveyAug09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveyAug09.kmz');  
   SurveySep09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveySep09.kmz');
   SurveyOct09=getNL('http://www.cimmyt.org/gis/rustmapper/OnWeb/SurveyOct09.kmz');
   
   
 

   
    AsignaLinkTrayectorias();

   
   
   
   VisualizaTrayectorias();  
   ge.getView().setAbstractView(lookAt);
 } 
function failureCallback(object) {   } 
function getNL(kmlURL){  
   var nl = ge.createNetworkLink("");
   var link = ge.createLink("");
   link.setHref(kmlURL);  
   nl.setLink(link);
   ge.getGlobe().getFeatures().appendChild(nl);
   return nl; 
} 


 
 function VisualizaTrayectorias(){ 
   LayerWheatProduction.setVisibility(document.Trayectorias.WheatProduction.checked); 
   PathWay.setVisibility(document.Trayectorias.CheckPathWay.checked);
   countries.setVisibility(document.Trayectorias.CheckCountries.checked); 
   Races2008.setVisibility(document.Trayectorias.CheckRaces2008.checked);
   Pre_2008_races.setVisibility(document.Trayectorias.CheckPre_2008_race.checked);
   Screening_sites.setVisibility(document.Trayectorias.CheckScren_Site.checked);
  
   SurveyFeb09.setVisibility(document.Trayectorias.CheckSurveyFeb09.checked);
   SurveyMarch09.setVisibility(document.Trayectorias.CheckSurveyMarch09.checked);
   SurveyApr09.setVisibility(document.Trayectorias.CheckSurveyApr09.checked);   
   SurveyMay09.setVisibility(document.Trayectorias.CheckSurveyMay09.checked);
   SurveyJun09.setVisibility(document.Trayectorias.CheckSurveyJun09.checked);
   SurveyJul09.setVisibility(document.Trayectorias.CheckSurveyJul09.checked);
   SurveyAug09.setVisibility(document.Trayectorias.CheckSurveyAug09.checked); 
   SurveySep09.setVisibility(document.Trayectorias.CheckSurveySep09.checked); 
   SurveyOct09.setVisibility(document.Trayectorias.CheckSurveyOct09.checked);
   
  
  
  ChecaTrayectorias();
   
  

} 


function VisualizaConjunto(cual)
{
switch(cual){
    case "SurveyAll2009": 
        document.Trayectorias.CheckSurveyFeb09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
   document.Trayectorias.CheckSurveyMarch09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
  document.Trayectorias.CheckSurveyApr09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
   document.Trayectorias.CheckSurveyMay09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
   document.Trayectorias.CheckSurveyJun09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
   document.Trayectorias.CheckSurveyJul09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
   document.Trayectorias.CheckSurveyAug09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
   document.Trayectorias.CheckSurveySep09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
   document.Trayectorias.CheckSurveyOct09.checked=document.Trayectorias.CheckAllSurvey2009.checked;
   VisualizaTrayectorias();
   break;
   

		
		}//switch
}













/****************************************************************
Menú en arbol accesible. 28-Jul-07
Autor tunait http://javascript.tunait.com/
Script de libre uso mientras se mantengan intactos los créditos de autor.
****************************************************************/
var abrirenVentanaNueva = 0;


var tagApartado = 'a';
var docActual = location.href;
function iniciaMenu(menu){
	idMenu = menu
	menu = document.getElementById(menu);
	for(var m = 0; m < menu.getElementsByTagName('ul').length; m++){
		el = menu.getElementsByTagName('ul')[m]
		el.style.display = 'none';
		el.className = 'menuDoc';
		el.parentNode.className = 'cCerrada'
		textoNodo = el.parentNode.firstChild.nodeValue;
		nuevoNodo = document.createElement(tagApartado);
		if(tagApartado == 'a') nuevoNodo.href = '#' + textoNodo;
		nuevoNodo.className = 'tagApartado';
		nuevoNodo.appendChild(document.createTextNode(textoNodo));
		el.parentNode.replaceChild(nuevoNodo,el.parentNode.firstChild);
    
		nuevoNodo.onclick = function(){
			hijo = sacaPrimerHijo(this.parentNode, 'ul')
			hijo.style.display = hijo.style.display == 'none' ? 'block' : 'none';
			if(this.parentNode.className == 'cCerrada' || this.parentNode.className == 'cAbierta'){
				this.parentNode.className = this.parentNode.className == 'cCerrada' ? 'cAbierta' : 'cCerrada'
			}
			else{
				this.parentNode.className = this.parentNode.className == 'cAbiertaSeleccionada' ? 'cCerradaSeleccionada' : 'cAbiertaSeleccionada' 
			}
			return false;
		}
	}
	documentoActual(idMenu)
}
function sacaPrimerHijo(obj, tag){
	for(var m = 0; m < obj.childNodes.length; m++){
		if(obj.childNodes[m].tagName && obj.childNodes[m].tagName.toLowerCase() == tag){
			return obj.childNodes[m];
			break;
		}
	}
}
function documentoActual(menu){
	idMenu = menu
	menu = document.getElementById(menu);
	for(var s = 0; s < menu.getElementsByTagName('a').length; s++){
		if(abrirenVentanaNueva) menu.getElementsByTagName('a')[s].target = 'blank';
		enlace = menu.getElementsByTagName('a')[s].href
		if(enlace == docActual){
			menu.getElementsByTagName('a')[s].parentNode.className = 'documentoActual'
		}
		if(enlace == docActual && menu.getElementsByTagName('a')[s].parentNode.parentNode.id != idMenu){
			menu.getElementsByTagName('a')[s].parentNode.parentNode.parentNode.className = 'cAbiertaSeleccionada'
			var enlaceCatPadre = sacaPrimerHijo(menu.getElementsByTagName('a')[s].parentNode.parentNode.parentNode, 'a')
			enlaceCatPadre.onclick = function(){
				hijo = sacaPrimerHijo(this.parentNode, 'ul')
				hijo.style.display = hijo.style.display == 'none' ? 'block' : 'none';
				this.parentNode.className = this.parentNode.className == 'cAbiertaSeleccionada' ? 'cCerradaSeleccionada' : 'cAbiertaSeleccionada' 
				return false;

			} 
			nodoSig = sacaPrimerHijo(menu.getElementsByTagName('a')[s].parentNode.parentNode.parentNode, 'ul')
			nodoSig.style.display = 'block';/**/
			abrePadre(idMenu, enlaceCatPadre.parentNode)
		}
	}
}
function abrePadre(idmenu, obj){
	obj.parentNode.parentNode.className = 'cAbiertaSeleccionada'
	var nodoSig = sacaPrimerHijo(obj, 'ul')
	nodoSig.style.display = 'block';
	if(obj.parentNode.id != idmenu){
		abrePadre(idmenu, obj.parentNode.parentNode)
	}
}