// ---------------------------------------------------------------- layers ---------------------------------------------------------------
var browser = 0; //unknown
if (document.all) browser  = 1; //ie
else if (document.layers) browser = 2; //netscape

//positions
var headerH=109;

var posX=555, posY=280+headerH, posH=4+120; //posH: height of menu; posY: top of the menu; posX: left of the menu
var posW=122;
var clipL=0, clipT=0, clipW=0, clipH=0, cliptoH=0;
var MenusID="Menus";
var wannahide=0;
var IsDisplaying=false;


//timers
var tmrID = null, tmrID2 = null;

function setVisible(id, visible)
{
	if (id==null) return;
	switch (browser)
	{
		case 1:	if (visible) document.all[id].style.visibility = "visible"; else document.all[id].style.visibility = "hidden";
			break;
		case 2:	if (visible) document.layers[id].visibility = "show"; else document.layers[id].visibility = "hide";
			break;
	}
}

function getLayer(id)
{
	if (id==null) return;
	switch (browser)
	{
		case 1:	return document.all[id].style;
			break;
		case 2:	return document.layers[id];
			break;
	}
}

function clipLayer(id, left, top, width, height)
{
	var tmp=getLayer(id);

	switch (browser)
	{
	case 1: tmp.clip = "rect(" + top + " " + (left + width) + " " + (top+height) + " " + left + ")";
			break;
	case 2: tmp.clip.left=left;
	            tmp.clip.top=top;
	            tmp.clip.right=left+width;
                          tmp.clip.bottom=top+height;
			break;
	}	
}

function init()
{
	var tmp=getLayer(MenusID);	


	IsDisplaying=true;

	setVisible(MenusID, false);	

	tmp.left=posX;
	tmp.top=posY;
	clipL=0;
	clipT=posH;
	clipW=posW;
	clipH=0;
	cliptoH=posH;
	clipLayer(MenusID, clipL, clipT, clipW, clipH);

	setVisible(MenusID, true);
}

function displayLayer()
{
	var maxdelta = (cliptoH-clipH);
	
	if (clipH<=cliptoH)
	{

		clipH+=10;
		clipT-=10;

		var tmp=getLayer(MenusID);

		clipLayer(MenusID, clipL, clipT, clipW, clipH);
	}
	else
	{
		if (tmrID!=null)
		{
			clearInterval(tmrID);
			tmrID=null;
		}
	}
	
	
}

function hideMenu()
{	
	if (wannahide>0) 
	{
		wannahide--;
		if (wannahide>0) return;
		
		IsDisplaying=false;

		setVisible(MenusID, false);
		if (tmrID2!=null)
		{
			clearInterval(tmrID2);
			tmrID2=null;
		}		
	}

}

function showMenu()
{
	if (IsDisplaying) return;
	init();
	if (tmrID==null) tmrID = setInterval("displayLayer();", 50);
	if (tmrID2==null) tmrID2 = setInterval("hideMenu();", 500);
}


function movein()
{
	wannahide=0;
}

function moveout()
{
	wannahide=4;
}