function getPageScroll() {
   var xScroll, yScroll;
   if (self.pageYOffset) {
      yScroll = self.pageYOffset;
      xScroll = self.pageXOffset;
   } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
      yScroll = document.documentElement.scrollTop;
      xScroll = document.documentElement.scrollLeft;
   } else if (document.body) {// all other Explorers
      yScroll = document.body.scrollTop;
      xScroll = document.body.scrollLeft;	
   }
   return new Array(xScroll,yScroll) 
}

function getPageHeight() {
    var windowHeight
    if (self.innerHeight) {	// all except Explorer
      windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
      windowHeight = document.body.clientHeight;
    }	
    return windowHeight
}

$(function() {
  var site_height =  $("#top").outerHeight() + $("#content").outerHeight() + $("#copyright").outerHeight();
  if (site_height < getPageHeight()) {
     $("#content").height($("#content").outerHeight()+(getPageHeight()-site_height))
  }
  
  $("[rel=lightbox]").lightBox({
     imageLoading: '/image/jquery/lightbox/lightbox-ico-loading.gif',
     imageBtnClose: '/image/jquery/lightbox/lightbox-btn-close.gif',
     imageBtnPrev: '/image/jquery/lightbox/lightbox-btn-prev.gif',
     imageBtnNext: '/image/jquery/lightbox/lightbox-btn-next.gif',
     imageBlank:  '/image/jquery/lightbox/lightbox-blank.gif',
     txtImage: 'Фотография',
     txtOf: 'из'
  })
  
  var width_links = 0; 
  $("#menu .link").each(function() {width_links = width_links + $(this).outerWidth()})
  var diff = parseInt(($("#menu .menu_content").width() - width_links)/$("#menu .delim").length);
  $("#menu .delim").each(function() {
     $(this).width(diff);
  })
  
  $("#menu .sublinks td").each(function() {
     if ($.browser.msie && ($.browser.version < 7)) {
        $(this).css('background', 'none');
        this.runtimeStyle.filter = 
        "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/image/layout/menu-top-bg.png',sizingMethod='scale'";
     } 
  })
  
  $("#menu .sublinks td").hover(
     function() { 
         if ($.browser.msie && ($.browser.version < 7)) {
            this.runtimeStyle.filter = 
                "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/image/layout/menu-top-bg-current.png', sizingMethod='scale'";
         } else { 
            $(this).css('background', 'url(/image/layout/menu-top-bg-current.png)');
         }
     },
     function() {
        if ($.browser.msie && ($.browser.version < 7)) {
            this.runtimeStyle.filter = 
                "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/image/layout/menu-top-bg.png', sizingMethod='scale'";
         } else {
            $(this).css('background', 'url(/image/layout/menu-top-bg.png)');
         }
     }
  );
  $("#menu .link").hover(
     function() {
        $sub  = $(".sublinks", this);
        if ($sub.width() < ($(this).width()+15))
        $("table", this).width($(this).width()+15);
        $sub.show();
     },
     function() {
        $(".sublinks", this).hide();
     }
  )
  
  //$("#section .inner").css('margin-top', parseInt(($("#section .section_info").height() - $("#section .inner").height())/2) + 'px');
  
  var height1 = $(".left_column").height();
  var height2 = $(".center_column").height();
  var height3 = $(".right_column").height();
  var inner_height1 = $(".inner_content").outerHeight();
  var inner_height2 = $(".catalog_items").outerHeight();
  if (height2 < height1 || height2 < height3) {
     if (height1 > height3) {
        $(".inner_content").height(inner_height1+(height1-height2));
        $(".catalog_items").height(inner_height2+(height1-height2));
     } else {
        $(".inner_content").height(inner_height1+(height3-height2));
        $(".catalog_items").height(inner_height2+(height3-height2));
     }
  }
  
})
