function getBounds(element)
{
    var left = element.offsetLeft;
    var top = element.offsetTop;
    for (var parent = element.offsetParent; parent; parent = parent.offsetParent)
    {
       left += parent.offsetLeft - parent.scrollLeft;
       top += parent.offsetTop - parent.scrollTop;
    }
    return {left: left, top: top, width: element.offsetWidth, height: element.offsetHeight};
}

function $(e_id)
{
    return document.getElementById(e_id);
}

function $$(tag)
{
    return document.createElement(tag);
}

function $_(elem)
{
    if (elem && elem.parentNode)
    {
        var p = elem.parentNode;
        p.removeChild(elem);
        delete(elem);
    }
}

function getClientWidth()
{
    var w = 0;
    if (document.body) w = Math.min(document.body.clientWidth, document.body.scrollWidth);
    return w;
}

function getClientHeight()
{
    var h = 0;
    if (self.innerHeight) h = self.innerHeight;
    else if (document.documentElement && document.documentElement.clientHeight) h = document.documentElement.clientHeight;
    else if (document.body) h = document.body.clientHeight;
    return h;
}

function showElem(id)
{
    $(id).style.display = 'block';
}

function hideElem(id)
{
    $(id).style.display = 'none';
}

function toggleElem(id)
{
    $(id).style.display = ($(id).style.display=='block' || $(id).style.display=='')?'none':'block';
    return ($(id).style.display == 'block');
}

function toggleMenu(id)
{    if (toggleElem(id)) setCoo(id,1); else remCoo(id);
}


var cCookie = false;
function initCoo()
{
  if (!cCookie) cCookie = new CCookie(1000);
}
function setCoo(name,val)
{
  initCoo();
  cCookie.set('vooncoo'+name,val,'/');
}
function remCoo(name)
{
  initCoo();
  cCookie.remove('vooncoo'+name);
}



var styleAjax = false;
var styleTM = false;

function chooseStyle(nologin)
{
    var s = getCurrentStyle() + 1;
    s = (s>7) ? 0 : s;
    nologin ? setCookStyle(s) : setStyle(s);
    return false;
}
function setStyle(s)
{
    $('style').href = 'css/style'+(s ? s : '')+'.css';
    styleTM = window.setTimeout(saveStyle,5000);
}
function setCookStyle(s)
{
    $('style').href = 'css/style'+(s ? s : '')+'.css';
    setCoo('style',s);
}
function saveStyle()
{
    var s = getCurrentStyle();
    if (oldStyle != s)
    {
        oldStyle = s;
        if (!styleAjax) styleAjax = new CAjax();
        styleAjax.req({'s':s},null,'ajax/style.php');
    }
}
function getCurrentStyle()
{
    var s = $('style').href.split('style');
    s = parseInt(s[1]);
    return (!s) ? 0 : s;
}
var oldStyle = getCurrentStyle();


function openMyScroll()
{
   var div = $('mycscroll');
   var lb = $('myclabel');
   if(div.style.overflow == 'auto')
   {
       div.style.overflow = '';
       div.style.height = null;
       lb.innerHTML = window.opera ? '' : 'свернуть';
   }
   else
   {
       div.style.overflow = 'auto';
        div.style.height = '200px';
        lb.innerHTML = 'раскрыть';
   }
   return false;
}

