/* ******************************************************************************/
/* onLoad */
/* ******************************************************************************/

Event.observe(window, "load", function() {
	// hack para que IE haga cache de los backgrounds
	if(document.uniqueID && !window.XMLHttpRequest ) document.execCommand("BackgroundImageCache",false,true);

	// para todo ul clase hide
	$$('ul.hide').each(function(item){
		item.hide();
		item.removeClassName("hide");
		item.addClassName("loraimer");
		$(document.body).insert(item.remove());
		eval('window.'+item.id+' = new Loro(\''+item.id+'\')');
	});
});

/* ******************************************************************************/
/* Para ocultar y enseñar el menú de seguros */
/* ******************************************************************************/
var Loro = Class.create({
	initialize: function(id) {
		this.id = id;
		this.interval = null;
		$(id).observe("mousemove", function() {
			eval('window.'+this.id+'.somethingOver()');
		});
	},
	appear: function() {
		$(this.id).show();
		$(this.id+'Link').addClassName("over");
	},
	fade: function() {
		clearInterval(this.interval);
		$(this.id).hide();
		$(this.id+'Link').removeClassName("over");
	},
	somethingOver: function() {
		if(this.interval!=null) { clearInterval(this.interval); }
		this.interval = setInterval(this.fade.bind(this), 3000);
	}    
});

function showItem(a)
{
	hideOthers();
	eval(a.id.substring(0,a.id.indexOf('Link'))+'.appear()');
}

function showSubItem(a)
{
	hideSubOthers();

	var item = $(a.id.substring(0,a.id.indexOf('Link')))
	item.addClassName("subloraimer");
	item.setStyle({
	  position: 'absolute',
	  top: 0,
	  left: item.up().up().getStyle('width')
	});
	item.removeClassName("subHide");
}

function hideOthers()
{
	$$('ul.loraimer').each(function(item){
		eval(item.id+'.fade()');
	});
	hideSubOthers();
}

function hideSubOthers()
{
	$$('ul.subloraimer').each(function(item){
		var item = $(item.id);
		item.addClassName("subHide");
		item.removeClassName("subloraimer");
	});
}

function d(id)
{
	Effect.SlideDown(id);
	return false;
}
function u(id)
{
	Effect.SlideUp(id);
	return false;
}

function avisolegal2() {
	var win2 = new Window({url: "avisolegal2.php", className: "alphacube", width: 545, height:500, maximizable:false, minimizable:false, opacity:1, showEffect: Effect.Appear, hideEffect: Element.hide });
	win2.showCenter();		
	win2.setZIndex(99);
	WindowCloseKey.init();
}

function enviardb() {
	f = document.forms['bdform_srch'];
	if (f.en[0].checked || f.en[1].checked) {
		return true;
	} else {
		alert('Debe seleccionar un tipo de documento'); return false;
	}
}


