function mahl(menuitem, e, bgc, ccst, ooo)
{
	if (!window.canbeclosed) canbeclosed = new Array();
	canbeclosed[menuitem.id] = ooo;
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();

	setTimeout(function () { mbg(menuitem, bgc, ccst, ooo) }, 20);
	if (ooo == 0) setTimeout(function () { msch(menuitem) }, 50);
	if (ooo == 1) setTimeout(function () { mhch(menuitem) }, 50);
}

function mbg(menuitem, color, colorc, hlstatus)
{
	if (canbeclosed[menuitem.id] != hlstatus) return '';

	var RGB_array = new Array();
	var RGB_array1 = menuitem.style.backgroundColor.RGBsplit();
	var RGB_array2 = color.RGBsplit();

	if (RGB_array1 == RGB_array2) return '';

	for (var i=1; i<=colorc; i++) {
		RGB_array[0] = parseInt(RGB_array1[0] + (RGB_array2[0] - RGB_array1[0]) / colorc * i);
		RGB_array[1] = parseInt(RGB_array1[1] + (RGB_array2[1] - RGB_array1[1]) / colorc * i);
		RGB_array[2] = parseInt(RGB_array1[2] + (RGB_array2[2] - RGB_array1[2]) / colorc * i);
		mbg2(menuitem, 'rgb(' + RGB_array.join() + ')', i*40, hlstatus);
	}
}

function mbg2(menuitem, nnnn, del, hlstatus)
{
	setTimeout(function () { mgbg(menuitem, nnnn, hlstatus) }, del);
}

function mgbg(menuitem, color, hlstatus)
{
	if (canbeclosed[menuitem.id] != hlstatus) return '';
	menuitem.style.backgroundColor=color;
}

String.prototype.RGBsplit = function()
{
var vals = this.replace(/\(|\)|[a-z]/gi,"").split(",");
for(var k=0;k<3;k++)
vals[k] = vals[k]/1;
return vals;
}

function msch(menuitem)
{
	var chcon = document.getElementById(menuitem.id+'_ch');
	if (chcon == null) return '';
	if (chcon.style.visibility == 'hidden') {
		chcon.style.visibility = 'visible';
		chcon.style.top = (parseInt(chcon.style.top)+1000)+'px';
	}
}

function mhch(menuitem)
{
	if (canbeclosed[menuitem.id] == 0) return '';
	var chcolbros = menuitem.parentNode.getElementsByTagName('div');
	var brocountnotclose = 0;
	var countnotclose = 0;

	var chcon = document.getElementById(menuitem.id+'_ch');
	if (chcon != null) {

		var chcol = chcon.getElementsByTagName("div");
		var countnotclose = 0;
		for (var i=0; i<chcol.length; i++) {
			if (canbeclosed[chcol[i].id] == 0) countnotclose++;
		}
		if (chcon.style.visibility == 'visible') if (countnotclose == 0) {
			chcon.style.visibility = 'hidden';
			chcon.style.top = (parseInt(chcon.style.top)-1000)+'px';
		}
	}
	
	if (countnotclose == 0) for (var i=0; i<chcolbros.length; i++) {
		if (canbeclosed[chcolbros[i].id] == 0) brocountnotclose++;
	}
	if (menuitem.parentNode.style.visibility == 'visible') if (brocountnotclose == 0) if (countnotclose == 0) {
		menuitem.parentNode.style.visibility = 'hidden';
		menuitem.parentNode.style.top = (parseInt(menuitem.parentNode.style.top)-1000)+'px';
		mhch(document.getElementById(menuitem.parentNode.id.substring(0,menuitem.parentNode.id.length-3)));
	}
}

function scrollMenu(maxTop)
{
	if (document.body.scrollTop > maxTop) document.getElementById('mglo').style.top=document.body.scrollTop;
	else document.getElementById('mglo').style.top = maxTop;
}

