/**
* @file common.rdebug.js
* @author Rach
* @date 05/19/2010
*
* A small set of functions to use in place of alerts in order to
* display a set of information all at once, for use with debugging.
*/

var rErrorMessage = new Array();
var rErrorPresent = false;
var rDebugLog = new Array();
var rDebug = false; // enable to show dialogs
var rDebugIndividual = false; // enable to use like alerts - shows a dialog as soon as something is stored.

/**
* Appends to a list of strings for output later, or
* displays the text given to it in an alert depending on settings.
*
* @param	string	text		String for error/log message
*/
function RD_Append_Log( text )
{
	if ( rDebug )
	{
		if ( rDebugIndividual )
		{
			rDebugLog[ 0 ] = text;
			MD_Display_DebugLog();
		}
		else
		{
			rDebugLog[ rDebugLog.length ] = text + "\n";
		}
	}
}

/**
* Displays all the elements of the log in one long alert, then clears out the log array
*/
function RD_Display_Log()
{
	/*
	if ( rDebug )
	{
		var msg = "DEBUG LOG:\n";
		for ( var i=0; i<rDebugLog.length; i++ )
		{
			msg += "\n" + rDebugLog[i];
		}

		if ( rDebugLog.length != 0 )
			alert( msg );
		RD_Clear_Log();
	}
	*/
}

/**
* Clears out the debug log array
*/
function RD_Clear_Log()
{
	rDebugLog.length = 0;
}

/**
* Turn on/off the debuggin'
*/
function RD_Set_Log( isOn )
{
	rDebug = isOn;
}

/**
* Turn on/off whether to display an alert immediately after something is
* added to the debug log or not, with the latter needing a manual call to
* "RD_Show_Log()".
*/
function RD_Set_Individual( isOn )
{
	rDebugIndividually = isOn;
}






