var HOME = {
	init : function()
	{
		if (document.getElementById('menu'))
		{
			var opcmenu = document.getElementById('menu').getElementsByTagName('img');
			for (cont = 0; cont < opcmenu.length; ++cont)
			{
				document.getElementById(opcmenu[cont].id).onmouseover = function()
				{
					if (this.id != 'active')
						document.getElementById(this.id).src = document.getElementById(this.id).src.replace('_off.','_on.');
				}
				
				document.getElementById(opcmenu[cont].id).onmouseout = function()
				{
					if (this.id != 'active')
					document.getElementById(this.id).src = document.getElementById(this.id).src.replace('_on.','_off.');
				}
				
				document.getElementById(opcmenu[cont].id).onclick = function()
				{
					if (this.id != 'active')
					{
						opcion = this.id;
						HOME.poneracero();
						document.getElementById(opcion).src = document.getElementById(this.id).src.replace('_off.','_on.');
						document.getElementById(opcion.replace('img','sub')).className = 'dblock';
						document.getElementById(opcion).id = 'active';
					}
					return false;
				}
			}
			document.getElementById('selected').onclick = function()
			{
				return false;
			}
		}
		if (document.getElementById('lnkimprimir'))
		{
			document.getElementById('lnkimprimir').onclick = function ()
			{
				window.print();
				return false;
			}
		}
	},
	poneracero : function()
	{
		var opmenu = document.getElementById('menu').getElementsByTagName('img');
		for (cont = 0; cont<opmenu.length; ++cont)
		{
			document.getElementById(opmenu[cont].id).src = document.getElementById(opmenu[cont].id).src.replace('_on.','_off.');
			document.getElementById(opmenu[cont].id).id = 'imghome'+parseInt(cont+1);
		}
		
		var opsubmenu = document.getElementById('submenu').getElementsByTagName('div');
		for (cont = 0; cont<opsubmenu.length; ++cont)
		{
			document.getElementById(opsubmenu[cont].id).className = 'dnone';
		}
	}
}


/* LOAD */

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

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