var oldmenu;
var menuopen=false;
var mouseovertherainbow=false;
var tid,tid1;

function shw(idx)
{
mouseovertherainbow=true;
window.clearTimeout(tid1);
var cx=window.event.clientX;
var cy=window.event.clientY;
var ox=window.event.offsetX;
var oy=window.event.offsetY;
if (menuopen){
		showmenu1(idx,cx,cy,ox,oy)
	}else{
		var hedestr="showmenu1("+idx+","+cx+","+cy+","+ox+","+oy+");"
		tid1=window.setTimeout(hedestr, 500);
	}
window.event.returnValue=false;
}

function showmenu(idx)
{
mouseovertherainbow=true;
window.clearTimeout(tid1);
var cx=window.event.clientX;
var cy=window.event.clientY;
var ox=window.event.offsetX;
var oy=window.event.offsetY;
if (menuopen){
		showmenu1(idx,cx,cy,ox,oy)
	}else{
		var hedestr="showmenu1("+idx+","+cx+","+cy+","+ox+","+oy+");"
		tid1=window.setTimeout(hedestr, 500);
	}
window.event.returnValue=false;
}

function showmenu1(idx,lcx,lcy,lox,loy)
{
//alert(idx);
window.clearTimeout(tid);
tid=window.setTimeout("checktherainbow()", 1000);
if ((parseInt(idx)==0)) 
	{
	if (typeof(oldmenu)=='object') { menulayer.style.visibility='hidden';}
	return;
	}
	lzobj=eval('document.all.mntd_'+idx);
	menu=eval('mn_'+idx)
	if (idx==maxmenu)
	{
	menulayer.style.left= lcx-lox+document.body.scrollLeft-60;
	}else
	{
	menulayer.style.left= lcx-lox+document.body.scrollLeft-3;
		
	}
	menulayer.style.top= lcy-loy+document.body.scrollTop+lzobj.offsetHeight-1;
//	menulayer.style. backgroundColor=mnucolors[idx];
	menulayer.style.visibility='visible';
	if (typeof(oldmenu)=='object') { oldmenu.style.display='none'; }
	menu.style.display='inline';
	oldmenu=menu;
	menuopen=true;
	hideElement("APPLET");
	hideElement("SELECT");
	hideElement("OBJECT");
//	hideElement("IFRAME");

}

function hidemenu(){
	window.clearTimeout(tid1);
	menulayer.style.visibility='hidden';
	showElement("APPLET");
	showElement("SELECT");
	showElement("OBJECT");
//	showElement("IFRAME");
}

function checkclick(){
	if (window.event.srcElement.id.substr(0,2)!='td') {
		if (typeof(oldmenu)=='object') { hidemenu();menuopen=false;}
	} 
	else 
	{}
}

function checkkeypress(){
	if (window.event.keyCode==27) { hidemenu();menuopen=false;}
}


function checktherainbow(){
	if (!mouseovertherainbow){
		hidemenu();
		menuopen=false;
		} else {tid=window.setTimeout("checktherainbow()", 1000);}
}


function hideElement(elmID)
{
	x=menulayer.style.left;
	y=menulayer.style.top;
	for (i = 0; i < document.all.tags(elmID).length; i++)
	{
		obj = document.all.tags(elmID)[i];
		if (! obj || ! obj.offsetParent)
			continue;

		objLeft   = obj.offsetLeft;
		objTop    = obj.offsetTop;
		objParent = obj.offsetParent;
		while (objParent.tagName.toUpperCase() != "BODY")
		{
			objLeft  += objParent.offsetLeft;
			objTop   += objParent.offsetTop;
			objParent = objParent.offsetParent;
		}
//alert (objLeft+'  '+menulayer.style.left);
		objTop = objTop - y;

		if (x > (objLeft + obj.offsetWidth) || objLeft > (x + menulayer.offsetWidth))
			;
		else if (objTop > menulayer.offsetHeight)
			;
		else if ((y + menulayer.offsetHeight) <= 80)
			;
		else
			obj.style.visibility = "hidden";
	}
}

function showElement(elmID)
{
	for (i = 0; i < document.all.tags(elmID).length; i++)
	{
		obj = document.all.tags(elmID)[i];
		if (! obj || ! obj.offsetParent)
			continue;
		obj.style.visibility = "";
	}
}

function ofn() //onmoseover function for menu heads.
{
	mouseovertherainbow=false;
	window.clearTimeout(tid1);
}

function mniov(lzobj) // onmoseover function for menu items
{
	lzobj.style.backgroundColor='#B6BDD2';
	lzobj.style.color='#FFFFFF';
}

function mniou(lzobj) // onmoseout function for menu items
{
lzobj.style.backgroundColor='';
lzobj.style.color='';
}

function mnj2(lzaddr){
document.location=lzaddr;
}