var winCol = new Date();
function wshow(url, width, height)
{
    if (!width) width = 640;
    if (!height) height = 480;
    window.open(url, (winCol++), 
                'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=' 
                + width + 
                ',height=' + height + 
                ',left=' + ((screen.width - width) / 2) + 
                ',top=' + ((screen.height - height) / 2));
    return false;
}
function __get(id)
{
    if (document.layers)
    {
        return document.layers[id];
    }
    if (document.getElementById)
    {
        return document.getElementById(id);
    }       
    if (document.all)
    {
        return document.all[id];
    }
}

function trim(str) {

    beg = 0;
    while (str.charAt(beg) == " ") { beg++; }
    end = str.length - 1;
    while (str.charAt(end) == " ") { end--; }

    if (beg <= end) { return str.substring(beg, end + 1); }
    else            { return ""; }
}
/*
 * Стиль объекта 
 * @param id
 */
function __get_style(id)
{   
    obj = __get(id);
    if (obj.style) return obj.style;
    return obj;
}

/*
 * Сворачивает меню
 *
 */
function clearVisible(id, position) 
{
    action = 'hidden';
    if (document.layers) 
    {
        action = 'hide';
    }
    c_obj = __get_style(id);
    c_obj.visibility = action;
    c_obj.height = '0px';
    cur_active_menu = 0; 
    if (position)
    {
        c_obj.position = 'absolute';
    }
    c_obj = __get(id);        
    if (c_obj.onHide) c_obj.onHide(id);
    c_obj.status = false;
}

/*
 * Разворачивает меню
 *
 */
function setVisible(id, position, needHiden) 
{
    if (!needHiden)
    {
        if ((cur_active_menu) && (cur_active_menu != id))
        {
            clearVisible(cur_active_menu, position);
        }
    }
    action = 'visible';
    if (document.layers) 
    {
        action = 'show';
    }    
    c_obj = __get_style(id);
    if (position)
    {
        c_obj.position = 'static';
    }
    c_obj.visibility = action;
    cur_active_menu = id;
    c_obj = __get(id);        
    c_obj.status = true;
    if (c_obj.onShow) c_obj.onShow(id);
    isMouseMove = true;
}
function isVisible(id) {

    vis = __get_style(id).visibility.charAt(0);
    if (vis == 'h') {
    
        return false;
    } else {
    
        return true;
    }
}
function changeVisible(id, position) {

    if (isVisible(id)) {

        clearVisible(id, position);
    } else {

        setVisible(id, position, true);        
    }
    cur_active_menu = false;
}


function cat_changeVisible(id, menu_name) {

    if (__get(id + "_item").style.display != "block") {

        __get(id + "_item").style.display = "block";
        __get(id + "_item_icon").src   = "./images/menu_item_minus.gif";
        __get(id + "_item_icon").title = 'Свернуть пункт меню "' + menu_name + '"';
        __get(id + "_link").title      = 'Свернуть пункт меню "' + menu_name + '"';
    } else {

        __get(id + "_item").style.display = "none";
        __get(id + "_item_icon").src   = "./images/menu_item_plus.gif";
        __get(id + "_item_icon").title = 'Раскрыть пункт меню "' + menu_name + '"';
        __get(id + "_link").title      = 'Раскрыть пункт меню "' + menu_name + '"';
    }
}