function Menu_GetData(item) {
    if (!item.data) {
        var a = (item.tagName.toLowerCase() == "a" ? item : WebForm_GetElementByTagName(item, "a"));
        var menu = Menu_FindMenu(a);
        try {
            item.data = eval(menu.id + "_Data");
        }
        catch(e) {}
    }
    return item.data;
}
function Menu_HoverRoot(item) {
    var node = (item.tagName.toLowerCase() == "td") ?
        item:
        item.cells[0];
    var data = Menu_GetData(item);
    if (!data) {
        return null;
    }
    var nodeTable = WebForm_GetElementByTagName(node, "table");
    if (data.staticHoverClass) {
        nodeTable.hoverClass = data.staticHoverClass;
        WebForm_AppendToClassName(nodeTable, data.staticHoverClass);
    }
    node = nodeTable.rows[0].cells[0].childNodes[0];
    if (data.staticHoverHyperLinkClass) {
        node.hoverHyperLinkClass = data.staticHoverHyperLinkClass;
        WebForm_AppendToClassName(node, data.staticHoverHyperLinkClass);
    }
    return node;
}
function Menu_HoverStatic(item) {
    var node = Menu_HoverRoot(item);
    var data = Menu_GetData(item);
    if (!data) return;
    __disappearAfter = data.disappearAfter;
    Menu_Expand(node, data.horizontalOffset, data.verticalOffset); 
}























function Menu_Unhover(item) {
    var node = (item.tagName.toLowerCase() == "td") ?
        item:
        item.cells[0];
    var nodeTable = WebForm_GetElementByTagName(node, "table");
    if (nodeTable.hoverClass) {
        WebForm_RemoveClassName(nodeTable, nodeTable.hoverClass);
    }
    node = nodeTable.rows[0].cells[0].childNodes[0];
    if (node.hoverHyperLinkClass) {
        WebForm_RemoveClassName(node, node.hoverHyperLinkClass);
    }
    Menu_Collapse(node);
}

function Menu_Key(item) {
    var event;
    if (window.event) {
        event = window.event;
    }
    else {
        event = item;
        item = event.currentTarget;
    }
    var key = (event ? event.keyCode : -1);
    var data = Menu_GetData(item);
    if (!data) return;
    var horizontal = Menu_IsHorizontal(item);
    var a = WebForm_GetElementByTagName(item, "A");
    var nextItem, parentItem, previousItem;
    if ((!horizontal && key == 38) || (horizontal && key == 37)) {
        previousItem = Menu_FindPrevious(item);
        while (previousItem && previousItem.disabled) {
            previousItem = Menu_FindPrevious(previousItem);
        }
        if (previousItem) {
            Menu_Focus(previousItem);
            Menu_Expand(previousItem, data.horizontalOffset, data.verticalOffset, true);
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return;
        }
    }
    if ((!horizontal && key == 40) || (horizontal && key == 39)) {
        if (horizontal) {
            var subMenu = Menu_FindSubMenu(a);
            if (subMenu && subMenu.style && subMenu.style.visibility && 
                subMenu.style.visibility.toLowerCase() == "hidden") {
                Menu_Expand(a, data.horizontalOffset, data.verticalOffset, true);
                event.cancelBubble = true;
                if (event.stopPropagation) event.stopPropagation();
                return;
            }
        }
        nextItem = Menu_FindNext(item);
        while (nextItem && nextItem.disabled) {
            nextItem = Menu_FindNext(nextItem);
        }
        if (nextItem) {
            Menu_Focus(nextItem);
            Menu_Expand(nextItem, data.horizontalOffset, data.verticalOffset, true);
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return;
        }
    }
    if ((!horizontal && key == 39) || (horizontal && key == 40)) {
        var children = Menu_Expand(a, data.horizontalOffset, data.verticalOffset, true);
        if (children) {
            var firstChild;
            children = WebForm_GetElementsByTagName(children, "A");
            for (var i = 0; i < children.length; i++) {
                if (!children[i].disabled && Menu_IsSelectable(children[i])) {
                    firstChild = children[i];
                    break;
                }
            }
            if (firstChild) {
                Menu_Focus(firstChild);
                Menu_Expand(firstChild, data.horizontalOffset, data.verticalOffset, true);
                event.cancelBubble = true;
                if (event.stopPropagation) event.stopPropagation();
                return;
            }
        }
        else {
            parentItem = Menu_FindParentItem(item);
            while (parentItem && !Menu_IsHorizontal(parentItem)) {
                parentItem = Menu_FindParentItem(parentItem);
            }
            if (parentItem) {
                nextItem = Menu_FindNext(parentItem);
                while (nextItem && nextItem.disabled) {
                    nextItem = Menu_FindNext(nextItem);
                }
                if (nextItem) {
                    Menu_Focus(nextItem);
                    Menu_Expand(nextItem, data.horizontalOffset, data.verticalOffset, true);
                    event.cancelBubble = true;
                    if (event.stopPropagation) event.stopPropagation();
                    return;
                }
            }
        }
    }
    if ((!horizontal && key == 37) || (horizontal && key == 38)) {
        parentItem = Menu_FindParentItem(item);
        if (parentItem) {
            if (Menu_IsHorizontal(parentItem)) {
                previousItem = Menu_FindPrevious(parentItem);
                while (previousItem && previousItem.disabled) {
                    previousItem = Menu_FindPrevious(previousItem);
                }
                if (previousItem) {
                    Menu_Focus(previousItem);
                    Menu_Expand(previousItem, data.horizontalOffset, data.verticalOffset, true);
                    event.cancelBubble = true;
                    if (event.stopPropagation) event.stopPropagation();
                    return;
                }
            }
            var parentA = WebForm_GetElementByTagName(parentItem, "A");
            if (parentA) {
                Menu_Focus(parentA);
            }
            Menu_ResetSiblings(parentItem);
            event.cancelBubble = true;
            if (event.stopPropagation) event.stopPropagation();
            return;
        }
    }
    if (key == 27) {
        Menu_HideItems();
        event.cancelBubble = true;
        if (event.stopPropagation) event.stopPropagation();
        return;
    }
}







/*********************************************************************************************/
/************************FUNCIONES DE DESPLIEGUE HORIZNTAL******************/
/*********************************************************************************************/
var MOL=new Array(); 
function MO(e)	{
	if (!e)	var e=window.event;
	var S=e.srcElement;	 
	while (S.tagName!="TD")	 {	S=S.parentElement;	 }
	S.className="T";
}
function MU(e)	{
	if (!e)	var e=window.event;
	var S=e.srcElement;
	while (S.tagName!="TD")	 {	S=S.parentElement;	 }
	S.className="P";
}
function MO_D(e)	 {
	if (!e)	var e=window.event;
	var S=e.srcElement;
	while (S.tagName!="TD")	 {	S=S.parentElement;	 }
	S.className="X";
}

function MU_D(e)	{
	if (!e)	var e=window.event;
	var S=e.srcElement;
	while (S.tagName!="TD")	 {	S=S.parentElement;	 }
	S.className="W";
}
function MOD_D(e)	{
	if (!e)	var e=window.event;
	var S=e.srcElement;
	while (S.tagName!="TD")	 {	S=S.parentElement;	 }
	S.className="Y";
}

function MUD_D(e)	{
	if (!e)	var e=window.event;
	var S=e.srcElement;
	while (S.tagName!="TD")	 {	S=S.parentElement;	 }
	S.className="Y";
}
function getXY(Obj)	{
	for (var sumTop=0,sumLeft=0;Obj!=document.body;sumTop+=Obj.offsetTop,sumLeft+=Obj.offsetLeft, Obj=Obj.offsetParent);
		return {left:sumLeft,top:sumTop}
}
function ROP(ObjRef)	{
	var theObj=null;
	if (ObjRef)	{
		if (typeof ObjRef != 'object')	theObj=eval(ObjRef);
		else	 theObj=ObjRef;
		return theObj;
	}
	else	 return false;
}
function CM(callerObj)	{
	for (aIndex=0;aIndex < MOL.length; aIndex++)	{
		if ((callerObj) && (callerObj.name != MOL[aIndex].name))	 {	
			if (MOL[aIndex].showing)	{
				MOL[aIndex].TM();
				MOL[aIndex].SBS();
			}
		}
		else	 {
			if (MOL[aIndex].showing)	{
				MOL[aIndex].TM();
				MOL[aIndex].SBS();
			}
		}
	}
}
function MCH(e, srcObj, srcIsMenuDiv)	{
	var srcElem;
	if (!e)	var e=window.event;
	e.cancelBubble=true;
	if (srcObj)	{
		var pCurrMenuObj=ROP(srcObj); 
		if (!srcIsMenuDiv)
		pCurrMenuObj.divObj.onclick="MCH(event,"+srcObj+",true)";
		pCurrMenuObj.TM();
	}
	else	CM();
}

function MME(e, srcObj)	{
	try	{
		if (!e) 
		var e=window.event;
		var pCurrMenuObj=ROP(srcObj);
		if (!pCurrMenuObj.showing)	{
			if (e.type == 'mouseover')	pCurrMenuObj.SBS('on');
			else if ((e.type == 'mouseout') || (e.type == 'blur'))	pCurrMenuObj.SBS();
		}
	}
	catch(e){}
}
function SBS(wS)	{
	if (typeof this.refTDObj != "undefined")	{
		if (wS == 'on')	{
			if (this.bOn)	{
				if (typeof this.DdTDObj != "undefined")	this.DdTDObj.className=this.bOn;
				this.refTDObj.className=this.bOn;
			}
		}
		else 
			if (wS == 'clicked')	{
				if (this.bA)	{
					if (typeof this.DdTDObj != "undefined")	this.DdTDObj.className=this.bA;
					this.refTDObj.className=this.bA;
				}
			}
			else	{
				if (this.bOf)	{
					if (typeof this.DdTDObj != "undefined")	this.DdTDObj.className=this.bOf;
					this.refTDObj.className=this.bOf;
				}
			}
	}
}
function TM()	{
	if (!this.showing)	{
		var RelObjCords=getXY(this.refTDObj);
		if (this.Direction)	{
			this.divStyleObj.top = this.frmObj.style.top = RelObjCords.top + -this.divObj.offsetHeight;
			this.divStyleObj.left = this.frmObj.style.left = RelObjCords.left;
		}
		else	{
			this.divStyleObj.top = this.frmObj.style.top = RelObjCords.top + 18;
			this.divStyleObj.left = this.frmObj.style.left = RelObjCords.left;
		}
		this.frmObj.style.height=this.divObj.offsetHeight;
		this.frmObj.style.width=this.divObj.offsetWidth;
		var pCurrMenuObj=ROP(this);
		CM(this);
		this.SBS('clicked');
		this.divStyleObj.visibility = this.frmObj.style.visibility = this.strShow;
		this.showing=true;
	}
	else	{
		this.divStyleObj.visibility = this.frmObj.style.visibility = this.strHide;
		this.showing=false;
		this.SBS();
	}
}
function MenuObj(_A,_B,_C,_D,_E,_F,_G,_H,_I)	{
	this.name=_A;
	this.bOn=_E;
	this.bOf=_F;
	this.bA=_G;
	this.SBS=SBS;
	this.showing=false;
	this.TM=TM;
	document.onclick=MCH;
	this.Direction=_I;
	MOL[MOL.length]=this;
	this.divObj=eval('document.all.' + _B);
	this.divStyleObj=eval('document.all.' + _B + '.style');
	this.refTDObj=eval('document.all.' + _C);
	if (_D)	this.DdTDObj=eval('document.all.' +  _D);
	this.frmObj=eval('document.all.' +  _H);
	this.strShow='visible';
	this.strHide='hidden';
}




