// (c) eclipse-creative.com
// 2008/10/09 tomc

var menu_active = null;

function menu( _el_name ){
	this.isOver = true;
	this.el_name = null;		// tag id string
	this.el = null;				// dom element
	this.ttl = 500;				// time to live after mouse has moved off
	this._int_id = null;		// interval id
	this.mt_el = null;			// mootools element	

	this.kill = function(obj){
		clearInterval(obj._int_id);
		obj._int_id = null;
		obj.el.style.display="none";
	}

	this.hideEvent = function(obj){
		if( !obj.isOver ) obj.kill(obj);
	}
	
	this.mouseIsOut = function(){
		this.isOver	= false;
		
		var menuCpy=this;
		if(this._int_id){
			clearInterval(this._int_id);
			this._int_id = null;
		}
		this._int_id = setInterval( function(){menuCpy.hideEvent(menuCpy)}, this.ttl);
	}
	
	this.mouseIsIn = function(){
		this.isOver=true;

		if (menu_active != this) {
			if (menu_active) 
				menu_active.kill(menu_active);
			menu_active = this;
		}
			
			
		if (this._int_id) {
			clearInterval(this._int_id);
			this._int_id = null;
		}
			
		this.el.style.display = "block";
		
	}
	

	// .: CONSTRUCTION TIME :. //
	if( _el_name && document.getElementById(_el_name) )
	{
		this.el_name = _el_name;
		this.el = document.getElementById(_el_name);
		this.el.style.display="none";
	}

}