
var myT;

function cleanColumns(rightcolId)
{
    nodes = $('contentleft').childNodes;
    var i = nodes.length; while(i-->0)
    {
        if(nodes[i].nodeType == 3 || nodes[i].tagName != 'DIV')
        {
            if (nodes[i].nodeType == 1)
            {
                console.log(nodes[i].tagName)
                //console.log('Type: ' + nodes[i].nodeType + ' / ' + nodes[i].nodeValue)
            }
            nodes[i].parentNode.removeChild(nodes[i]);
        }
    }
    if (rightcolId == undefined) rightcolId = 'contentright'

    nodes = $(rightcolId).childNodes;
    var i = nodes.length; while(i-->0)
    {
        if(nodes[i].nodeType == 3 || nodes[i].tagName != 'DIV')
        {
            nodes[i].parentNode.removeChild(nodes[i]);
        }
    }
}

function initMenu()
{
    //$('search_button_id').addEvent('click', openAdvanced);
    //$('searchcontext_id').addEvent('click', function(){if (this.value == 'Search') this.value='';});
    //$('advsearch_close_id').addEvent('click', function(){$('advsrch').setStyle('visibility', 'hidden')});


    $S('#menubar td.menucell').each(function(el)
    {
        el.addEvent('mouseover', cleartimeout)
        el.addEvent('mouseover', showmenu)
        el.addEvent('mouseout', settimeout)
    })

    $S('#submenucontainer div.sub').each(function(el)
    {
        el.addEvent('mouseover', cleartimeout)
        el.addEvent('mouseout', settimeout)
    })

    $S('#menuitemscontainer tr.mrow').each(function(el)
    {
        el.addEvent('mouseover', cleartimeout)
        el.addEvent('mouseover', function(el){this.setStyle('background-color', '#dbeece')})
        el.addEvent('mouseover', submenu)
        el.addEvent('mouseout', settimeout)
        el.addEvent('mouseout', function(el){this.setStyle('background-color', 'transparent')})
    })
}

function showmenu()
{
    hideall()
    if (this.id=='m1') return;
    mx = this.getPosition().left + 20
    if (this.id=='m1') mx = mx - 4;
    
    my = this.getPosition().bottom + 3
    $(this.id+'i').setStyles({display: 'block', top: my+'px', left: mx+'px'})
}

function hideall()
{
    hidesub();
    var c = 2;
    while(c<3)
    {
        tmp = 'm' + c + 'i'
        c++
        document.getElementById(tmp).style.display = 'none';
    }
}

function hidesub(big)
{
    if (!big)
    {
        $S('#submenucontainer div.sub').each(function(el){el.setStyle('display', 'none');})
    } else {
        big.setStyle('display', 'none')
    }
}

function settimeout()
{
    myT = hideall.delay(1000)
}

function cleartimeout()
{
    myT = $clear(myT)
}

function submenu()
{
    hidesub();
    triangle = 't' + this.id
    if($(triangle))
    {
        var offset = (this.id.test('_0')) ? 20 : 19
        subname = 's' + this.id
        x = $(triangle).getPosition().right + 6
        y = $(triangle).getPosition().bottom - offset
        $(subname).setStyles({left: x+'px', top: y+'px', display: 'block'});
    }
}



sfHover = function() {
    var sfEls = document.getElementById("share");
    if (sfEls) {
        sfEls.onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls.onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
