/********************************************/
/* KSE website javascript	stole from IPS  */
/********************************************/

var kse = {
	menus: {}
	
};

kse.menu = Class.create({
	
	initialize: function( elem, target )
	{
		if( !$( elem ) || !$( target ) ){
			return;
		}
		
		this.elem = $( elem );
		this.target = $( target );
		
		$( this.target ).hide();
		
		$( elem ).observe('mouseover', this.event_mouseover.bindAsEventListener(this));
		$( elem ).observe('mouseout', this.event_mouseout.bindAsEventListener(this));

		$( this.elem ).setStyle({
			position: 'relative'
		}); 
	},
	
	doShow: function()
	{
		Debug.write("Showing " + $( this.elem ).id );
		
		// Position it
		var elemPos = $( this.elem ).positionedOffset();
		var elemDim = $( this.elem ).getDimensions();
		
		$( this.target ).setStyle({
			position: 'absolute',
//			top: ( elemPos.top + elemDim.height ) + 'px',
			top: '32px',
//			left: ( elemPos.left ) + 'px',
			left: '-1px',
			background: '#111',
			borderBottom: '1px solid #222',
			whiteSpace: 'nowrap',
			zIndex: '10000'
		});
		
		new Effect.Appear( $( this.target ), { duration: 0.1 } ); 
	},
	
	doHide: function()
	{
		if( $( this.target ).visible() )
		{
			Debug.write("Hiding " + $( this.elem ).id );
			new Effect.Fade( $( this.target ), { duration: 0.1 } );
		}
	},
	
	event_mouseover: function( e )
	{
		window.clearTimeout( this._meventHide );
		this._meventShow = this.doShow.bind(this).delay(0.2);		
	},
	
	event_mouseout: function( e )
	{
		window.clearTimeout( this._meventShow );
		this._meventHide = this.doHide.bind(this).delay(0.2);		
	}
});
