var HISTORIA = {
	init : function()
	{
		if (document.getElementById('cajahistoria'))
		{
			var opcimg = document.getElementById('cajahistoria').getElementsByTagName('area');
			for (cont = 0; cont<opcimg.length; ++cont)
			{
				document.getElementById(opcimg[cont].id).onmouseover = function()
				{
					id = this.id.replace('op','img');
					document.getElementById(id).className = 'visible';
				}
				document.getElementById(opcimg[cont].id).onmouseout = function()
				{
					id = this.id.replace('op','img');
					document.getElementById(id).className = 'oculto';				
				}
				document.getElementById(opcimg[cont].id).onclick= function()
				{
					HISTORIA.ocultarParrafos();
					HISTORIA.ocultarImagenes();
					op = 'txtopcionesmapa'+this.id.substring(6,7);
					HISTORIA.poneracero(op);
					id = this.id.replace('op','capatxt');					
					document.getElementById(id).className = 'dblock';
					
					id_sub = this.id.replace('op','txtopciones');
					if (document.getElementById(id_sub))
					{
						var opclnk = document.getElementById(id_sub).getElementsByTagName('a');
						for (conlnk = 0; conlnk < opclnk.length; ++conlnk)
						{
							document.getElementById(opclnk[conlnk].id).onclick = function()
							{
								HISTORIA.ocultarImagenes();
								op = 'txtopcionesmapa'+this.id.substring(6,7);
								HISTORIA.marcarActive(op,this.id);
								document.getElementById(this.id.replace('lnkimg','imgtxtmapa')).className = 'dblock';
								return false;
							}
						}
						
					}
					
					idimg = this.id.replace('op','imgtxt');
					document.getElementById(idimg).className = 'dblock';	
					return false;
				}
			}
		}
	},
	ocultarParrafos : function()
	{
		var opctxt = document.getElementById('cajacentro').getElementsByTagName('div');
		for (cont = 0; cont<opctxt.length; ++cont)
		{
			document.getElementById(opctxt[cont].id).className = 'dnone';			
		}
	},
	ocultarImagenes : function()
	{
		imagenes = document.getElementById('cajacentro').getElementsByTagName('img');
		for (conlnk = 0; conlnk < imagenes.length; ++conlnk)
		{
			if (imagenes[conlnk].id != 'aux')
			document.getElementById(imagenes[conlnk].id).className = 'dnone';	
		}
	},
	marcarActive : function(capa, opcion)
	{
		var opclnk = document.getElementById(capa).getElementsByTagName('a');
		for (conlnk = 0; conlnk < opclnk.length; ++conlnk)
		{
			if (opclnk[conlnk].id == opcion)
				document.getElementById(opclnk[conlnk].id).className = "active";
			else
				document.getElementById(opclnk[conlnk].id).className = "noactive";
		}
	},
	poneracero : function(op)
	{
		if (document.getElementById(op))
		{
			var opclnk = document.getElementById(op).getElementsByTagName('a');				
			for (conlnk = 0; conlnk < opclnk.length; ++conlnk)
			{
				if (conlnk == 0)
					document.getElementById(opclnk[conlnk].id).className = "active";
				else
					document.getElementById(opclnk[conlnk].id).className = "noactive";
			}
		}
	}
}


/* LOAD */

function addLoadEvent(fn)
 {
	var old = window.onload;
	if(typeof window.onload != 'function')
		window.onload = fn;
	else
		window.onload = function()
		 {
			old();
			fn();
		 }
 }

addLoadEvent( function() { HISTORIA.init(); } );
