
var msgBox =
{
	contentsObj: null,
	isVisible: false,
	
	init: function()
	{
		this.contentsObj = $('msgBoxContents');
	},
	
	confirm: function(msg)
	{
		return confirm(msg);
	},
	
	alert: function(msg)
	{
		return alert(msg);
	},
	
	wait: function(link)
	{
		
	},
	
	display: function( msg)
	{
		if(this.isVisible)
		{
			this.contentsObj.innerHTML = msg;
			return;
		}
		
		hideSelectBoxes();
		hideFlash();
		var arrayPageSize = getPageSize();
		Element.setWidth('overlay', arrayPageSize[0]);
		Element.setHeight('overlay', arrayPageSize[1]);

		new Effect.Appear('overlay', { duration: 0.5, from: 0.0, to: 0.8 });
		
		// calculate top and left offset for the msgBox 
		var arrayPageScroll = getPageScroll();
		var msgBoxTop = ((arrayPageSize[3]-200) / 2) + arrayPageScroll[1];
		
		Element.setTop('msgBox', msgBoxTop);
		Element.setLeft('msgBox', (arrayPageSize[0]-600)/2);
		
		this.contentsObj.innerHTML = msg;
		
		Element.show('msgBox');
		this.isVisible = true;
	},
	
	hidde: function()
	{
		Element.hide('msgBox');
		new Effect.Fade('overlay', { duration: 0.5});
		this.contentsObj.innerHTML = '';
		showSelectBoxes();
		showFlash();
		this.isVisible = false;
	},
	
	show: function( msg, exec, showTime, execTime)	
	{
		if(!showTime)
			showTime = 1.5;
		
		this.display(msg);
		
		if(!execTime)
			execTime = 0.5;
		if(exec)
			setTimeout(exec, execTime*1000);
		
		setTimeout( function() { msgBox.hidde(); }, showTime*1000);
	},
	
	errorMsg: function( msg, exec, showTime, execTime)
	{
		this.show( '<div class="errorMsg">'+msg+'</div>', exec, showTime, execTime);
	},
	
	successMsg: function(msg, exec, showTime, execTime)
	{
		this.show( '<div class="successMsg">'+msg+'</div>', exec, showTime, execTime);
	},
	
	showMsg: function(msg, exec, showTime, execTime)
	{
		this.show( '<div class="dialogMsg">'+msg+'</div>', exec, showTime, execTime);
	}
	
};

