/*
Массивы
*/
if (!Array.prototype.map)
{
  Array.prototype.map = function(fun /*, thisp*/)
  {
    var len = this.length >>> 0;
    if (typeof fun != "function")
      throw new TypeError();

    var res = new Array(len);
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        res[i] = fun.call(thisp, this[i], i, this);
    }

    return res;
  };
}


/*
Cookie
*/
function GetCookie (name)
  {
  var arg  = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i    = 0;
  while (i < clen)
    {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
    }
  return null;
  }
  
function getCookieVal (offset)
  {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
  }
  
function SetCookie (name, value)
  {
  var argv    = SetCookie.arguments;
  var argc    = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null; if (expires == Infinity) expires = new Date (new Date ().getTime () + 1000 * 60 * 60 * 24 * 365 * 100);
  var path    = (argc > 3) ? argv[3] : null;
  var domain  = (argc > 4) ? argv[4] : null;
  var secure  = (argc > 5) ? argv[5] : false;
  document.cookie =
    name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
    //"; expires=Sat, 19 Nov 3005 17:23:22 UTC" + 
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
  }
  
function DeleteCookie (name)
  {
  var exp  = new Date();
  var cval = GetCookie (name);
  exp.setTime (exp.getTime() - 1);  // This cookie is history
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  }
  
/*
Браузеры
*/
navigator.isIE = function ()
  {
  return (navigator.userAgent.search('MSIE') != -1);
  }
navigator.isOpera = function ()
  {
  return (navigator.userAgent.search('Opera') != -1);
  }
navigator.getOperaVersion = function ()
  {
  var isOpera = /Opera[\/\s](\d+\.\d+)/.test (navigator.userAgent)
  if (!isOpera)
    return (-1);
  else
    return (new Number(RegExp.$1));
  }

function onDomReady (i)
  {
  var e = /*@cc_on!@*/false; //!!!!!!!!!!!!
  if (/webkit/i.test(navigator.userAgent))
    {
    setTimeout (function()
      {
      if (document.readyState == "loaded" || document.readyState == "complete")
        {
        i ()
        }
      else
        {
        setTimeout (arguments.callee, 10);
        }
      }, 10);
    }
  else if ((/mozilla/i.test(navigator.userAgent)&&!/(compati)/.test(navigator.userAgent)) || (/opera/i.test(navigator.userAgent)))
    {
    document.addEventListener ("DOMContentLoaded", i, false);
    }
  else if (e)
    {
    (function()
      {
      var t = document.createElement('div');
      try
        {
        t.doScroll ('left');
        //alert ("!!!");
        try {i (); } catch (e) {}
        t = null;
        }
      catch(e)
        {
        setTimeout (arguments.callee, 0);
        }
     })();
    }
  else
    {
    //alert ("!");
    window.onload = i;
    }
  }
  
/*
function onDomReady (handler)
  {
  if (window.addEventListener)
    {
    window.addEventListener('DOMContentLoaded', handler, false);
    window.addEventListener('load', handler, false);
    }
  else if (window.attachEvent)
    window.attachEvent('onload', handler);
  else
    window.onload = handler;
  }
*/

//onDomReady (function () {alert ("!");})

function getCompStyle (elElement)
  {
  if (document.defaultView)
    return (document.defaultView.getComputedStyle(elElement, ""));
  else if (elElement.currentStyle)  
    return (elElement.currentStyle);
  }