var mt;
function selectTab(id, aid, path){
    clearTimeout(mt);

    for(i = 1; i < 11; i++){

        if(i != id){
            if(document.getElementById("menu-" + i))
                document.getElementById("menu-" + i).style.visibility = 'hidden';

            if(document.getElementById('menuBorderBottom' + i))
                document.getElementById('menuBorderBottom' + i).style.visibility = 'hidden';

            if(document.getElementById('menuBorderCornerRight' + i))
                document.getElementById('menuBorderCornerRight' + i).style.visibility = 'hidden';

            if(document.getElementById('menuBorderRight' + i))
                document.getElementById('menuBorderRight' + i).style.visibility = 'hidden';

            if(i != aid){

                if(document.getElementById('tab-menu-' + i))
                    document.getElementById('tab-menu-' + i).src = path + "but-grey-" + i + ".png";
            }
        }
    }

    if(id != aid)
        document.getElementById('tab-menu-' + id).src = path + "but-glow-" + id + ".png";

    mt = setTimeout("openMenu('" + id + "')", 500);
}

function openMenu(id){

    if(document.getElementById("menu-" + id)){
        document.getElementById("menu-" + id).style.visibility = 'visible';

        if(document.getElementById('menuBorderBottom' + id))
            document.getElementById('menuBorderBottom' + id).style.visibility = 'visible';

        if(document.getElementById('menuBorderCornerRight' + id))
            document.getElementById('menuBorderCornerRight' + id).style.visibility = 'visible';

        if(document.getElementById('menuBorderRight' + id))
        document.getElementById('menuBorderRight' + id).style.visibility = 'visible';
    }
}

function deselectTab(id, aid, path){
    clearTimeout(mt);

    mt = setTimeout("closeMenu('" + id + "', '" + aid + "', '" + path + "')", 375);
}

function closeMenu(id, aid, path){

    if(id != aid)
        document.getElementById('tab-menu-' + id).src = path + "but-grey-" + id + ".png";

    if(document.getElementById("menu-" + id))
        fadeOutMenu(100, id, id, 10);
}

function fadeOutMenu(opacity, id, cid, ms) {
    var object = document.getElementById('menu-' + id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";

    if(opacity > 0){
        setTimeout("fadeOutMenu(" + (opacity-5) + ",'" + id + "', '" + cid + "', " + ms + ")", ms);

        if(opacity == 50){
            if(document.getElementById('menuBorderBottom' + id))
                document.getElementById('menuBorderBottom' + id).style.visibility = 'hidden';

            if(document.getElementById('menuBorderCornerRight' + id))
                document.getElementById('menuBorderCornerRight' + id).style.visibility = 'hidden';

            if(document.getElementById('menuBorderRight' + id))
                document.getElementById('menuBorderRight' + id).style.visibility = 'hidden';
        }
    }else{
        if(document.getElementById('menu-' + id))
            document.getElementById('menu-' + id).style.visibility = 'hidden';

        object.opacity = 1.0;
        object.MozOpacity = 1.0;
        object.KhtmlOpacity = 1.0;
        object.filter = "alpha(opacity=100)";
    }
}

function showTcTab(path){
    document.getElementById('tc').src = path + "tc-green.png";
}

function hideTcTab(path){
    document.getElementById('tc').src = path + "tc-grey.png";
}

function showHomeTab(path){
    document.getElementById('home').src = path + "but-home-glow.png";
}

function hideHomeTab(path){
    document.getElementById('home').src = path + "but-home-grey.png";
}

