$(function(){

  // Центрируем эелементы в меню «Каталог»
  $('#left-col .catalogue a').each(function(){
    $(this).css('top', function(){
      return ($(this).parent().height() - $(this).height())/2*(-1) + 'px';
    });
  })

  // Добавляем полоску под h2 элементами
  $('h2').not('.basket h2').append('<span class="underline"></span>');

  // При изменении валюты отправляем форму
  $('#right-col .currencies select').change(function(){
    $('#right-col .currencies form').submit();
  });

  // Функция для выравнивания внизу продолжение фона
  function PositionFooterBg(){
    $('#footer div.bg').css({
      marginLeft : function(){
        if (document.body.clientWidth > 1250) {
          return (document.body.clientWidth - 1250)/2 + 229 + 'px';
        }
        else return '229px';
      },
      marginRight : function(){
        if (document.body.clientWidth > 1250) {
          return (document.body.clientWidth - 1250)/2 + 238 + 'px';
        }
        else if (document.body.clientWidth < 997) {
          return '0';
        }
        else return '238px';
      },
      width : function(){
        if (document.body.clientWidth < 997) {
          return '530px';
        }
        else return 'auto';
      }
    });
  }
  PositionFooterBg();


  $(window).resize(function(){
    PositionFooterBg();
  });

})









