// -----------------------------
// Отображаем с такими координатами.
// -----------------------------

function ShowLayer(lName, x, y, Showing)
{

var skin;

if(lName=='') return;

skin=document.getElementById(lName);

if(skin==null) return;

skin.style.left = x;
skin.style.top  = y;

skin.style.zIndex=2000;
if(Showing) 
    {
    skin.style.visibility="visible"; 
    skin.style.display="block"; 
    }
    else 
    {
    skin.style.visibility="hidden";
    skin.style.display="none"; 
    }

}


// -----------------------------
// Переход на URL
// -----------------------------

function GotoUrl(Url)
{

location.href = Url;

}


// -----------------------------
// Прячем слой.
// -----------------------------

function HideLayer(lName)
{

var skin;

if(lName=='') return;

skin=document.getElementById(lName);

if(skin==null) return;

//skin.style.zIndex=2;
skin.style.visibility="hidden";

}


// -----------------------------
// Загружаем слой
// -----------------------------

function LoadLayer(lName, LoadFrom)
{

var link = LoadFrom + "&rand=" + Math.random();
var old_s = document.getElementById('dataloader');
if (old_s)
    {
    old_s.parentNode.removeChild(old_s);            
    }

var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.src = link;
s.id = 'dataloader';
document.getElementsByTagName('head')[0].appendChild(s);        
}


// open new window
function OpenNewWindow(href, text, width, height)
{
if(text)
    {
    if(confirm(text))
        {
        return window.open(href, '', 'width=' + width + ',height=' + height + ',scrollbars');
        }
    else
        {
        return false;
        }
    }
else
    {
    return window.open(href, '', 'width=' + width + ',height=' + height + ',scrollbars,resizable=1');
    }
}

// open new window
function OpenNewWindowByName(href, text, width, height, name)
{
if(text)
    {
    if(confirm(text))
        {
    return window.open(href, name, 'width=' + width + ',height=' + height + ',scrollbars');
        }
    else
        {
        return false;
        }
    }
else
    {
    return window.open(href, name, 'width=' + width + ',height=' + height + ',scrollbars');
    }
}

// ------------------------------------------
// Resize window
// ------------------------------------------


function ResizeWindow(w,h) 
    {
    if (parseInt(navigator.appVersion)>3) 
        {
        if (navigator.appName=='Netscape') 
            {
            top.outerWidth=w+50;
            top.outerHeight=h+120;
            }
            else 
            {
            top.resizeTo(w+50,h+120);
            }
        }
    }


//--------------------------------
//  show|hide element
//--------------------------------
function z(id)
{
var element;
if(document.getElementById(id) == null)
    {
    if(id.style == null)
        {
        return;
        }
    else
        {
        element = id;
        }
    }
else
    {
    element = document.getElementById(id);
    }

if(element.style.display=='block')
    {
    element.style.display='none';
    }
else
    {
    element.style.display='block';
    }
}

//--------------------------------
//  show|hide element in class
//--------------------------------
function zx(id)
{
var element;
if(document.getElementById(id) == null)
    {
    if(id.className == null)
        {
        return;
        }
    else
        {
        element = id;
        }
    }
else
    {
    element = document.getElementById(id);
    }

if(element.className=='hide')
    {
    element.className='show';
    }
else
    {
    element.className='hide';
    }
}


/**
 * Checks/unchecks all tables
 *
 * @param   string   the form name
 * @param   boolean  whether to check or to uncheck the element
 *
 * @return  boolean  always true
 */
function setCheckboxes(the_form, do_check, formname)
{
    var elts      = (typeof(document.forms[the_form].elements[formname]) != 'undefined')
                  ? document.forms[the_form].elements[formname]: 0;
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        } // end for
    } else {
        elts.checked        = do_check;
    } // end if... else

    return true;
} // end of the 'setCheckboxes()' function


//-------------------------------------
// Open new window with some image 
//----------------------------------
function OpenImg(id, width, height, name)
{
var PopupWin = window.open('', 'galery', 'width='+width+',height='+height+',tytlebar,top='+(320-(height/2))+',left='+(540-(width/2))+'');

PopupWin.focus();
PopupWin.window.document.writeln('<head><title>'+name+'</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link rel="stylesheet" href="css/styles.css" type="text/css" /><link type="text/css" href="/css/common.css" rel="stylesheet"></head><body><table width=100% height=100% border=0 cellspacing=0 cellpadding=0><tr><td align=center valign=middle><div class=menudeactive style="text-align: center;">'+name+'</div><img src='+id+' alt="'+name+'"/></td></tr></table></body></html>');
}