$.myMenu = function() {
  var id = '#secondary_menu';
  var seep = 1;
  var step = $.browser.mozilla ? 10 : 5;
  var len;
  var count = 0;
  var target;
  var intervalId;
  
  if($.browser.mozilla) {
  	$(id).css('left','210px');
  }
    
  $(id + ' > ul > li > ul').each(function(){
    $(this).attr('len',$(this).height()-30);      
  });
    
  $(id + ' > ul > li').hover(
    function(){      
      if($(this).find('ul').css('display') == 'none') {                                                               
        if(!!target) {                    
            target.style.display = 'none';
            target.style.height = '0px';
            count = 0;
            window.clearInterval(intervalId);    
        }
               
        target = $(this).find('ul')[0];                         
        len = $(this).find('ul').attr('len');         
        //target.style.overflow = 'hidden';
        target.style.height = count+'px';
        target.style.display = 'block';  
        
        function slideDown() {  
           //debug(count+":"+len);      
           if(count >= len) {                            
                window.clearInterval(intervalId);
                return;
             }
            count += step;
            target.style.height = count+'px';        
        }      
               
        intervalId = window.setInterval(slideDown, seep);
       
      }  
    },
    function(){                            
      if(!!!target) return; 
                 
      function slideUp() {                        
         if(count == 0) {
                target.style.display = 'none';                
                len = 0;
                window.clearInterval(intervalId);
                return;
         }
         count -= step; 
         target.style.height = count+'px';
      }
      
      window.clearInterval(intervalId);      
      intervalId = window.setInterval(slideUp, seep); 
        
    }
  );
};

$(function(){
  jQuery.myMenu();
});	