$(document).ready(function(){
   var change = false;

   $('#work, #solution, #about, #contact').hover(function(){
      change = true;
      var id = $(this).attr("id");
      $('#header div:first a').removeAttr("class");
      $(this).attr("class", id+"H");
      $('#submenu').slideDown("slow").show();
      $('#submenu ul').css('display', 'none');
      $('#submenu #'+id+'Sub').show();
   });

   $('#blog').hover(function(){
      $('#header div:first a').removeAttr("class");
      $(this).attr("class", "blogH");
      if ($('#submenu ul').is(":visible"))
      {
         $('#submenu').slideUp("slow");
         $('#submenu ul').css('display', 'none');
      }
   });

   $('#bodyContainer').hover(function(){
      if (change)
      {
         change = false;
         $('#header div:first a').removeAttr("class");
         $('#submenu').slideUp("slow");
         $('#submenu ul').css('display', 'none');
         $('#submenu .current').show();
      }

      if ($('#blog').hasClass("blogH"))
         $('#blog').removeAttr("class");
   });
});

