// JavaScript Document
var durada	= 2000;
var tanco	= 0;
var menu	= 0;

// Mostro la capa oculta
function obrir(id)
{	
	// cancel close timer
	aturar();

	// close old layer
	if(menu) menu.style.display = 'none';

	// get new layer and show it
	menu = document.getElementById(id);
	menu.style.display = 'block';

}
// Tanco la capa oberta
function amagar()
{
	if(menu) menu.style.display = 'none';
}

// go close timer
function tancar()
{
	tanco = window.setTimeout(amagar, durada);
}

// cancel close timer
function aturar()
{
	if(tanco)
	{
		window.clearTimeout(tanco);
		tanco = null;
	}
}

// close layer when click-out
// document.onclick = amagar;
document.onmouseup = amagar;
