	var obj = null;  
	var mmactive = null;  
    
    function hideUl() {  
    if (obj) {  
        obj.find('ul').hide();  
         var currentId = obj.attr('id');
          
          if(mmactive != currentId){
            $('#bg_'+currentId).stop().animate({backgroundPosition:"(0px -75px)"}, {duration:500});   
            obj.children('#bg_'+currentId).css('color','white');
        }
        
        }   
	}
    

      
  	function menu(mactive,state,submenu){
  	if (typeof submenu == "undefined") {
    submenu = "";
    }

      $(".menuClosedText").hide();
      $('.menuSet').find('ul').hide();

  if(state == 'close'){
    $(".menuClosedText").show();
  	$('.menuSet').hide();
  }
  mmactive = mactive;
  

  	$('.menuSet > li > a > span').hover(function() {  
        if (obj) {
            var currentId = obj.attr('id');
            if(mactive != currentId){
            $('#bg_'+currentId).stop().animate({backgroundPosition:"(0px -75px)"}, {duration:500}); 
        	$('#bg_'+currentId).css('color','white');
            }
            obj.find('ul').hide();  
            obj = null;           
        }
       
     
      
       
       var currentId = $(this).parent().parent().attr('id');
        
       if(mactive){     
        if( $('#'+currentId+' > ul').children().size() > 0)
            {
            $('#'+mactive).find('ul').hide();
            }else{
                $('#'+mactive).find('ul').show();
            }
       
        }
        
        if(mactive != currentId){
        $(this).parent().parent().find('ul').fadeIn().show();
        $('#bg_'+currentId).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:500});
         $('#bg_'+currentId).css('color','#301a58');
        }else{
        $(this).parent().parent().find('ul').show();  
        $('#bg_'+currentId).css('color','#b7a1c5');
        }
     
       
    }, function() {  
        obj = $(this).parent().parent(); 
        var currentId = obj.attr('id');
        if(mactive != currentId){
        if( $('#'+currentId+' > ul').children().size() > 0)
       {
        
       // semmi nem történik
        
        } else {
        $('#bg_'+currentId).stop().animate({backgroundPosition:"(0px -75px)"}, {duration:500}); 
       	$('#bg_'+currentId).css('color','white'); 
        $('#'+mactive).find('ul').show();
        }
            }
    });  
    
    
    if(state == 'close'){
   	    $(".menu").css({ left: "-440px",height: "97px" });
        $(".menu").hover(function() {
        $(".menuClosedText").fadeOut("fast");
        $(this).stop().animate({ left: "0px" ,height: "130px"}, 'slow', 'easeOutBounce');
      	$('.menuSet').show();
      	}
      	,function(){
      	$(".menuClosedText").fadeIn("fast");
       	$(this).stop().animate({ left: "-440px",height: "97px" }, 'slow','easeOutBounce');
       	hideUl();
       	$('.menuSet').hide();
   	});
    }else{
        $(".menu").hover(function() {	}
      	,function(){
      	  	hideUl(); 
      	  $('.menuSet > li > ul').hide();
      	   $('#'+mactive).find('ul').show();
           	});
        
        $(".menu").css({ left: "0px" ,height: "130px"}) ;
      /* 	$('#bg_'+mactive).css('background','url(/Front-end/public/img/menu/active/'+mactive+'_h_bg.png)');
       	$('#bg_'+mactive).css('background-position','0px -75px');
        $('#bg_'+mactive).css('background-repeat','no-repeat');
        $('#bg_'+mactive).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:500});*/
        $('#bg_'+mactive).css('color','#b7a1c5');
        $('#'+mactive).find('ul').show();
        if(submenu != ""){
        $('#'+submenu).css('color','white');
        }
    }
 
  }
