/**
 * Общий файл для скриптов сайта
 */

 /* Реализация замены getElementById */
function $() {
  var results = [], element;
  for (var i = 0; i < arguments.length; i++) {
    element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
      results.push(element);
  }
  return results[0];
}

 /* Насколько просколили окно */
function getyScroll()
 {
  yScroll = 0;

  if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX)
   {
    yScroll = window.innerHeight + window.scrollMaxY;
    xScroll = window.innerWidth + window.scrollMaxX;

    var deff = document.documentElement;
    var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
    var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;

    xScroll -= (window.innerWidth - wff);
    yScroll -= (window.innerHeight - hff);
   } 
  else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth)
   { // all but Explorer Mac
    yScroll = document.body.scrollHeight;
    xScroll = document.body.scrollWidth;
   } 
  else 
   { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    yScroll = document.body.offsetHeight;
    xScroll = document.body.offsetWidth;
   }

  return yScroll;
 }

/* Отображаем всплывающее */
function showPopupForm(block) {
  $(block).style.display = 'block';
  $('screen').style.opacity = '0.4';
  $('screen').style.filter = 'alpha(opacity=40)';
  $('screen').style.display = 'block';
  $('screen').style.height = getyScroll() + 'px'; //window.innerHeight + window.scrollMaxY;

  $(block).style.top = (document.body.offsetHeight - block.offsetHeight)/2 +'px';
  $(block).style.left = (window.innerWidth - 760)/2 +'px';

  $('screen').setAttribute('onclick', 'hidePopupForm("'+block+'")');
}

/* Прячем окно логина */
function hidePopupForm(block) {
  $(block).style.display = 'none';
  $('screen').style.display = 'none';
}
