
/* Naming standards:

		Please prefix functions and variable names defined here
		with an underscore so as to differentiate them from
		local-page defined functions and variables.
*/
/* Note:

		The webapp employing this lib must put the following within the HTML Head:
		
			script language="JavaScript" src="scriptname" script
		
		To have arbitrary JavaScript execute upon the completion of page loading
			modify the HTML Body like so:
			
			body onLoad="_init()"
			
		You may:
			~ put globally-executing code here, in this lib's _init() function
				and then call a local-page function.
			~ define a local-page function BY THE SAME CASE-SENSITIVE NAME as one
				defined here and the effect will be to Override This Global function.

*/

// Global variables
var _console = null; // Used by _debug()
var _debugState = false; // Used to conditionally display debug messages; e.g. see _testDebugWindow()
var undefined; // Do not set a value! Use in case the browser's implementation fails to provide 'undefined'.


// Functions

// Typically called on HTML page unload initiation
function _cleanup() { // Do nothing, purposefully
    // This function will be overridden by any locally defined one
	//alert('Global function _cleanup() called.');
}

// Provide HTML-rendered debug output
function _debug(msg) {
    // Open a window the first time we are called, or after an existing
    // console window has been closed
    if ((_console == null) || (_console.closed)) {
        _console = window.open("","console","width=600,height=300,scrollbars=yes,resizable");
        // Open a document in the window to display plain text
        _console.document.open("text/plain");
    }
    _console.focus();               // Make the window visible
    _console.document.writeln(msg); // Output the message to it
    // Note: We purposely do not call close(). Leaving the document
    // open allows us to append to it later.
}

// Typically called on HTML page load completion
function _init() { // Do nothing, purposefully
    // This function will be overridden by any locally defined one
    //alert('Global function _init() called.');
	_localInit();
}

// Typically called on HTML page load completion by _init()
function _localInit() { // Do nothing, purposefully
    // This function will be overridden by any locally defined one
    //alert('Global function _localInit() called.');
}

// Limit HTML textbox input to numbers only using the 'onKeyPress' event, IE-specific?
function _numbersOnly() {
	if ( window.event.keyCode > 57 | window.event.keyCode < 48)
	{ window.event.returnValue=false }
}
		
// _testDebugWindow()
function _testDebugWindow() { 
	if (_debugState) { _debug('testing debuggery...') }
}

// _setDebugON
function _setDebugStateON() {
    _debugState = true;
}

// _setDebugOFF
function _setDebugStateOFF() {
    _debugState = false;
}









