
// Misc

function echo(str)
{
  document.write(str);
}

// Images

function PreloadImages()
{
  if (document.images)
  {
    var imgFiles = PreloadImages.arguments;
    var preloadArray = new Array(imgFiles.length);
    for (var i=0; i<imgFiles.length; i++)
    {
      preloadArray[i] = new Image;
      preloadArray[i].src = imgFiles[i];
    }
  }
}

// Elements

function element(id)
{
  if (document.getElementById) return document.getElementById(id);
  if (document.all) return document.all(id);
  if (document.layers) return document.layers(id);
}

// ToPageTop

function AttToPageTop()
{
  tpt = element('aToPageTop');
  if (tpt)
  {
    tpt.onmouseover = function() { window.status='Наверх страницы';return true; }
    tpt.onmouseout = function() { window.status='';return true; }
    tpt.onclick = function() { scroll(0,0);return false; }
  }
}

// Page Functions

function AddToFavorites()
{
  var Url = window.document.location;
  var Title = window.document.title;

  if (window.sidebar) // Firefox
  {
    window.sidebar.addPanel(Title, Url, "");
  }
  else if (window.external) // IE
  {
    window.external.AddFavorite(Url, Title);
  }
  else if (window.opera && window.print) // Opera
  {
    alert("Извините, ваш браузер не поддерживает автоматическое добавление в закладки. Нажмите 'Ctrl-D' или 'Ctrl-T' в Opera для добавления " + "\'" + Title + "\'");
  }
}

// Counters

function counter_li()
{
  echo ("<img src='http://counter.yadro.ru/hit?r" + escape(document.referrer) + ((typeof(screen)=="undefined")?"":";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth)) + ";u" + escape(document.URL) + ";" + Math.random() + "' width=1 height=1 alt=''>");
}

// Rekla

function gas()
{
  echo ('<script>google_ad_client = "pub-6773028262265173";google_ad_slot = "8706655065";google_ad_width = 728;google_ad_height = 90;<\/script><script src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><\/script>');
}

// Init

function PreloadMainPageImages()
{
  PreloadImages('/i/bkgnd.gif','/i/header.jpg','/i/delimit.png','/i/sims.gif','/i/topmenu.png','/i/submenu.png','/i/wordmenu.png');
}

function AttachEvents(elemId, statMsg, aHref)
{
  e = element(elemId);
  if (e)
  {
    e.onmouseover = function() { window.status=statMsg;return true; }
    e.onmouseout = function() { window.status='';return true; }
    if (aHref) e.href = aHref;
  }
}

function AttToHeadMenu()
{
  var v1 = 'ma'+'il'+'to:'+'ad'+'mi'+'n@'+'lo'+'ve'+'in'+'fo'+'.'+'r'+'u';
  var v2 = '?'+'su'+'bj'+'ec'+'t=';
  AttachEvents('aAddToFavor', 'Добавить текущую страницу в закладки', 'javascript:AddToFavorites()');
  AttachEvents('aPrint', 'Отобразить страницу в виде текста для печати');
  AttachEvents('aSiteMap', 'Посмотреть карту сайта');
  AttachEvents('aSendMail', 'Написать письмо администрации сайта', v1+v2+'Message from son.loveinfo.ru');
}

function js_init()
{
  PreloadMainPageImages();
  AttToHeadMenu();
  AttToPageTop();
}

