//<script language="javascript">

var ErrorMsg = new Array();

var WarningMsg = new Array();



function buildError(ImgCol, FontClass, Msg){

	var HTMLStr = "";

	HTMLStr = HTMLStr + "<TR><TD><IMG SRC='/common/gfx/transparent.gif' WIDTH='5' HEIGHT='5' BORDER='0'></TD>";

	HTMLStr = HTMLStr + "<TD><FONT class='" + FontClass + "'>";

	HTMLStr = HTMLStr + Msg + "</FONT></TD></TR>";

	return HTMLStr;

}



function displayError(){

	

	var i, errorType;

	

	//	If no entries in the array, then do not display anything

	if (ErrorMsg.length + WarningMsg.length <= 0)

	{

		return;

	}



	//	If browse supports DIV, then use ErrorDiv section to display error.

	//	Otherwise, use alert boxes.		

	if (document.all && (navigator.platform.indexOf("Mac") == -1)) 

	{

		var errorDiv;

		var HTMLStr;

		if (document.getElementById)

		{

			errorDiv = document.getElementById("errorDivDefault");

		} 

		else 

		{

			errorDiv = document.all.errorDivDefault;

		}

		

		//	Set error type (for border color).  If there is an error, set

		//	border to red.  Otherwise, set to gray.

		if (ErrorMsg.length > 0)

		{

			errorType = 'E';

		}

		else

		{

			errorType = 'W';

		}

				

		//	If there is an error, set border to red.  

		//	Otherwise, set to gray.

		HTMLStr = "";

		

		if (errorType == 'E') 

		{

			HTMLStr = HTMLStr + "<table width='100%' border='1' bordercolor='red'  cellspacing='0' cellpading='1' align='center'>";

		}

		else

		{

			HTMLStr = HTMLStr + "<table width='100%' border='1' cellspacing='0' cellpading='1' align='center'>";

		}

		

		HTMLStr = HTMLStr + "<TR><TD><table width='100%' border='0' cellspacing='0' cellpading='0'>";



		//	Write error messages in red				

		for (i=0;i < ErrorMsg.length;i++)

		{

			HTMLStr = HTMLStr + buildError("<IMG SRC='http://www.companytheatre.ca/gfx/alert.gif'>","labelRed",ErrorMsg[i]);

		}

		

		//	Write warning messages in gray

		for (i=0;i < WarningMsg.length;i++)

		{

			HTMLStr = HTMLStr + buildError("&nbsp;","label",WarningMsg[i]);

		}

		HTMLStr = HTMLStr + "</TABLE></TD></TR>"

		HTMLStr = HTMLStr + "</TABLE>"

		errorDiv.innerHTML += HTMLStr;

	} 

	else

	{

		//	Use alert boxes in Netscape and write each message in 

		//	separate lines.

		var msgString;

		msgString = "";

		for (i=0;i < ErrorMsg.length;i++)

		{

			msgString = msgString + ErrorMsg[i].replace(/<br>/gi,"\n") + "\n\n";

		}

		

		for (i=0;i < WarningMsg.length;i++)

		{

			msgString = msgString + WarningMsg[i].replace(/<br>/gi,"\n") + "\n\n";

		}



		alert(msgString);

	}	



	// Clear the message from the Error and warning array	

	resetErrorArray();	

	

}



/**************************************************************************

'  Purpose: Add entries to Error and Warning Messages arrays.

'   Inputs: msg - error message

'			errorType - 

'				If errorType = 'E', add msg to ErrorMsg array.

'				If errorType = 'W', add msg to WarningMsg array.

'				If 'undefined', set it to 'E'

'			blnShowError - 

'				If 'true', then display the error window at once.

**************************************************************************/

function addError(msg, errorType, blnShowError){

	

	var i;

	

	if (typeof(errorType) == "undefined")

	{

		errorType = 'E';

	}



	if (typeof(blnShowError) == "undefined") 

	{

		blnShowError = true;

	}

	

	//	Add to the proper array

	if (errorType == 'E')

	{

		i = ErrorMsg.length;

		ErrorMsg[i] = msg;

	}

	else

	{

		i = WarningMsg.length;

		WarningMsg[i] = msg;

	}

	

	//	Check to see if errors should be displayed at once

	if (blnShowError == true)

	{

		displayError();

	}

}



function resetErrorArray(){

	ErrorMsg = new Array();

	WarningMsg = new Array();

}



function error(message){

	addError(message, "E", true);

}