var VISITA = {
	init : function()
	{
		if (document.getElementById('opcionesTxtVisita'))
		{			
			opc_menu = document.getElementById('opcionesTxtVisita').getElementsByTagName('a');
			for (cont = 0; cont<opc_menu.length; ++cont)
			{
				document.getElementById(opc_menu[cont].id).onmouseover = function () {
					imagen = document.getElementById(this.id).getElementsByTagName('img');
					if (imagen[0].src.indexOf('_on.')<0)
						imagen[0].src = imagen[0].src.replace('_off','_on');
				}
				
				document.getElementById(opc_menu[cont].id).onmouseout = function() {
					imagen = document.getElementById(this.id).getElementsByTagName('img');
					if (imagen[0].id != 'active')
						imagen[0].src = imagen[0].src.replace('_on','_off');
				}
				
				document.getElementById(opc_menu[cont].id).onclick = function () {
					VISITA.ponerImgOpcOff();
					imagen = document.getElementById(this.id).getElementsByTagName('img');
					imagen[0].src = imagen[0].src.replace('_off','_on');
					imagen[0].id = 'active';
					
					document.getElementById(this.id.replace('op','titulo')).className = 'dblock';
					
					VISITA.cambiarcuerpo(this.id);
					
					imagen_mos = this.id.replace('op','imgd')+'_1';
					
					VISITA.cambiarimgDcha(imagen_mos);
										
					VISITA.cambiar_mini_img(this.id);
					return false;
				}
			}
			
			opc_img_numeros = document.getElementById('map_visita').getElementsByTagName('area');
			for (cont = 0; cont<opc_img_numeros.length; ++cont)
			{
				document.getElementById(opc_img_numeros[cont].id).onmouseover = function () {
					opcion = this.id.substring(4,5);
					imagen = document.getElementById('img_top_vis'+opcion).getElementsByTagName('img');
					document.getElementById(imagen[0].id).className = 'visible';
				}
				document.getElementById(opc_img_numeros[cont].id).onmouseout = function () {
					opcion = this.id.substring(4,5);
					imagen = document.getElementById('img_top_vis'+opcion).getElementsByTagName('img');
					document.getElementById(imagen[0].id).className = 'oculto';
				}
				document.getElementById(opc_img_numeros[cont].id).onclick = function () {
					subopcion_sel = this.id.substring(4,5);
					imagen = document.getElementById('img_top_vis'+subopcion_sel).getElementsByTagName('img');
					opcion_sel = imagen[0].id.substring(10,11);
					opcion = 'imgdvisita'+opcion_sel+'_'+subopcion_sel;
					VISITA.cambiarimgDcha(opcion);
					return false;
				}
			}			
		}
	},
	ponerImgOpcOff : function()
	{
		opc_menu = document.getElementById('opcionesTxtVisita').getElementsByTagName('img');
		for (cont = 0; cont<opc_menu.length; ++cont)
		{
			opc_menu[cont].id = '';
			opc_menu[cont].src = opc_menu[cont].src.replace('_on','_off');;
		}
		
		opc_img = document.getElementById('tituloVisita').getElementsByTagName('img');
		for (cont = 0; cont<opc_img.length; ++cont)
		{
			document.getElementById(opc_img[cont].id).className = 'dnone';
		}
	},
	cambiarcuerpo : function(opc)
	{
		opselec = opc.replace('op','txt');
		capas = document.getElementById('cajacentro').getElementsByTagName('div');
		for (cont = 0; cont<capas.length; ++cont)
		{
			if (capas[cont].id == opselec)
				document.getElementById(capas[cont].id).className = 'dblock';
			else
				document.getElementById(capas[cont].id).className = 'dnone';
		}
	},
	cambiarimgDcha : function(opc)
	{
		imagenes = document.getElementById('cajadcha').getElementsByTagName('img');
		for (cont = 0; cont<imagenes.length; ++cont)
		{
			if (imagenes[cont].id == opc)
			{
				document.getElementById(imagenes[cont].id).className = 'dblock';
			}
			else
			{
				document.getElementById(imagenes[cont].id).className = 'dnone';
			}
		}
	},
	cambiar_mini_img : function(opc)
	{
		opselec = '_'+opc.substring(8,9)+'_';
		imagen1 = document.getElementById('img_top_vis1').getElementsByTagName('img');
		opactual = imagen1[0].id.substring(9,12);
		imagen1[0].src = imagen1[0].src.replace(opactual,opselec);
		imagen1[0].id = imagen1[0].id.replace(opactual,opselec);
		
		imagen2 = document.getElementById('img_top_vis2').getElementsByTagName('img');
		imagen2[0].src = imagen2[0].src.replace(opactual,opselec);
		imagen2[0].id = imagen2[0].id.replace(opactual,opselec);
		
		imagen3 = document.getElementById('img_top_vis3').getElementsByTagName('img');
		imagen3[0].src = imagen3[0].src.replace(opactual,opselec);
		imagen3[0].id = imagen3[0].id.replace(opactual,opselec);
		
		
	}
}


/* LOAD */

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

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