/*
____________________________________________________________
| Log Class v1.0
|
| 1. Include this JS file in the frameset.
| 2. Above the include create the following global
|    variable, which toggles between javascript alerts and
|    using the debug log window:
|	 var _useLog 	= true;
| 3. Below the include, start the log class:
|	log.start(_useLog);
|
|
| Example call:  if(_DebugLMS){log.write("debug message here.", "JSfilename");}
|
|
| Last updated: 5/18/04 (ejf)
|____________________________________________________________

*/

//------------------------------------------
//-Create global instance of the log class
var log	= new logClass();

//******************************************
//* LOG CLASS
//******************************************
function logClass()
{
	this.target;				//-textarea to write to in the debug window
	this.useLog = true;			//-use debug window or javascript alerts?
}

logClass.prototype.start = startclass;
logClass.prototype.write = sendTo;		//-called from courseware


//------------------------------------------
function startclass(showLogWin)
{
	this.useLog = showLogWin;

	if(this.useLog)
	{
		this.target = debugframe.document.all.displayLog;
	}
}

//------------------------------------------
//-Called from courseware, organizes message information
//
//-Parameters:
//-	arguments[0]	= debug message string
//-	arguments[1]	= filename
//
function sendTo()
{
	if(arguments.length>0)
	{
		var sFilename 	= "";
		var sFunction 	= "";
		var txt	 		= "";

		//-Get filename
		if(arguments.length>1){sFilename = arguments[1];}

		//-Get function
		sFunction = arguments.caller.callee.toString().match(/function (\w*)/)[1]+"()";

		//-Send formatted debug information
		if(this.useLog)
		{
			txt	 		+= "*****************************************************************************\r\n";
			txt	 		+= "Filename:   "+sFilename+"\r\n";
			txt	 		+= "Function:   "+sFunction+"\r\n";
			txt	 		+= arguments[0];
			txt	 		+= "\r\n\r\n";

			this.target.value 	= this.target.value + txt;
		}
		else
		{
			//-Alert popup
			txt 		=  "DEBUG INFORMATION\r\n";
			txt 		+=  "******************************************************\r\n";
			txt			+= "Filename:     "+sFilename+"\r\n";
			txt			+= "Function:     "+sFunction+"\r\n";
			txt			+= "******************************************************\r\n\r\n\r\n";
			txt			+= arguments[0];

			alert(txt);
		}
	}
}

