$(window).load(function() {
  $('#banner_slide').show();
  $('.box').hover(function(){
    $(this).children('div.title').css('background-position','0 -48px');
  },function() {
    $(this).children('div.title').css('background-position','0 -0');
  });
  $('.right_box').hover(function(){
    $(this).children('div.title').css('background-position','0 -48px');
  },function() {
    $(this).children('div.title').css('background-position','0 -0');
  });
  var length_submenu = 0;
  $("ul#menu").children("li").each(function() {
    if($(this).children("ul").size()) {
      $(this).children("ul#submenu").children("li").each(function() {
        if ($(this).children("a").text().length>length_submenu) {
          length_submenu=$(this).children("a").text().length;
        }
      });
      if(length_submenu>20) {
        $(this).children("ul#submenu").css("width",length_submenu*7);
      } else {
        $(this).children("ul#submenu").css("width","160px");
      }
    }
    length_submenu = 0
  });
  var right_block = $('#content_text').height();
  if(right_block==0) {
    right_block = $('#right_block_menu').height();
    if(right_block % 2 != 0)
      right_block++;
  } else {
    if($('#content_text').height()>$('#right_block_menu').height()) {
      right_block = $('#content_text').height()+10;
    } else {
      right_block = $('#right_block_menu').height();
    }
    if(right_block % 2 != 0)
      right_block++;
  }
  var home_boxes = $('#boxes').height();
  if(home_boxes % 2 == 0)
    home_boxes++;
  $('#right_block_menu').height(right_block);
  $('#right_block_menu ul.right_menu_items li').hover(function(){
    if(!$(this).hasClass('active')) {
      $(this).css('background-position','-31px -66px');
      $(this).children('div').children('a').css('color','#fff');
    }
  },function() {
    if(!$(this).hasClass('active')) {
      $(this).children('div').children('a').css('color','#c40102');
      $(this).css('background-position','-31px 0');
    }
  })
  var length_menus_footer = 0;
  $("ul#menus_footer").children("li").each(function() {
    var li_width = 0;
    /*if($(this).children('a').text().length>12)
      li_width = $(this).children('a').text().length*11;
    if($(this).children("ul").size()) {
      $(this).children("ul.submenu_footer").children("li").each(function() {
        if ($(this).children("a").text().length>length_menus_footer) {
          length_menus_footer=$(this).children("a").text().length;
        }
      });
      var sub_width = 178;
      if (length_menus_footer>=26) {
        sub_width = length_menus_footer*6.8;
      }
      if(li_width>sub_width) {
        $(this).css("width",li_width);
      } else {
        $(this).css("width",sub_width);
      }
      length_menus_footer=0;
    }*/
	$(this).css("width",$("#footer_menu").width()/$('#menus_footer').children('li').size());
  });
  var length_footer_menu = 0;
  $("ul#menus_footer").children("li").each(function() {
    if($(this).height() > length_footer_menu) {
      length_footer_menu = $(this).height();
    }
  });
  $("ul#menus_footer").children("li").css('height',length_footer_menu+'px');
});
