window.dhtmlHistory.create({
        toJSON: function(o) {
                return Object.toJSON(o);
        }
        , fromJSON: function(s) {
                return s.evalJSON();
        }
});

var yourListener = function(newLocation, historyData) {
	if(newLocation=='inicio'){
		window.location="index.php";
	}else{
		hitoriar(historyData);
	}
}

window.onload = function() {
        dhtmlHistory.initialize();
        dhtmlHistory.add('inicio','');
        dhtmlHistory.addListener(yourListener);
};
function hitoriar(element){
	   if($(element)!=null && $(element).getAttribute('tipo')){
		   tipo=$(element).readAttribute('tipo').split(',');
		   id=$(element).readAttribute('id').split(',');
		   destino=$(element).readAttribute('destino').split(',');
		   for(i=0;i<tipo.length;i++){
		   if($(element).readAttribute('mostrar')!='si'){
			   todos=$('contenido').descendants();
			   for ( var int = 0; int < todos.length; int++) {
				   todos[int].writeAttribute('mostrar','no');
			}
			   if(i==(tipo.length-1)){$(element).writeAttribute('mostrar','si');};
			   $(destino[i]).update('');
			   muestra(tipo[i],id[i],destino[i]);
		   } else{
			   if(i==(tipo.length-1)){$(element).writeAttribute('mostrar','no');}
				ocultar(destino[i]);
		   }
		   }
	   }
}

