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 changeBgBack(id){

    object = __get(id);
    object.bgColor = '#F0C63A';
}

function changeBg(id){

    object = __get(id);
    object.bgColor = '#FFFFFF';
}

var
    global_id = 1,
    cur_active_menu = false,
    isMouseMove = false,
    isTryClose = 0;

/*
 * Проблемы с менюшкой
 */
var except = false;

/*
 * Предварительная загрузка картинок
 * @param array
 *
 */
function preload(img)
{
    if (document.images) 
    {
        my_images = new Array();
        len = img.length;
        for (i = 0; i < len; i++)
        {
             my_images[i] = new Image(); 
             my_images[i].src = img[i];
        }
    }
}

/*
 * Стиль объекта 
 * @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 changeVisible(id, position)
{        
    vis = __get_style(id).visibility.charAt(0);
    if (vis == 'h')
    {
        setVisible(id, position, true);
    } else
    {
        clearVisible(id, position);        
    }
    cur_active_menu = false;
}
