// JavaScript Document
<!--

function externalWrite( str )
{
	document.write( str );
}

function getElement( id, doc )
{
	doc = doc ? doc : document ;
	var x = null;
	
	if( doc.getElementById )
	{
		x = doc.getElementById( id );
	}
	else if( !( x = doc[id] ) && doc.all )
	{
		x = doc.all[id];
	}
	
	return x;
}

//ideally, you could keep on calling this, and add more onload funcs..
function setOnload( func )
{
	if( !window.onload )
	{
		var init = function ( e )
		{
			// quit if this function has already been called
			if (arguments.callee.done)
			{
				return;
			}
			// flag this function so we don't do the same thing twice
			arguments.callee.done = true;
			
			// kill the timer
			if (_timer) clearInterval(_timer);
			
			// call your onload function
			var funcs = arguments.callee.funcs;
			for( var i = 0; i < funcs.length; ++i )
			{
				funcs[i].func.apply( window, funcs[i].args );
			}
		};
		
		init.funcs = [];
		
		//init.func = func;
		//init.args = addArgs;
		
		/* for Mozilla/Opera9 */
		if( window.addEventListener )
		{
			window.addEventListener( "DOMContentLoaded", init, false );
			window.addEventListener( 'pageshow', init, false );
			window.addEventListener( 'pagehide', function(){ init.done = false; }, false );
		}
		else if(  document.addEventListener )
		{
			document.addEventListener( "DOMContentLoaded", init, false );
		}
		
		/* for Internet Explorer */
		/*@cc_on @*/
		/*@if (@_win32)
		  document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
		  var script = document.getElementById("__ie_onload");
		  script.onreadystatechange = function() {
			if (this.readyState == "complete") {
			  init(); // call the onload handler
			}
		  };
		/*@end @*/
		
		/* for Safari */
		if (/WebKit/i.test(navigator.userAgent))// sniff
		{ 
			var timerFunc = function()
			{
				if (/loaded|complete/.test(document.readyState))
				{
					argument.callee.init(); // call the onload handler
				}
			}
			
			timerFunc.init = init;
			
			var _timer = setInterval( timerFunc, 10 );
		}
	}
	else
	{
		var init = window.onload;
	}
	
	var addArgs = [];
		
	for( var i = 1; i < arguments.length; ++i )
	{
		addArgs.push( arguments[i] );
	}
	
	//record function
	init.funcs.push( { func:func, args: addArgs } );
	
	/* for other browsers */
	window.onload = init;
}