 
var timeOn = null;

var offsetleft = -3;
var offsettop = 2;
var delay = 400;
var tempbgcolor;
var lastitem;
var allitems = new Array();

// MENU MOUSE OVER 
function menuOver(id, parent, subid) 
{		
    
	var bParent = true;
	
	if (lastitem != parent)
	{
		//alert(lastitem);
		if (lastitem)
		{
			// changeObjectVisibility(lastitem, 'none');
            getStyleObject(lastitem).display = 'none';
			hideFixMSIE(lastitem);
		}
        hideAllTo(parent);
		//hide(lastitem);
		if (parent == 'undefined')
		{
			bParent = false;
			hideAllMenus();
		}
	}           
	
	if(subid)                                   
	{                                                   
		displaySubmenu(id, subid, bParent);               
		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, bParent)
{          
    arParentPos = getTopLeft(eParent, false);                                
	if(bParent)
	{
		var x = arParentPos[1] + getElementWidth(eParent);    
		var y = arParentPos[0] + 2;		     
	}
	else
	{
		var x = arParentPos[1] + offsetleft;
		var y = arParentPos[0] + getElementHeight(eParent) + offsettop;
	}
	                                         
	// changeObjectVisibility(subid, 'block');
    getStyleObject(subid).display = 'block'; 
	moveXY(subid, x, y); 

    getObject(subid).style.zIndex = 501;

    resizeFixMSIE(subid);  
}


function hideAllMenus()
{
	for (i=0; i<allitems.length; i++)
	{
        getObject(allitems[i]).style.zIndex = 500;
		// changeObjectVisibility(allitems[i], 'none');
        getStyleObject(allitems[i]).display = 'none';
        hideFixMSIE(allitems[i]); 
	}
    allitems = new Array();
}

function hideAllTo(id)
{
    bVisible = true;
	for (i=0; i<allitems.length; i++)
	{
        if(allitems[i] == id)
        {
            bVisible = false;
            continue;
        }
        if(!bVisible)
        {
            getObject(allitems[i]).style.zIndex = 500;
		    // changeObjectVisibility(allitems[i], 'none');
            getStyleObject(allitems[i]).display = 'none';
            hideFixMSIE(allitems[i]); 
        }
	}
}
 

/* 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;
    }
}