/*----------------------------------------------------------
  Messages Class
  
  
  Basic function:
    * Shows a message text for some seconds
  

  Requires the utilities.js 

  @package NTP
  @author Arnd Beyer, arnd.beyer@wmdata.fi
  @copyright WM-data Novo 2006
  @version $Id: UserSettings.php,v 1.0 2005/07/26 12:44:42 arnd Exp $
  ---------------------------------------------------------*/

/*
*  parameter: objectVariableName String Name of the variable 
*									where the Object will be stored in
*  Used for the setTimeout Function
*/
function Messages(objectVariableName){
	var timerId =null;
	var fader =0;
	
	this.display = display;
	this.hide = hide;
	
	function display(event, divId, text, displayLength){
	    var ev = getEvent(event);
		div = attach(divId);
		if(div != null){
			div.innerHTML = text;
		    div.style.display    = "block";
		    div.style.visibility = "visible";
		    div.style.left = ev.clientX +"px";
		    div.style.top =  ev.clientY +"px";
		    fader =10;
			timerId = setTimeout(objectVariableName + ".hide()", displayLength);
		}
	}

	function hide(){
		if(timerId != null){
			clearTimeout(timerId);
			fader--;
			if(fader > 0 ){			
				if(isIE){
					div.style.filter="alpha(opacity="+fader *10+")";
				}else{
					div.style.MozOpacity=fader/10;
				}
			    timerId = setTimeout(objectVariableName + ".hide()", 100);
			}else{
			    div.style.display    = "none";
			    div.style.visibility = "hidden";
				if(isIE){
					div.style.filter="alpha(opacity=100)";			
				}else{
					div.style.MozOpacity=1;
				}				
				timerId = null;		
			}
		}
	}
}