function initialize() {
  // initialize RSH
  dhtmlHistory.initialize();
  
  // add ourselves as a listener for history
  // change events
  dhtmlHistory.addListener(handleHistoryChange);
  
  // determine our current location so we can
  // initialize ourselves at startup
  var initialLocation = 
                dhtmlHistory.getCurrentLocation();
  
  // if no location specified, use the default
  if (initialLocation == null)
    initialLocation = "noticias";
  
  // now initialize our starting UI
  tabNavigation(initialLocation, null);
}

function handleHistoryChange(newLocation,
                             historyData) {
  // use the history data to update our UI
  tabNavigation(newLocation, historyData);                           
}

/* Js para el menu superior en pestañas. Amiguetes mi javascript no da por AHORA para mucho más, pero estoy convencido que tiene que haber alguna manera de automatizar la función tabNavigation() porque si os dais cuenta es una serie ordenada de numeros. Echarle un ojo */
function tabNavigation(lugar,historial) {
    
	
	var tab1 = document.getElementById("tab-0");
	var tab2 = document.getElementById("tab-1");
	var tab3 = document.getElementById("tab-2");
	var tab4 = document.getElementById("tab-3");
	var tab5 = document.getElementById("tab-4");
	var tab6 = document.getElementById("tab-5");
	var tab7 = document.getElementById("tab-6");
	
	var tab1content = document.getElementById("contenidos0");
	var tab2content = document.getElementById("contenidos1");
	var tab3content = document.getElementById("contenidos2");
	var tab4content = document.getElementById("contenidos3");
	var tab5content = document.getElementById("contenidos4");
	var tab6content = document.getElementById("contenidos5");
	var tab7content = document.getElementById("contenidos6");
	
	// por temas de accesibilidad oculto de inicio las capas no visibles
	
	
		

	tab1.onclick = function() {
		closeAll();
		tab1content.className = "caja1";
		this.className = "seleccionado";
		ObtenerDatos('/jsp/destacamos.jsp','destacamos');
		dhtmlHistory.add('mai',{message: 'hello world 1'});
		_nnEventTrack("http://www.universia.net/#mai");
		return false;
	}
	
	tab2.onclick = function() {
		closeAll();
		tab2content.className = "caja1";
		this.className = "seleccionado";
		ObtenerDatos('/jsp/destacamos1.jsp','destacamos');
		dhtmlHistory.add('empleo',{message: 'hello world 1'});
		_nnEventTrack("http://www.universia.net/#empleo");
		return false;
	}
	
	tab3.onclick = function() {
		closeAll();
		tab3content.className = "caja1";
		this.className = "seleccionado";
		ObtenerDatos('/jsp/destacamos3.jsp','destacamos');
		dhtmlHistory.add('formacion',{message: 'hello world 1'});
		_nnEventTrack("http://www.universia.net/#formacion");
		return false;
	}
	
	tab4.onclick = function() {
		closeAll();
		tab4content.className = "caja1";
		this.className = "seleccionado";
		ObtenerDatos('/jsp/destacamos4.jsp','destacamos');
		dhtmlHistory.add('noticias',{message: 'hello world 1'});
		_nnEventTrack("http://www.universia.net/#noticias");
		return false;
	}
	
	tab5.onclick = function() {
		closeAll();
		tab5content.className = "caja1";
		this.className = "seleccionado";
		ObtenerDatos('/jsp/destacamos0.jsp','destacamos');
		dhtmlHistory.add('abierto',{message: 'hello world 1'});
		_nnEventTrack("http://www.universia.net/#abierto");
		return false;
	}
	
	tab6.onclick = function() {
		closeAll();
		tab6content.className = "caja1";
		this.className = "seleccionado";
		ObtenerDatos('/jsp/destacamos.jsp','destacamos');
		dhtmlHistory.add('nosotros',{message: 'hello world 1'});
		_nnEventTrack("http://www.universia.net/#nosotros");
		return false;
	}
	
	tab7.onclick = function() {
		closeAll();
		tab7content.className = "caja1";
		this.className = "seleccionado";
		ObtenerDatos('/jsp/destacamos.jsp','destacamos');
		dhtmlHistory.add('observatorio',{message: 'hello world 1'});
		_nnEventTrack("http://www.universia.net/#observatorio");
		return false;
	}
	
	if (lugar=="") lugar="noticias";
	
	switch(lugar){
	case (lugar="mai"): tab1.onclick(); break;
	case (lugar="empleo"): tab2.onclick(); break;
	case (lugar="formacion"): tab3.onclick(); break;
	case (lugar="noticias"): tab4.onclick(); break;
	case (lugar="abierto"): tab5.onclick(); break;
	case (lugar="nosotros"): tab6.onclick(); break;
	case (lugar="observatorio"): tab7.onclick(); break;
	default:
	  tab1content.className = "hidden";
	  tab2content.className = "hidden";
		tab3content.className = "hidden";
		tab5content.className = "hidden";
		tab6content.className = "hidden";
		tab7content.className = "hidden";
	}
	
}

function closeAll() {
	var menuTabs = document.getElementById("menu").getElementsByTagName("li");
	for (var i=0; i<menuTabs.length; i++) {
		menuTabs[i].className = "";
	}
	
	for (var i=0; i<7; i++) {
		var tabs = document.getElementById("contenidos" + [i]);
		tabs.className = "hidden";
	}

}

//onload = tabNavigation;
onload=initialize;