var _heightMax = 230;
var heightMax = 0;
var height = 12;
var speed = 10;
var timer = 50;
var efectGlobal = ""
var currentHeight = 0;
var isShowAll = false;
var isActive = false;
var isFocus = false;
var isFirst = true;
function ShowMenu(strID,efect)
{
    var strDivID = "";
    efectGlobal = efect;
    if(efect == "show" && !isActive)
    {
        if(strID.length != 0)
        {
            var objControl = document.getElementById("hControlMenu")
            var objShow = document.getElementById(strID);
            objShow.style.display = "block";
            objShow.style.visibility = "visible";
            objShow.style.height ='0px';
            strDivID = strID.replace(gMenuID_,"");
            var divCh = document.getElementById(strDivID);
            divCh.style.top = 0 - divCh.offsetHeight + 'px';
            heightMax = divCh.offsetHeight;
            if(_heightMax>heightMax) heightMax = _heightMax;
            setTimeout("objectGrow(" + speed + ",'" + strID +"')",timer);
            if(strID != objControl.value)
            {
                HideMenu(efect);
                objControl.value = strID;
            }

            isActive = true;
            isFocus = true;
            if(isFirst)
                initChild();
            resetTimer();
        }
    }
    else if(efect == "showAll" && !isShowAll && !isActive)
    {
        var divs = document.getElementsByTagName("DIV");
        var intMayorH = 0;
        for(var no=0;no<divs.length;no++)
        {
            strDivID = divs[no].id;
            div = divs[no];
            if(strDivID.indexOf(gMenuID_)!= -1)
            {
                div.style.display = "block";
                div.style.visibility = "visible";
                div.style.height ='0px';
                strDivID = strDivID.replace(gMenuID_,"");
                var divCh = document.getElementById(strDivID);
                divCh.style.top = 0 - divCh.offsetHeight + 'px';
                if (intMayorH < divCh.offsetHeight)
                    intMayorH = divCh.offsetHeight;
            }
        }
        isActive = true;
        isFocus = true;
        heightMax = intMayorH;
        if(_heightMax>heightMax) heightMax = _heightMax;
        if(isFirst)
            initChild();
        //slideContent(1,1)
        setTimeout("objectGrowAll("+ speed +")",timer);
        resetTimer();
    }
}
function objectGrow(fast,strID)
{
    var obj = document.getElementById(strID);
    var continueFun = true;
    if(currentHeight > heightMax)
        continueFun = false
    if(continueFun)
    {
			obj.style.height = (parseInt(obj.style.height,10) + fast) +"px";
        currentHeight = currentHeight + fast;
        setTimeout("objectGrow("+ speed +",'"+ strID +"')",timer);
    }
    if(!continueFun)
    {
        isShowAll = true;
        isActive = false;
    }
}
function objectUnGrow(fast,strID)
{
    var obj = document.getElementById(strID);
    var localHeight = 0;
    var continueFun = true;
    if(currentHeight < 0)
        continueFun = false
    if(continueFun)
    {
        localHeight = (parseInt(obj.style.height,10) - fast)
        if (localHeight < 0) localHeight = 0;
        obj.style.height = localHeight +"px";
        currentHeight = currentHeight - fast;
        setTimeout("objectUnGrow("+ speed +",'"+ strID +"')",timer);
    }
    if(!continueFun)
    {
        obj.style.display = "none";
        obj.style.visibility = "hidden";
        isShowAll = false;
        isActive = false;
        currentHeight = 0;
    }
}
function objectGrowAll(fast)
{
    var objs = document.getElementsByTagName("DIV");
    var strDivID = "";
    var continueFun = true;
    if(currentHeight > heightMax)
        continueFun = false
    if(continueFun)
    {
        for(var no=0;no<objs.length;no++)
        {
            strDivID = objs[no].id;
            if(strDivID.indexOf(gMenuID_)!= -1)
            {
                objs[no].style.height = (parseInt(objs[no].style.height,10) + fast) +"px";
            }
        }
        currentHeight = currentHeight + fast;
        setTimeout("objectGrowAll("+ speed +")",timer);
    }
    if(!continueFun)
    {
        isShowAll = true;
        isActive = false;
    }
}
function objectUnGrowAll(fast)
{
    var objs = document.getElementsByTagName("DIV");
    var strDivID = "";
    var continueFun = true;
    var localHeight = 0;
    if(currentHeight < 0)
        continueFun = false;
    if(continueFun)
    {
        for(var no=0;no<objs.length;no++)
        {
            strDivID = objs[no].id;
            if(strDivID.indexOf(gMenuID_)!= -1)
            {
                localHeight = (parseInt(objs[no].style.height,10) - fast)
                if (localHeight < 0) localHeight = 0;
                objs[no].style.height = localHeight + "px";
            }
        }
        currentHeight = currentHeight - fast;
        setTimeout("objectUnGrowAll("+ speed +")",timer);
    }
    else if(!continueFun)
    {
        for(var no=0;no<objs.length;no++)
        {
            strDivID = objs[no].id;
            if(strDivID.indexOf(gMenuID_)!= -1)
            {
                objs[no].style.display = "none";
                objs[no].style.visibility = "hidden";
            }
        }
        isShowAll = false;
        isActive = false;
        currentHeight = 0;
    }
}
function HideMenu(efect)
{
    if (efect == "show" && isShowAll && !isActive && !isFocus)
    {
        var objControl = document.getElementById("hControlMenu")
        if(objControl != null)
        {
            var strID = objControl.value
            if(strID.length != 0)
            {
                isActive = true;
                setTimeout("objectUnGrow("+ speed +",'"+ strID +"')",timer);
            }
        }
        stopTimer();
    }
    else if(efect == "showAll" && isShowAll && !isActive && !isFocus)
    {
        isActive = true;
        setTimeout("objectUnGrowAll("+ speed +")",timer);
        stopTimer();
    }
}
function stopTimer()
{
    var objTime = document.getElementById("hControlTime");
    var intervalID = objTime.value;
    if(intervalID.length != 0 )
        clearInterval(intervalID);
}
function resetTimer()
{
    var objTime = document.getElementById("hControlTime");
    var intervalID = objTime.value;
    if(intervalID.length != 0 )
        clearInterval(intervalID);
    objTime.value = setInterval("HideMenu('"+ efectGlobal +"')",500);
}
function initChild()
{
    var obj = document.getElementById(gMenuID);
    obj.onmouseout = function(){isFocus = false;};
    isAChild(obj);
    isFirst = true;
}
function isAChild(objChNode)
{
    var n=0;
    if(objChNode != null)
    {
        for (n=0;n<objChNode.childNodes.length;n++)
        {
           if(objChNode.childNodes[n].childNodes != null && objChNode.childNodes[n].nodeType == 1)
           {
                isAChild(objChNode[n]);
                objChNode.childNodes[n].onmouseover =  function(){isFocus = true;};
                objChNode.childNodes[n].onmouseout = function(){isFocus = false;};
           }
        }
    }
    return true;
}
function DoHover(source) { try { source.parentNode.className+=' hover'; } catch(er) {} }
function RestoreHover(source) { try { source.parentNode.className = source.parentNode.className.replace(/\bhover\b/,''); } catch(er) {}}
