// JavaScript Document

function IMSLib() {

	function onLoadInitialize () {
		var codeToRun = [];
		var add = function ( c ) {
			codeToRun.push( c );
		}
		var run = function ( ) {
			for(var i=0; i < codeToRun.length; i++) {
				if( typeof(codeToRun[i])=='function')
					codeToRun[i]();
				else {
					try { eval(codeToRun[i]); }
					catch( exc ) { 'Note: some error occurred!'; }
				}
			}
		}
		this.add = add;
		this.run = run;
		this.code = codeToRun;

		return this;
	}

	this.onload = onLoadInitialize();
}
IMSLibObject = new IMSLib;
IMS_Onload = IMSLibObject.onload;

// Test the OnLoad feature
if (location.search.search(/testOnLoad/i) > 0 ) {
	IMS_Onload.add( function () { alert('testing... onload'); } );
	alert("IMS_Onload is of type '" + typeof(IMS_Onload) + "'.\n" + (typeof(IMS_Onload) != 'undefined' ? 'The code to run on-load is: ' + ( IMS_Onload.code.length ? "\n----\n"+IMS_Onload.code.join("\n----") : '[empty]') : ''));
}