///////////////////////////////////////////
//
//  Adaptation by swummoq.net of the 
//  Generic onload functions by Brothercake
//  original by: http://www.brothercake.com/
//
///////////////////////////////////////////

/*
create a global function you want to be called onLoad
then pass that function to the GenericOnLoad constructor
like this:
function myOnLoad ()
{
	alert ('loaded!');
}

var GOL = new GenericOnLoad (myOnLoad);
*/

var GenericOnLoad = Class.create();
GenericOnLoad.prototype =
{
	initialize: function (loadFunc)
	{
		window.loadFunc = loadFunc;
		//setup onload function
		if(typeof window.addEventListener != 'undefined')
		{
			//.. gecko, safari, konqueror and standard
			window.addEventListener('load', this.generic, false);
		}
		else if(typeof document.addEventListener != 'undefined')
		{
			//.. opera 7
			document.addEventListener('load', this.generic, false);
		}
		else if(typeof window.attachEvent != 'undefined')
		{
			//.. win/ie
			window.attachEvent('onload', this.generic);
		}
		
		//** remove this condition to degrade older browsers
		else
		{
			//.. mac/ie5 and anything else that gets this far
			
			//if there's an existing onload function
			if(typeof window.onload == 'function')
			{
				//store it
				var existing = onload;
				
				//add new onload handler
				window.onload = function()
				{
					//call existing onload function
					existing();
					
					//call generic onload function
					this.generic();
				};
			}
			else
			{
				//setup onload function
				window.onload = generic;
			}
		}
	},
	generic: function ()
	{
		window.loadFunc.call();
	}
}
