$(document).ready(function(){
  $('#mainmenu a').click(function(){
    if($('.menucontainer').is(':hidden')) {
      $('#mainmenu a').removeClass('current');
      $(this).addClass('current');
      $('.'+$(this).attr('id')).show(0);
      $('.menucontainer').slideDown('fast');
      $('#mmainlink').html('Mergi la <a href="'+$(this).attr('href')+'">'+$(this).html()+'</a>');
      if($(this).attr('id') == "menu_solutii") { $('#menu-solutii-info').fadeIn('fast'); } else { $('#menu-solutii-info').fadeOut('fast'); }
    } else {
      var newtoshow = $('.'+$(this).attr('id'));
      if(newtoshow.is(':hidden')) {
        $('#mainmenu a').removeClass('current');
        $(this).addClass('current');
        $('.submenu:visible').fadeOut('fast', function(){ newtoshow.fadeIn('fast'); });
        $('#mmainlink').html('Mergi la <a href="'+$(this).attr('href')+'">'+$(this).html()+'</a>');
        if($(this).attr('id') == "menu_solutii") { $('#menu-solutii-info').fadeIn('fast'); } else { $('#menu-solutii-info').fadeOut('fast'); }
      }
    }
  });
  $('#closemenu').click(function(){
    $('#mainmenu a').removeClass('current');
    $('.menucontainer').slideUp('fast', function(){ $('.submenu').hide(); });
  });
  $('#prodslink').click(function(){
    if($('#prodsmenu').is(':hidden')) {
      $('#prodsmenu').slideDown(100);
    } else {
      $('#prodsmenu').slideUp(100);
    }
  });

  $("#closecontact").click(function(){ $(".topcontainer").slideUp('fast', function(){ $(".topcontainer .topbox").hide(); }); });
  $("#closenewsletter").click(function(){ $(".topcontainer").slideUp('fast', function(){ $(".topcontainer .topbox").hide(); }); });
  $("#contactl").click(function(){
    if($(".topcontainer").is(':visible')) {
      if($(".topcontact").is(':hidden'))
        $(".topcontainer").slideUp('fast', function(){
          $(".topcontainer .topbox").hide();
          $(".topcontainer .topcontact").show();
          $(".topcontainer").slideDown('fast');
        });
    } else {
      $(".topcontainer .topbox").hide();
      $(".topcontainer .topcontact").show();
      $(".topcontainer").slideDown('fast');
    }
  });
  $("#newsletterl").click(function(){
    if($(".topcontainer").is(':visible')) {
      if($(".topnewsletter").is(':hidden'))
        $(".topcontainer").slideUp('fast', function(){
          $(".topcontainer .topbox").hide();
          $(".topcontainer .topnewsletter").show();
          $(".topcontainer").slideDown('fast');
        });
    } else {
      $(".topcontainer .topbox").hide();
      $(".topcontainer .topnewsletter").show();
      $(".topcontainer").slideDown('fast');
    }
  });
});
function gotop() {
  $('html,body').animate({scrollTop: 0}, 500);
  return false;
}
