function Animator()
{
  var fadingTime = 200;
  
  function isIE()
  {
    var isIE = false; // it is not ie. good boy

    if (navigator.appName == 'Microsoft Internet Explorer') { //fuck
      isIE = true;
    }

    return isIE;
  }

  function normalAnimate()
  {
    $('.submenu_wrapper').css({
      display: 'none',
      opacity: 0
    });
    $('.menu_item').mouseenter(function() {
      $('a:first', $(this)).css({
        backgroundColor: '#dccda1'
      })
//      find the position of mouse-overed item
      var _position = $('.menu_item').index($(this));
//      and make margins
      var _firstUl = $('ul:first', $(this)).css({
        marginLeft: _position*183 + 15
      });
  //    and show current
      var currentSubmenuWrapper = $('.submenu_wrapper', $(this));
      currentSubmenuWrapper.css({
        display: 'block'
      });
//      set opacity to submenu_transparent_background:
      $('.submenu_transparent_background', currentSubmenuWrapper).css({
        opacity : 0.52
      });
  //    if we mouse over the menu item while fading-out animation hasn't finished -
  //    then stop animation
      currentSubmenuWrapper.stop();
      currentSubmenuWrapper.css({
        opacity: 0
      });
      currentSubmenuWrapper.animate({
        opacity: 1
      }, fadingTime)
    })
    $('.menu_item').mouseleave(function() {
      $('a:first', $(this)).css({
        backgroundColor: '#ede6d0'
      })
      var currentSubmenuWrapper = $('.submenu_wrapper', $(this));
      currentSubmenuWrapper.animate({
        opacity: 0
      }, fadingTime, function() {
        $(this).css({
          display: 'none'
        });
      })
    })
  }

  function ie8Animate()
  {
    $('.submenu_wrapper').css({
      display: 'none'
    });
    $('.menu_item').mouseenter(function() {
      $('a:first', $(this)).css({
        backgroundColor: '#dccda1'
      })
  //    and show current
      var currentSubmenuWrapper = $('.submenu_wrapper', $(this));
      currentSubmenuWrapper.css({
        display: 'block'
      });
      $('.submenu_transparent_background', currentSubmenuWrapper).css({
        opacity : 0.52
      });
    })
    $('.menu_item').mouseleave(function() {
      $('a:first', $(this)).css({
        backgroundColor: '#ede6d0'
      })
      var currentSubmenuWrapper = $('.submenu_wrapper', $(this));
      currentSubmenuWrapper.css({
        display : 'none'
      });
    })
  }

  function animate()
  {
    if(isIE() === true)
    {
      ie8Animate();
    }
    else
    {
      normalAnimate();
    }
  }

  return {
    animate : animate
  }
}

$(document).ready(function() {
  var animator = new Animator();
  animator.animate();
})
