var dropMenu = new Class({
    
    initialize : function(navId,menuClass){
        this.t = false;
        this.current = null;
        var lis = $(navId).getElementsByTagName('li');
        for(var i=0;i<lis.length; i++){
            if (lis[i].className != menuClass) continue;
            var thislink = this.findChild(lis[i],'a');
            thislink.onmouseover = this.showMenu.bindWithEvent(this);
            thislink.onmouseout = this.startTimer.bind(this);
            if (ol = this.findChild(lis[i], 'ol')){
        
                for(var k=0; k<ol.childNodes.length;k++){
          
                    ol.childNodes[k].onmouseover = this.resetTimer.bind(this);
                    ol.childNodes[k].onmouseout = this.startTimer.bind(this);
                }
                
            }    
         }
    
    },
    
    
    showMenu : function(e){
    
        var e = new Event(e);
        var thelink = e.target;
        this.resetTimer();
        if( this.current) this.hideMenu(this.current);
        thelink = thelink.parentNode;
        this.current = thelink;
        var ol = this.findChild(thelink, 'ol');
        if (!ol) return ;
        ol.style.display = 'block';
        
    },
    
    hideMenu : function(thelink){
        var ol = this.findChild(thelink, 'ol');
        if(!ol) return;
        ol.style.display = 'none';
    },
    
    findChild : function(obj,tag){
         if(obj.getElementsByTagName(tag)!=null){
             return obj.getElementsByTagName(tag)[0]
         }else{
            return false;
         }
    
    },
    
    startTimer : function(){
        var current = this.current;
        var  hide = this.hideMenu.bind(this);  //closure need (如果不用bind，执行hideMenu 中的上下文,this.findChild将出错，this此时为window)
        this.t = window.setTimeout(function(){hide(current)}, 200);
    },
    
    resetTimer: function(){
      if(this.t) clearTimeout(this.t);
     // alert(this.t);
    }

})