var aix = 0;
var aid = "";
var bid = "";

function sub_on(id) {
    var obj = document.getElementById(id);
    if (!obj) return;

    if ("sub_selected_fixed" != obj.className) obj.className = "sub_selected";
    
    obj = document.getElementById(id + 'menu');
    if (obj) {
        obj.style.display = "block";
        if (obj.offsetWidth < obj.parentNode.offsetWidth) {
            obj.style.width = obj.parentNode.offsetWidth + "px";
        }
    }
}

function sub_on_one(id) {
    sub_off_all();
    sub_on(id);
}


function sub_off(id) {
    var obj = document.getElementById(id);
    if (!obj) return;

    if ("sub_selected_fixed" != obj.className) obj.className = "sub";
    
    obj = document.getElementById(id + 'menu');
    if (obj) obj.style.display = "none";
}

function sub_off_all() {
    for (i = 1; i <= maxmenu; i++) sub_off("sub" + i);
}

function sub_menu_off() {
    if (bid) sub_off(bid);
}

function set_timer(id) {
    if (aix) clear_timer();
    aid = id + 'menu';
    bid = id;
    aix = window.setTimeout("sub_menu_off()", 200);
}

function clear_timer() {
    window.clearTimeout(aix);
    aix = 0;
    aid = "";
    bid = "";
}
