/*
	jsLOG: Provides logging functionality for javascript.
	Constructor parameters:
		- param_newwindow (boolean) : if logging is displayed in a new window, if not, pop-ups will be shown.
		- param_active (boolean)  : if logging is activated
*/

var VAR_LOG_COUNTER = 1;

function jsLOG(param_active, param_newwindow) {

	// Public data fields
	this.enabled = param_active;
	this.newWindow = param_newwindow;
	this.logWindow = null;

	// Methods

	// log : Displays the log line in the log.
	function jsLOG_log(param_logline) {
		if ( this.enabled == true ) {
			if ( this.newWindow == true ) {
				if ( this.logWindow ) {
				} else {
					this.createWindow();
				}
				this.logWindow.document.writeln ('<xmp>' + param_logline + '</xmp>---<BR>');
			} else {
				window.alert ( param_logline );
			}
		}
	}
	this.log = jsLOG_log;

	// createWindow : Creates the log window.
	function jsLOG_createWindow() {
		if ( (this.enabled == true)  && (this.newWindow == true) ) {
			var name = 'LogNum' + VAR_LOG_COUNTER;
			VAR_LOG_COUNTER = VAR_LOG_COUNTER + 1;
			this.logWindow = window.open ('', name, 'dependent=yes,menubar=no,resizable=yes,toolbar=no,scrollbars=yes');
		}
	}
	this.createWindow = jsLOG_createWindow;

	// enable : enables the log
	function jsLOG_enable () {
		this.enabled = true;
	}
	this.enable = jsLOG_enable;

	// disable : disables the log
	function jsLOG_disable () {
		this.enabled = false;
		if ( this.logWindow ) {
			this.logWindow.close();
		}
	}
	this.disable = jsLOG_disable;

	// init : Initializes the log
	function jsLOG_init() {
		if ( ( this.enabled == true ) && (this.newWindow == true) ) {
			this.createWindow();
		}
	}
	this.init = jsLOG_init;

	// Initialize the log.
	this.init();
}

