/////////////////////////////////////////////////////////////////////////////
//
// Gladiator Components
//
// http://www.gladiatorweb.com
//
// (c) 2006 by Edward H. Trager .  All Rights Reserved
//
// NAME: gladiatorAlert.js
//
// DESCRIPTION: Implements a gladiator "alert" window.
//
// AUTHOR: Edward H. Trager
//
// LAST UPDATE: 2006.03.08
//
// NOTE: SEE "LICENSE" FILE FOR LICENSING TERMS
//
//////////////////////////////////////////////////////////////////////////////

//
// DEPENDENCY CHECKING:
//
if(typeof GLADIATOR_CORE_INCLUDED == 'undefined') alert('NOTE BENE: "gladiatorAlert.js" REQUIRES "gladiatorCore.js"!');
if(typeof GLADIATOR_WINDOWS_INCLUDED == 'undefined') alert('NOTE BENE: "gladiatorAlert.js" REQUIRES "gladiatorWindows.js"!');

var GLADIATOR_ALERT_INCLUDED=true;

function gAlert(title,id,left,top,width,height,contents,show,parentNode){
	
	var _width;
	if(width) _width=width;
	else      _width=300;
	
	var _height;
	if(height) _height=height;
	else       _height=170;
	
	var _left;
	if(left) _left=left;
	else     _left=DIMENSIONS.horizontalCenter - 0.5 * _width;
	
	var _top;
	if(top) _top=top;
	else     _top=DIMENSIONS.verticalCenter - 0.5 * _height;

	var _window   = new gWindow(title,id,_left,_top,_width,_height,contents,show,parentNode);
	_window.allowAll(false);
	_window.allowResize(false);
	var _canvas   = _window.getNode();
	var _okButton = document.createElementNS(NS.xhtml,"button");
	var _buttonText = document.createTextNode("OK");
	_okButton.appendChild(_buttonText);
	_okButton.className="gCenteredButton";
	_okButton.addEventListener("click",close,false);
	_canvas.appendChild(_okButton);

	// INSERT MODAL SCREEN:
	var _modalScreen = document.createElementNS(NS.xhtml,"div");
	_modalScreen.className="gModalScreen";
	_modalScreen.style.width  = DIMENSIONS.width  + "px";
	_modalScreen.style.height = DIMENSIONS.height + "px";
	var bodyRef = document.getElementsByTagName("body").item(0);
	bodyRef.appendChild(_modalScreen);

	//
	// close()
	//	
	function close(){
		_window.show(false);
		_modalScreen.style.display="none";
	}
	
	this.show = function(showIt){
		_window.show(showIt);
		if(showIt) _modalScreen.style.display="block";
		else       _modalScreen.style.display="none";
	}
	
	this.getNode = function(){
		
		return _window.getNode()
		
	}
	
	this.addContent = function(contentNode){
		
		_window.addContent(contentNode);
		
	}
	
}

