var subcatMas = {}


function getSubElements()
{
        var elemsopen = getElementsByClass('hideIt')
        for(i=0;i<elemsopen.length;i++)
        {
                subcatMas[elemsopen[i].id] = {}
                subcatMas[elemsopen[i].id][0] = "closed"
                subcatMas[elemsopen[i].id][1] = 0

        }
}

function getElementsByClass(searchClass,node,tag)
{
    var classElements = new Array();
    if ( node == null )
        node = document
    if ( tag == null )
        tag = '*'
    var els = node.getElementsByTagName(tag)
    var elsLen = els.length
    var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
    for (i = 0, j = 0; i < elsLen; i++)
    {
        if ( pattern.test(els[i].className) )
        {
            classElements[j] = els[i]
            j++
        }
    }
    return classElements;
}


function hiddenopen(id,close)
{
        if(close=='open')
        {
                for(el in subcatMas)
                {
                    window.clearTimeout(subcatMas[el][2]);
                }
                if(subcatMas[id][0] == "closing")
                {
                        subcatMas[id][0] = "open"
                }
                else
                {
                        closing()
                        document.getElementById(id).style.display = "";
                        subcatMas[id][0] = "open"
                }
        }

        if(close=='close')
        {
                subcatMas[id][2]= setTimeout(closing,400)
        }
}

function closing()
{
        for(el in subcatMas)
        {
                            document.getElementById(el).style.display = "none";
                            subcatMas[el][0] = "closed"
        }
}


var subcatMasH = {}


function getSubElementsH()
{
        var elemsopen = getElementsByClass('horiz hideItHorizontal')
        for(i=0;i<elemsopen.length;i++)
        {
                subcatMasH[elemsopen[i].id] = {}
                subcatMasH[elemsopen[i].id][0] = "closed"
                subcatMasH[elemsopen[i].id][1] = 0

        }
}


function hiddenopenH(id,close)
{
		if(close=='open')
        {
                for(el in subcatMasH)
                {
                    window.clearTimeout(subcatMasH[el][2]);
                }
                if(subcatMasH[id][0] == "closing")
                {
                        subcatMasH[id][0] = "open"
                }
                else
                {
                        closingH()
                        document.getElementById(id).style.display = "";
                        subcatMasH[id][0] = "open"
                }
        }

        if(close=='close')
        {
        	subcatMasH[id][2]= setTimeout(closingH,400)
        }
}

function closingH()
{
        for(el in subcatMasH)
        {
                            document.getElementById(el).style.display = "none";
                            subcatMasH[el][0] = "closed"
        }
}