/**
 * @author Gert Blom
 * @company Blom Internetdiensten
 * @copyright 2009
 */

var PopMenu = function(){};


PopMenu.delayTime	= 100; // milliseconds
PopMenu.currentShowing = null; // id of element
PopMenu.currentTimer = null; // instance of setTimeout event


PopMenu.Show = function( id ) {

	this.ClearTimer();
		
	if ( this.currentShowing == id ) {
		return;	
	}else if ( null != this.currentShowing ) {
		this.HideElement( this.currentShowing );
	}

	this.currentShowing = id;	
	this.SetDisplay( id, 'block' );
	this.SetCursor( id, 'default' );
}

PopMenu.Hide = function( id ) {
	this.ClearTimer();
	this.currentTimer = setTimeout( "PopMenu.HideElement( '"+id+"' )", this.delayTime );
	return;
}

PopMenu.HideElement = function( id ) {
	this.SetDisplay( this.currentShowing, 'none' );
	this.currentShowing = null;
}

PopMenu.SetDisplay = function( id, value ) {
	this.currentTimer = null;
	this.SetCSS( id, 'display', value );
	return;
} 

PopMenu.SetCursor = function( id, value ) {
	this.SetCSS( id, 'cursor', value );
}

PopMenu.SetCSS = function( id, attribute, value ) {
	
	try{
		// ie hack:
		// for proper browsers use: setProperty
		// for ie use: setAttribute
		if ( document.getElementById(id).style.setProperty ) {
			document.getElementById(id).style.setProperty( attribute, value, null );
		}else if ( document.getElementById(id).style.setAttribute )  {
			document.getElementById(id).style.setAttribute( attribute, value );
		}
	}
	catch( Error ) {
		//alert( Error.description );
	}
	return;
}

PopMenu.ClearTimer = function() {
	if ( null != this.currentTimer ) {
		clearTimeout( this.currentTimer );
	}
	this.currentTimer = null;
	return;
}
