// подавить сообщения браузера об ошибках Javascript
window.onerror = null;

// PNG-прозрачность в IE 5,5 - 6,5 Begin ---------------------------------------
 function fixPNG(element) {
    if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
      var src;
      if (element.tagName=='IMG') {
        if (/\.png$/.test(element.src)) {
          src = element.src;
          element.src = "artatom/img/blank.gif";
          element.width = element.width;
          element.height = element.height;
        };
      }
      else {
        src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
        if (src) {
          src = src[1];
          //убираем фоновое изображение
          element.runtimeStyle.backgroundImage="none";
        };
      };
      if (src) {
        element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
      };
    };
  }
// PNG-прозрачность в IE 5,5 - 6,5 End ---------------------------------------

// Get_Width & Get_Height Begin ------------------------------------------------
  function get_width(name_) {
    obj_ = document.getElementById(name_);
    return (obj_.offsetWidth);
  };
  function get_height(name_) {
    obj_ = document.getElementById(name_);
    return (obj_.offsetHeight);
  };
// Get_Width & Get_Height End --------------------------------------------------

// Check_num_&_% Begin ---------------------------------------------------------
  function check_num(num_) {
    return (/^[0-9]{1,10}$/i).test(num_);
  };
  function check_procent(procent_) {
    return (/^[0-9%]{2,4}$/i).test(procent_);
  };
// Check_num_&_% End -----------------------------------------------------------

// Pos Begin -------------------------------------------------------------------
  var pos_array_ = new Array();

  function pos_(name_, parent_, align_g_, align_v_, type_, x_, y_) {
    // Add obj_pos to pos_array
    n_ = pos_array_.length;
    pos_array_[n_] = new Array();
    pos_array_[n_]["name_"] = name_;
    pos_array_[n_]["parent_"] = parent_;
    pos_array_[n_]["align_g_"] = align_g_;
    pos_array_[n_]["align_v_"] = align_v_;
    pos_array_[n_]["type_"] = type_;
    pos_array_[n_]["x_"] = x_;
    pos_array_[n_]["y_"] = y_;

    pos_go_(name_, parent_, align_g_, align_v_, type_, x_, y_);
  };

  function pos_onresize_() {
    for (var i=0; i <= (pos_array_.length-1); i++) {
      name_ = pos_array_[i]["name_"];
      parent_ = pos_array_[i]["parent_"];
      align_g_ = pos_array_[i]["align_g_"];
      align_v_ = pos_array_[i]["align_v_"];
      type_ = pos_array_[i]["type_"];
      x_ = pos_array_[i]["x_"];
      y_ = pos_array_[i]["y_"];

      pos_go_(name_, parent_, align_g_, align_v_, type_, x_, y_);
    };
  };

  function pos_go_(name_, pos_parent_, align_g_, align_v_, type_, x_, y_) {
    obj_ = document.getElementById(name_);
    obj_parent_ = document.getElementById(pos_parent_);
    obj_.style.position = "absolute";

    x_0 =  left_get_(obj_parent_) - left_get_(obj_.offsetParent);

    y_0 =  top_get_(obj_parent_) - top_get_(obj_.offsetParent);

    if (type_ == "num_") {
      // if Screen ---------------------------------------------------------------
      if (pos_parent_ == "screen_") {
        // x Begin ---------------------------------------------------------------
        if (align_g_ == "center_") {
          obj_.style.left = (x_0 + x_ + (getClientWidth() / 2) - (obj_.offsetWidth / 2)) + "px";;
        };
        if (align_g_ == "left_") {
          obj_.style.left = (x_0 + x_) + "px";
        };
        if (align_g_ == "left_left") {
          obj_.style.left = (x_0 - obj_.offsetWidth - x_) + "px";;
        };
        if (align_g_ == "right_") {
          obj_.style.left = (x_0 + getClientWidth() - obj_.offsetWidth - x_) + "px";
        };
        // y Begin ---------------------------------------------------------------
        if (align_v_ == "center_") {
          obj_.style.top = (y_0 + y_ + (getClientHeight() / 2) - (obj_.offsetHeight / 2)) + "px";
        };
        if (align_v_ == "top_") {
          obj_.style.top = (y_0 + y_) + "px";
        };
        if (align_v_ == "top_top") {
          obj_.style.top = (y_0 - obj_.offsetHeight - y_) + "px";
        };
        if (align_v_ == "bottom_") {
          obj_.style.top = (y_0 + getClientHeight() - obj_.offsetHeight - y_) + "px";
        };
        if (align_v_ == "bottom_bottom") {
          obj_.style.top = (y_0 + obj_parent_.offsetHeight + y_) + "px";
        };
      }
      // not screen ------------------------------------------------------------
      else {
        // x Begin ---------------------------------------------------------------
          if (align_g_ == "center_") {
            left_ = x_0 + x_ + (obj_parent_.offsetWidth / 2) - (obj_.offsetWidth / 2);
            if ((left_ < 0) && (pos_parent_ == "body_")) {
              obj_.style.left = 0 + "px";
            }
            else {
              obj_.style.left = left_ + "px";
            };
          };
          if (align_g_ == "left_") {
            obj_.style.left = (x_0 + x_) + "px";
          };
          if (align_g_ == "left_left") {
            obj_.style.left = (x_0 - obj_.offsetWidth - x_) + "px";
          };
          if (align_g_ == "right_") {
            obj_.style.left = (x_0 + obj_parent_.offsetWidth - obj_.offsetWidth - x_) + "px";
          };
          if (align_g_ == "right_right") {
            obj_.style.left = (x_0 + obj_parent_.offsetWidth + x_) + "px";
          };
        // y Begin ---------------------------------------------------------------
          if (align_v_ == "center_") {
            top_ = y_0 + y_ + (obj_parent_.offsetHeight / 2) - (obj_.offsetHeight / 2);
            if ((top_ < 0) && (pos_parent_ == "body_")) {
              obj_.style.top = 0 + "px";
            }
            else {
              obj_.style.top = top_ + "px";
            };
          };
          if (align_v_ == "top_") {
            obj_.style.top = (y_0 + y_) + "px";
          };
          if (align_v_ == "top_top") {
            obj_.style.top = (y_0 - obj_.offsetHeight - y_) + "px";
          };
          if (align_v_ == "bottom_") {
            obj_.style.top = (y_0 + obj_parent_.offsetHeight - obj_.offsetHeight - y_) + "px";
          };
          if (align_v_ == "bottom_bottom") {
            obj_.style.top = (y_0 + obj_parent_.offsetHeight + y_) + "px";
          };
      };
    };

    if (type_ == "%_") {
      x_ = (obj_parent_.offsetWidth / 100 * x_);
      y_ = (obj_parent_.offsetHeight / 100 * y_);
      // if Screen -------------------------------------------------------------
      if (pos_parent_ == "screen_") {
        // x Begin -------------------------------------------------------------
        if (align_g_ == "center_") {
          obj_.style.left = (x_0 + x_ + (getClientWidth() / 2) - (obj_.offsetWidth / 2)) + "px";
        };
        if (align_g_ == "left_") {
          obj_.style.left = (x_0 + x_) + "px";
        };
        if (align_g_ == "left_left") {
          obj_.style.left = (x_0 - obj_parent_.offsetWidth - x_) + "px";
        };
        if (align_g_ == "right_") {
          obj_.style.left = (x_0 + getClientWidth() - obj_.offsetWidth - x_) + "px";
        };
        // y Begin ---------------------------------------------------------------
        if (align_v_ == "center_") {
          obj_.style.top = (y_0 + y_ + (getClientHeight() / 2) - (obj_.offsetHeight / 2)) + "px";
        };
        if (align_v_ == "top_") {
          obj_.style.top = (y_0 + y_) + "px";
        };
        if (align_v_ == "top_top") {
          obj_.style.top = (y_0 - obj_.offsetHeight - y_) + "px";
        };
        if (align_v_ == "bottom_") {
          obj_.style.top = (y_0 + getClientHeight() - obj_.offsetHeight - y_) + "px";
        };
        if (align_v_ == "bottom_bottom") {
          obj_.style.top = (y_0 + obj_parent_.offsetHeight + y_) + "px";
        };
      }
      // not screen ------------------------------------------------------------
      else {
        // x Begin ---------------------------------------------------------------
          if (align_g_ == "center_") {
            left_ = x_0 + x_ + (obj_parent_.offsetWidth / 2) - (obj_.offsetWidth / 2);
            if ((left_ < 0) && (pos_parent_ == "body_")) {
              obj_.style.left = 0 + "px";
            }
            else {
              obj_.style.left = left_ + "px";
            };
          };
          if (align_g_ == "left_") {
            obj_.style.left = (x_0 + x_) + "px";
          };
          if (align_g_ == "left_left") {
            obj_.style.left = (x_0 - obj_parent_.offsetWidth - x_) + "px";
          };
          if (align_g_ == "right_") {
            obj_.style.left = (x_0 + obj_parent_.offsetWidth - obj_.offsetWidth - x_) + "px";
          };
        // y Begin ---------------------------------------------------------------
          if (align_v_ == "center_") {
            top_ = y_0 + y_ + (obj_parent_.offsetHeight / 2) - (obj_.offsetHeight / 2);
            if ((top_ < 0) && (pos_parent_ == "body_")) {
              obj_.style.top = 0 + "px";
            }
            else {
              obj_.style.top = top_ + "px";
            };
          };
          if (align_v_ == "top_") {
            obj_.style.top = (y_0 + y_) + "px";
          };
          if (align_v_ == "top_top") {
            obj_.style.top = (y_0 - obj_.offsetHeight - y_) + "px";
          };
          if (align_v_ == "bottom_") {
            obj_.style.top = (y_0 + obj_parent_.offsetHeight - obj_.offsetHeight - y_) + "px";
          };
          if (align_v_ == "bottom_bottom") {
            obj_.style.top = (y_0 + obj_parent_.offsetHeight + y_) + "px";
          };
      };
    };

  };

  function left_get_(obj_) {
    left_ = 0;
    while (obj_) {
      left_ = left_ + obj_.offsetLeft;
      obj_ = obj_.offsetParent;
    };
    return left_;
  };

  function top_get_(obj_) {
    top_ = 0;
    while (obj_) {
      top_ = top_ + obj_.offsetTop;
      obj_ = obj_.offsetParent;
    };
    return top_;
  };
// Pos End ---------------------------------------------------------------------

// Display_ Begin --------------------------------------------------------------
  function display_(name_, num_set) {
    obj_ = document.getElementById(name_);
    if (num_set == 0) {
      obj_.style.display = "none";
    }
    if (num_set == 1) {
      obj_.style.display = "inline";
    }
  };
// Display_ End ----------------------------------------------------------------

// Visibility_ Begin -----------------------------------------------------------
  function visibility_(name_, num_set) {
    obj_ = document.getElementById(name_);
    if (num_set == 0) {
      obj_.style.visibility = "hidden";
    }
    else {
      obj_.style.visibility = "visible";
    };
  };
// Display_ End ----------------------------------------------------------------

// Visibility_ Begin -----------------------------------------------------------
  function visibility_(name_, num_set) {
    obj_ = document.getElementById(name_);
    if (num_set == 0) {
      obj_.style.visibility = "hidden";
    }
    else {
      obj_.style.visibility = "visible";
    };
  };
// Display_ End ----------------------------------------------------------------

// Create_ & Parent_Get Begin -------------------------------------------------
  function create_(name_, parent_) {
    var obj_ = document.createElement("div");
    obj_.setAttribute("id", name_);
    if (parent_ == "no_") {
      document.body.appendChild(obj_);
    }
    else {
      document.getElementById(parent_).appendChild(obj_);
    };
  };

  function parent_get(name_, parent_) {
    obj_ = document.getElementById(name_);
    obj_parent_ = document.getElementById(parent_);
    obj_parent_.appendChild(obj_);
  };
// Create_ & Parent_Get End ----------------------------------------------------

// Attr Begin ------------------------------------------------------------------
  var attr_array_ = new Array();

  function attr_(name_, width_, height_, bgcolor_, zindex_) {

    n_ = attr_array_.length;
    attr_array_[n_] = new Array();
    attr_array_[n_]["name_"] = name_;
    attr_array_[n_]["width_"] = width_;
    attr_array_[n_]["height_"] = height_;
    attr_array_[n_]["bgcolor_"] = bgcolor_;
    attr_array_[n_]["zindex_"] = zindex_;

    obj_ = document.getElementById(name_);

    if (width_ != "no_") {
      obj_.style.width = width_ + "px";
    };

    if (height_ != "no_") {
      obj_.style.height = height_ + "px";
      if (obj_.offsetHeight > height_) {
        obj_.style.fontSize = 0;
        obj_.style.overflow = "hidden";
        obj_.style.height = height_ + "px";
      };
    };

    if (bgcolor_ != "no_") {
      obj_.style.backgroundColor = "#" + bgcolor_;
    };

    if (zindex_ != "no_") {
      obj_.style.position = "absolute";
      obj_.style.zIndex = zindex_;
    };
  };
// Attr End --------------------------------------------------------------------

// BackGround_ Begin -----------------------------------------------------------
  var bg_array = new Array();

  function background_(bg_name, bg_url, bg_pos_x, bg_pos_y, bg_repeat) {

    n_ = bg_array.length;
    bg_array[n_] = new Array();
    bg_array[n_]["bg_name"] = bg_name;
    bg_array[n_]["bg_url"] = bg_url;
    bg_array[n_]["bg_pos_x"] = bg_pos_x;
    bg_array[n_]["bg_pos_y"] = bg_pos_y;
    bg_array[n_]["bg_repeat"] = bg_repeat;

    background_go(bg_name, bg_url, bg_pos_x, bg_pos_y, bg_repeat);
  };

  function background_go(bg_name, bg_url, bg_pos_x, bg_pos_y, bg_repeat) {
    if (bg_name != "") {
      obj_ = document.getElementById(bg_name);
    };
    if (bg_url != "") {
      obj_.style.background = "url(" + bg_url + ")";
    };
    if ( (bg_pos_x != "") && (bg_pos_y != "") ) {
      obj_.style.backgroundPosition = " " + bg_pos_x + " " + bg_pos_y;
    };
    if ( (bg_repeat == "no-repeat") || (bg_repeat == "repeat-x") || (bg_repeat == "repeat-y") ) {
      obj_.style.backgroundRepeat = "" + bg_repeat;
    };
  };

  function background_onresize() {
    for (var i=0; i <= (bg_array.length-1); i++) {
      bg_name = bg_array[i]["bg_name"];
      bg_url = bg_array[i]["bg_url"];
      bg_pos_x = bg_array[i]["bg_pos_x"];
      bg_pos_y = bg_array[i]["bg_pos_y"];
      bg_repeat = bg_array[i]["bg_repeat"];

      background_go(bg_name, bg_url, bg_pos_x, bg_pos_y, bg_repeat);
    };
  };
// BackGround_ End -------------------------------------------------------------


// Width Begin -----------------------------------------------------------------
  var width_array_ = new Array();

  function width_ (name_, parent_, type_, width_obj_) {
    // Add obj_width_ to width_array_
    n_ = width_array_.length;
    width_array_[n_] = new Array();
    width_array_[n_]["name_"] = name_;
    width_array_[n_]["parent_"] = parent_;
    width_array_[n_]["type_"] = type_;
    width_array_[n_]["width_obj_"] = width_obj_;

    width_go_ (name_, parent_, width_obj_);
  };

  function width_go_ (name_, parent_, type_, width_obj_) {
    obj_ = document.getElementById(name_);
    if (type_ == "num_") {
      x_ = width_obj_;
      if (parent_ == "screen_") {
        obj_.style.width = getClientWidth() + x_ + "px";
      }
      else {
        if (parent_ == "body_") {
          obj_.style.width = document.body.scrollWidth + x_ + "px";
        }
        else {
          obj_parent_ = document.getElementById(parent_);
          obj_.style.width = obj_parent_.offsetWidth + x_ + "px";
        };
      };
    };
    if (type_ == "%_") {
      x_ = getClientWidth()/100*width_obj_;
      if (parent_ == "screen_") {
        obj_.style.width = x_ + "px";
      }
      else {
        if (parent_ == "body_") {
          obj_.style.width = document.body.scrollHeight + x_ + "px";
        }
        else {
          obj_parent_ = document.getElementById(parent_);
          obj_.style.width = x_ + "px";
        };
      };
    };
  };

  function width_onresize_() {
    for (var i=0; i <= (width_array_.length-1); i++) {
      name_ = width_array_[i]["name_"];
      parent_ = width_array_[i]["parent_"];
      type_ = width_array_[i]["type_"];
      width_obj_ = width_array_[i]["width_obj_"];

      width_go_(name_, parent_, type_, width_obj_);
    };
  };
// Width End -------------------------------------------------------------------
// Height Begin ----------------------------------------------------------------
  var height_array_ = new Array();

  function height_ (name_, parent_, type_, height_obj_) {
    // Add obj_height_ to height_array_
    n_ = height_array_.length;
    height_array_[n_] = new Array();
    height_array_[n_]["name_"] = name_;
    height_array_[n_]["parent_"] = parent_;
    height_array_[n_]["type_"] = type_;
    height_array_[n_]["height_obj_"] = height_obj_;

    height_go_ (name_, parent_, type_, height_obj_);
  };

  function height_go_ (name_, parent_, type_, height_obj_) {
    obj_ = document.getElementById(name_);
    if (type_ == "num_") {
      y_ = height_obj_;
      if (parent_ == "screen_") {
        obj_.style.height = getClientHeight() + y_ + "px";
      }
      else {
        obj_parent_ = document.getElementById(parent_);
        obj_.style.height = obj_parent_.offsetHeight + y_ + "px";
      };
    };
    if (type_ == "%_") {
      y_ = getClientHeight()/100 * height_obj_;
      if (parent_ == "screen_") {
        obj_.style.height = y_ + "px";
      }
      else {
        obj_parent_ = document.getElementById(parent_);
        obj_.style.height = y_ + "px";
      };
    };
  };

  function height_onresize_() {
    for (var i=0; i <= (height_array_.length-1); i++) {
      name_ = height_array_[i]["name_"];
      parent_ = height_array_[i]["parent_"];
      type_ = height_array_[i]["type_"];
      height_obj_ = height_array_[i]["height_obj_"];

      height_go_(name_, parent_, type_, height_obj_);
    };
  };
// Height End ------------------------------------------------------------------

function onresize_() {
  width_onresize_();
  height_onresize_();
  pos_onresize_();
  background_onresize();
};

// Opacity Begin ---------------------------------------------------------------
function getElementsByClass(searchClass,node,tag) {
        var classElements = new Array();
        if ( node == null )
                node = document;
        if ( tag == null )
                tag = '*';
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
        for (i = 0, j = 0; i < elsLen; i++) {
                if ( pattern.test(els[i].className) ) {
                        classElements[j] = els[i];
                        j++;
                }
        }
        return classElements;
};

function opacityClass(searchClass, nOpacity) {
  nOpacity = nOpacity / 100;
  var opacityProp = getOpacityProperty();
  var classElements = getElementsByClass(searchClass, document, 'div');
  if (!opacityProp) return;

  if (opacityProp=="filter") {
    nOpacity *= 100;
    for (i=0; i<classElements.length; i++) {
      elem = classElements[i];
      var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
      if (oAlpha) oAlpha.opacity = nOpacity;
      else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; // Для того чтобы не затереть другие фильтры используем "+="

    };
  }
  // Другие браузеры
  else {
    for (i=0; i<classElements.length; i++) {
      elem = classElements[i];
      elem.style[opacityProp] = nOpacity;
    };
  };
};

function opacity_(sElemId, nOpacity) {
  nOpacity = nOpacity / 100;
  var opacityProp = getOpacityProperty();
  var elem = document.getElementById(sElemId);

  if (!elem || !opacityProp) return; // Если не существует элемент с указанным id или браузер не поддерживает ни один из известных функции способов управления прозрачностью

  // Internet Exploder 5.5+
  if (opacityProp=="filter") {

    nOpacity *= 100;

    // Если уже установлена прозрачность, то меняем её через коллекцию filters, иначе добавляем прозрачность через style.filter
    var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
    if (oAlpha) oAlpha.opacity = nOpacity;
    else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; // Для того чтобы не затереть другие фильтры используем "+="

  }
  // Другие браузеры
  else {

    elem.style[opacityProp] = nOpacity;

  };

};

// Функция getOpacityProperty() возвращает свойство которое используется для смены прозрачности или undefined, и может использоваться для проверки возможности изменения прозрачности
function getOpacityProperty() {
  // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
  if (typeof document.body.style.opacity == 'string') {
    return 'opacity';
  }
  // Mozilla 1.6 и младше, Firefox 0.8
  else {
    if (typeof document.body.style.MozOpacity == 'string') {
      return 'MozOpacity';
    }
    else {
      // Konqueror 3.1, Safari 1.1
      if (typeof document.body.style.KhtmlOpacity == 'string') {
        return 'KhtmlOpacity';
      }
      // Internet Exploder 5.5+
      else {
        if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) {
          return 'filter';
        }
      };
    };
  };
  return false; //нет прозрачности
};

  // Opacity_Ani Begin ---------------------------------------------------------
    /* Функции для плавного изменения прозрачности:
      1) fadeOpacity.addRule('opacityRule1', 1, 0.5, 30); //вначале создаем правило, задаем имя правила, начальную прозрачность и конечную, необязательный параметр задержки, влийяющий на скорость смены прозрачности
2) fadeOpacity('elemID', 'opacityRule1'); // выполнить плавную смену прозрачности элемента с id равным elemID, по правилу opacityRule1
3) fadeOpacity.back('elemID'); //вернуться в исходное сотояние прозрачности
*/
function fadeOpacity(sElemId, sRuleName, bBackward)
{
        var elem = document.getElementById(sElemId);
        if (!elem || !getOpacityProperty() || !fadeOpacity.aRules[sRuleName]) return;

        var rule = fadeOpacity.aRules[sRuleName];
        var nOpacity = rule.nStartOpacity;

        if (fadeOpacity.aProc[sElemId]) {clearInterval(fadeOpacity.aProc[sElemId].tId); nOpacity = fadeOpacity.aProc[sElemId].nOpacity;}
        if ((nOpacity==rule.nStartOpacity && bBackward) || (nOpacity==rule.nFinishOpacity && !bBackward)) return;

        fadeOpacity.aProc[sElemId] = {'nOpacity':nOpacity, 'tId':setInterval('fadeOpacity.run("'+sElemId+'")', fadeOpacity.aRules[sRuleName].nDalay), 'sRuleName':sRuleName, 'bBackward':Boolean(bBackward)};
}

fadeOpacity.addRule = function(sRuleName, nStartOpacity, nFinishOpacity, nDalay){fadeOpacity.aRules[sRuleName]={'nStartOpacity':nStartOpacity, 'nFinishOpacity':nFinishOpacity, 'nDalay':(nDalay || 30),'nDSign':(nFinishOpacity-nStartOpacity > 0?1:-1)};};

fadeOpacity.back = function(sElemId){fadeOpacity(sElemId,fadeOpacity.aProc[sElemId].sRuleName,true);};

fadeOpacity.run = function(sElemId)
{
        var proc = fadeOpacity.aProc[sElemId];
        var rule = fadeOpacity.aRules[proc.sRuleName];

        proc.nOpacity = Math.round(( proc.nOpacity + .1*rule.nDSign*(proc.bBackward?-1:1) )*10)/10;
        opacity_(sElemId, proc.nOpacity*100);

        if (proc.nOpacity==rule.nStartOpacity || proc.nOpacity==rule.nFinishOpacity) clearInterval(fadeOpacity.aProc[sElemId].tId);
}
    fadeOpacity.aProc = {};
    fadeOpacity.aRules = {};
  // Opacity_Ani Begin ---------------------------------------------------------
// Opacity End -----------------------------------------------------------------

/* Sizes body & screen Begin */
function getClientWidth() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
};
function getClientHeight() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
};
function getBodyScrollTop() {
  return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);
};
function getBodyScrollLeft() {
  return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);
};
function getClientCenterX() {
  return parseInt(getClientWidth()/2) + getBodyScrollLeft();
};
function getClientCenterY() {
  return parseInt(getClientHeight()/2)+getBodyScrollTop();
};
function getDocumentHeight() {
  return (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;
};
function getDocumentWidth() {
  return (document.body.scrollWidth > document.body.offsetWidth)?document.body.scrollWidth:document.body.offsetWidth;
};
/* Sizes bodu & screen End */
/* Ani Begin*/
glob_array = new Array();
glob_array_num = 0;

function ani_all(name, freq, time, pause, type, what, x_begin, y_begin, x_end, y_end) {
  glob_array_num = glob_array_num + 1;

  glob_array[glob_array_num*100 + 0] = glob_array_num;
  glob_array[glob_array_num*100 + 1] = name;
  glob_array[glob_array_num*100 + 2] = freq;
  glob_array[glob_array_num*100 + 3] = time;
  pause = pause * 1000;
  glob_array[glob_array_num*100 + 4] = pause;
  glob_array[glob_array_num*100 + 5] = type;
  glob_array[glob_array_num*100 + 6] = what;

  glob_array[glob_array_num*100 + 11] = x_begin;
  glob_array[glob_array_num*100 + 12] = y_begin;
  glob_array[glob_array_num*100 + 13] = x_end;
  glob_array[glob_array_num*100 + 14] = y_end;
  glob_array[glob_array_num*100 + 15] = x_begin;
  glob_array[glob_array_num*100 + 16] = y_begin;

  glob_array[glob_array_num*100 + 21] = "timer_" + name;
  glob_array[glob_array_num*100 + 22] = 1000 / freq;
  glob_array[glob_array_num*100 + 23] = (x_end - x_begin) / (freq * time);
  glob_array[glob_array_num*100 + 24] = (y_end - y_begin) / (freq * time);

  setTimeout("ani(" + glob_array_num + ");", pause);
};

function ani(array_num) {
  name  = glob_array[array_num*100 + 1];
  freq  = glob_array[array_num*100 + 2];
  time  = glob_array[array_num*100 + 3];
  pause = glob_array[array_num*100 + 4];
  type  = glob_array[array_num*100 + 5];
  what  = glob_array[array_num*100 + 6];
  x_begin = glob_array[array_num*100 + 11];
  y_begin = glob_array[array_num*100 + 12];
  x_end   = glob_array[array_num*100 + 13];
  y_end   = glob_array[array_num*100 + 14];
  x_now   = glob_array[array_num*100 + 15];
  y_now   = glob_array[array_num*100 + 16];
  timer_name  = glob_array[array_num*100 + 21];
  timer_delay = glob_array[array_num*100 + 22];
  speed_x     = glob_array[array_num*100 + 23];
  speed_y     = glob_array[array_num*100 + 24];

  x_now = x_now + speed_x;
  glob_array[array_num*100 + 15] = x_now;
  y_now = y_now + speed_y;
  glob_array[array_num*100 + 16] = y_now;

  if (type == "move") {
    if (what == "bgpos") {
      document.getElementById(name).style.backgroundPosition = "" + x_now + " " + y_now;

      timer_name = setTimeout("ani(" + array_num + ");", timer_delay);

      if (speed_x >= 0) {
        if (x_now >= x_end) {
          clearTimeout(timer_name);
          document.getElementById(name).style.backgroundPosition = "" + x_end + " " + y_end;
        };
      }
      else {
        if (x_now <= x_end) {
          clearTimeout(timer_name);
          document.getElementById(name).style.backgroundPosition = "" + x_end + " " + y_end;
        };
      };
    };
    if (what == "margin") {
      document.getElementById(name).style.marginLeft = ("" + x_now) + "px";
      document.getElementById(name).style.marginTop = ("" + y_now) + "px";

      timer_name = setTimeout("ani(" + array_num + ");", timer_delay);

      if (speed_x >= 0) {
        if (x_now >= x_end) {
          clearTimeout(timer_name);
          document.getElementById(name).style.marginLeft = ("" + x_end) + "px";
          document.getElementById(name).style.marginTop = ("" + y_end) + "px";
        };
      }
      else {
        if (x_now <= x_end) {
          clearTimeout(timer_name);
          document.getElementById(name).style.marginLeft = ("" + x_end) + "px";
          document.getElementById(name).style.marginTop = ("" + y_end) + "px";
        };
      };
    };
  };
  if (type == "opacity") {
    opacity_(name, x_now);

    timer_name = setTimeout("ani(" + array_num + ");", timer_delay);

    if (speed_x >= 0) {
      if (x_now >= x_end) {
        clearTimeout(timer_name);
        opacity_(name, x_end);
      };
    }
    else {
      if (x_now <= x_end) {
        clearTimeout(timer_name);
        opacity_(name, x_end);
      };
    };
  };
};
/* Ani End*/

/* перемешать массив случайным образом Begin -------------------------------- */
Array.prototype.shuffle = function( b ) {
 var i = this.length, j, t;
 while( i ) {
  j = Math.floor( ( i-- ) * Math.random() );
  t = b && typeof this[i].shuffle!=='undefined' ? this[i].shuffle() : this[i];
  this[i] = this[j];
  this[j] = t;
 }
 return this;
};
/*
  var a = new Array(1,2,3,4,5);
  alert( a.shuffle() );
*/
/* перемешать массив случайным образом End ---------------------------------- */

// Зеркальное отражение Img Begin ----------------------------------------------
  // <img src="my_image.jpg" class="reflect">
  // <img src="my_image.jpg" class="reflect rheight34 ropacity60">
/**
 * reflection.js v2.0
 * http://cow.neondragon.net/stuff/reflection/
 * Freely distributable under MIT-style license.
 */

/* From prototype.js */
if (!document.myGetElementsByClassName) {
        document.myGetElementsByClassName = function(className) {
                var children = document.getElementsByTagName('*') || document.all;
                var elements = new Array();

                for (var i = 0; i < children.length; i++) {
                        var child = children[i];
                        var classNames = child.className.split(' ');
                        for (var j = 0; j < classNames.length; j++) {
                                if (classNames[j] == className) {
                                        elements.push(child);
                                        break;
                                }
                        }
                }
                return elements;
        }
}

var Reflection = {
        defaultHeight : 0.5,
        defaultOpacity: 0.5,

        add: function(image, options) {
                Reflection.remove(image);

                doptions = { "height" : Reflection.defaultHeight, "opacity" : Reflection.defaultOpacity }
                if (options) {
                        for (var i in doptions) {
                                if (!options[i]) {
                                        options[i] = doptions[i];
                                }
                        }
                } else {
                        options = doptions;
                }

                try {
                        var d = document.createElement('div');
                        var p = image;

                        var classes = p.className.split(' ');
                        var newClasses = '';
                        for (j=0;j<classes.length;j++) {
                                if (classes[j] != "reflect") {
                                        if (newClasses) {
                                                newClasses += ' '
                                        }

                                        newClasses += classes[j];
                                }
                        }

                        var reflectionHeight = Math.floor(p.height*options['height']);
                        var divHeight = Math.floor(p.height*(1+options['height']));

                        var reflectionWidth = p.width;

                        if (document.all && !window.opera) {
                                /* Fix hyperlinks */
                if(p.parentElement.tagName == 'A') {
                        var d = document.createElement('a');
                        d.href = p.parentElement.href;
                }

                                /* Copy original image's classes & styles to div */
                                d.className = newClasses;
                                p.className = 'reflected';

                                d.style.cssText = p.style.cssText;
                                p.style.cssText = 'vertical-align: bottom';

                                var reflection = document.createElement('img');
                                reflection.src = p.src;
                                reflection.style.width = reflectionWidth+'px';
                                reflection.style.display = 'block';
                                reflection.style.height = p.height+"px";

                                reflection.style.marginBottom = ("-"+(p.height-reflectionHeight))+'px';
                                reflection.style.filter = 'flipv progid:DXImageTransform.Microsoft.Alpha(opacity='+(options['opacity']*100)+', style=1, finishOpacity=0, startx=0, starty=0, finishx=0, finishy='+(options['height']*100)+')';

                                d.style.width = reflectionWidth+'px';
                                d.style.height = divHeight+'px';
                                p.parentNode.replaceChild(d, p);

                                d.appendChild(p);
                                d.appendChild(reflection);
                        } else {
                                var canvas = document.createElement('canvas');
                                if (canvas.getContext) {
                                        /* Copy original image's classes & styles to div */
                                        d.className = newClasses;
                                        p.className = 'reflected';

                                        d.style.cssText = p.style.cssText;
                                        p.style.cssText = 'vertical-align: bottom';

                                        var context = canvas.getContext("2d");

                                        canvas.style.height = reflectionHeight+'px';
                                        canvas.style.width = reflectionWidth+'px';
                                        canvas.height = reflectionHeight;
                                        canvas.width = reflectionWidth;

                                        d.style.width = reflectionWidth+'px';
                                        d.style.height = divHeight+'px';
                                        p.parentNode.replaceChild(d, p);

                                        d.appendChild(p);
                                        d.appendChild(canvas);

                                        context.save();

                                        context.translate(0,image.height-1);
                                        context.scale(1,-1);

                                        context.drawImage(image, 0, 0, reflectionWidth, image.height);

                                        context.restore();

                                        context.globalCompositeOperation = "destination-out";
                                        var gradient = context.createLinearGradient(0, 0, 0, reflectionHeight);

                                        gradient.addColorStop(1, "rgba(255, 255, 255, 1.0)");
                                        gradient.addColorStop(0, "rgba(255, 255, 255, "+(1-options['opacity'])+")");

                                        context.fillStyle = gradient;
                                        context.rect(0, 0, reflectionWidth, reflectionHeight*2);
                                        context.fill();
                                }
                        }
                } catch (e) {
            }
        },

        remove : function(image) {
                if (image.className == "reflected") {
                        image.className = image.parentNode.className;
                        image.parentNode.parentNode.replaceChild(image, image.parentNode);
                }
        }
}

function addReflections() {
        var rimages = document.myGetElementsByClassName('reflect');
        for (i=0;i<rimages.length;i++) {
                var rheight = null;
                var ropacity = null;

                var classes = rimages[i].className.split(' ');
                for (j=0;j<classes.length;j++) {
                        if (classes[j].indexOf("rheight") == 0) {
                                var rheight = classes[j].substring(7)/100;
                        } else if (classes[j].indexOf("ropacity") == 0) {
                                var ropacity = classes[j].substring(8)/100;
                        }
                }

                Reflection.add(rimages[i], { height: rheight, opacity : ropacity});
        }
}

var previousOnload = window.onload;
window.onload = function () { if(previousOnload) previousOnload(); addReflections(); }
// Зеркальное отражение Img End ------------------------------------------------

