function MenuOnClick(){
	if(this.OnClickFunction){
		if(this.OnClickFunction(this)==false) return;
	}
    if(this.SubMenu){
        this.SubMenu.EffectInstance.Execute();
    }
}

function MenuSetById(id,effect_in,effect_out,style,onclick_func,isactive_func){
    var parent = document.getElementById(id);
    if(!parent) return;
    MenuSetByElement(parent,effect_in,effect_out,style,onclick_func,isactive_func);
}

function MenuIsActive(elm){
    if(elm.className=="Active"){
        return true;
    }
    return false;
}

function MenuSetByElement(element,effect_in,effect_out,style,onclick_func,isactive_func,pareffect){
    var node = element.firstChild;
    if(!isactive_func) isactive_func = MenuIsActive;
    while(node){
        if(node.nodeName=="A"){
            node.OnClickFunction = onclick_func;
            if(style){
            	for(attr in style){
            	    node.style[attr] = style[attr];
            	}
            }
            AddElementEventFunction(node,"onclick",MenuOnClick);
            node.SubMenu = null;
            var next = node.nextSibling;
            while(next && (next.nodeName!="A" && next.nodeName!="DIV")){
                if(next) next = next.nextSibling;
            }
            if(next){
                if(next.nodeName=="DIV"){
                    next.ParentElement = node;
                    node.SubMenu = next;
                    AddEffectElement(next);
                    if(effect_in!=undefined) next.EffectInstance.EffectIn = effect_in;
                    if(effect_out!=undefined) next.EffectInstance.EffectOut = effect_out;
                    next.EffectInstance.ParentEffect = pareffect;
                    MenuSetByElement(next.firstChild,effect_in,effect_out,style,onclick_func,isactive_func,next.EffectInstance);
                }
            }
        }
        if(isactive_func){
            if(isactive_func(node)==true){
                var i = true;
				if(node.OnClickFunction){
					 i = node.OnClickFunction(node);
				}
			    if(i==true && node.SubMenu){
			        node.SubMenu.EffectInstance.Open();
			    }
            }
        }
        node = node.nextSibling;
    }
}