var AutoHide = Class.create();
AutoHide.prototype = {
   initialize: function(observe_element, body_element, hidefunc) {
      this.observe_element = $(observe_element);
      this.body_element = $(body_element);
      this.hide = function(){
	 if(Element.visible(this.body_element)){
	    hidefunc();
	 }
	 this.eraseTimer();
      };
      this.body_element.auto_hide_timer = null;
      Event.observe(this.observe_element,
		    'mouseout',
		    this.setTimer.bind(this)
		   )
      Event.observe(this.observe_element,
		    'mouseover', 
		    this.eraseTimer.bind(this)
		   );
   },

   setTimer: function() {
      this.body_element.auto_hide_timer = setTimeout(this.hide.bind(this), TIME_OUT);
   },

   eraseTimer: function() {
      if(this.body_element.auto_hide_timer != null) {
	 clearTimeout(this.body_element.auto_hide_timer);
	 this.body_element.auto_hide_timer = null;
      }
   }
};


