// -------------------------------------------------------------------------- \\
// WDSTrace.js
// jsLibrary javascript file
// -------------------------------------------------------------------------- \\
//
// -------------------------------------------------------------------------- \\


// -------------------------------------------------------------------------- \\
// WDSTrace
// -------------------------------------------------------------------------- \\
// Class WDSTrace ... constructor
// -------------------------------------------------------------------------- \\
function WDSTrace () {
	// attributes
	this.enable = false;
	
	// methods
	this.init    = WDSTrace_init;
	this.dump    = WDSTrace_dump;
	this.close   = WDSTrace_close;
	this.onError = WDSTrace_onError;
}

var WDSTrace = new WDSTrace();

// -------------------------------------------------------------------------- \\
// WDSTrace_enable
// -------------------------------------------------------------------------- \\
function WDSTrace_init () {
	this.enable = true;
	top.traceWin = window.open("", "WDSDump");
	top.traceWin.document.open();
	top.traceWin.document.writeln("<pre>");
}

// -------------------------------------------------------------------------- \\
// WDSTrace_dump
// -------------------------------------------------------------------------- \\
function WDSTrace_dump (str) {
	try {
		top.traceWin.document.writeln(str);
		top.traceWin.focus();
	} catch (error) {
		if (this.enable) {
			this.init();
		}
	}
}

// -------------------------------------------------------------------------- \\
// WDSTrace_close
// -------------------------------------------------------------------------- \\
function WDSTrace_close () {
	try {
		if (null != top.traceWin) {
			top.traceWin.document.close();
			top.traceWin.close();
			top.traceWin = null;
		}
	} catch (error) {
		return;
	}
}

// -------------------------------------------------------------------------- \\
// WDSTrace_onError
// -------------------------------------------------------------------------- \\
function WDSTrace_onError (err_msg, url, line) {
	this.dumpToWin(document.URL + ': ' + err_msg + ': ' + url + ' at line ' + line);
	return true;
}


