 
var timeOn = null;

var offsetleft = 0;
var offsettop = 0;
var delay = 400;
var tempbgcolor;
var lastitem;
var allitems = new Array();

// MENU MOUSE OVER 
function menuOver(id, parent, subid) 
{	
	if (lastitem != parent)
	{
		//alert(lastitem);
		if (lastitem)
		{
			changeObjectVisibility(lastitem, 'none');
		}
		//hide(lastitem);
		if (parent == 'undefined')
		{
			hideAllMenus();
		}
	}
	
	if(subid)                                   
	{
		displaySubmenu(id,subid);
		if(allitems.indexOf(subid) === -1)
		{
			allitems.push(subid);
		}
		lastitem = subid;
	}
	clearTimeout(timeOn);
}

// MENU MOUSE OUT 
function menuOut(eDiv) 
{
 	timeOn = setTimeout("hideAllMenus()", delay);
}       
 
function displaySubmenu(eParent,subid)
{
	 
    var x = getElementLeft(eParent) + offsetleft;
	var y = getElementTop(eParent) + getElementHeight(eParent) + offsettop;
	moveXY(subid, x, y); 

    getObject(subid).style.zIndex = 501;

	changeObjectVisibility(subid, 'block');
    /* 
    if(MSIE)
	{
        resizeFixMSIE(subid);
    } */  
}


function hideAllMenus()
{
    hideFixMSIE();  
	for (i=0; i<allitems.length; i++)
	{
        getObject(allitems[i]).style.zIndex = 500;
		changeObjectVisibility(allitems[i], 'none');
	}
}
 

/* Finds the index of the first occurence of item in the array, or -1 if not found */
if (typeof Array.prototype.indexOf == "undefined") {
    Array.prototype.indexOf = function(item) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] === item) {
                return i;
            }
        }
        return -1;
    }
}
