/** ===============================================================================================
 *	addLoadEvent
 *
 *  Adds a function to the window.onLoad event.  Based on code from:
 *  http://simonwillison.net/2004/May/26/addLoadEvent/ 
 *  ===============================================================================================
 */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/** ===============================================================================================
 *	addUnloadEvent
 *
 *  Adds a function to the window.onUnload event.  Based on code from:
 *  http://simonwillison.net/2004/May/26/addLoadEvent/ 
 *  ===============================================================================================
 */
function addUnloadEvent(func) {
	var oldonunload = window.onunload;
	if (typeof window.onunload != 'function') {
		window.onunload = func;
	} else {
		window.onunload = function() {
			oldonunload();
			func();
		}
	}
}

/** ===============================================================================================
 *	Configure onload/onunload events
 *
 *  Here is where we define our onload/onunload events for our application.  If you don't require
 *  a function, just comment it out (please don't remove it just incase someone else requires the
 *  function at a later date). 
 *  ===============================================================================================
 */

// onLoad Events
addLoadEvent(externalLinks);			// New windows for external link
addLoadEvent(stylesheetLoad); 		// Stylesheet switcher (for font controls)
//addLoadEvent(prepareMenu);				// On clicks for our menus
addLoadEvent(focusGeneralSearch);	// Give focus to the search box if present
addLoadEvent(hideElements);
addLoadEvent(displaylinks);

// IE Only onLoad
if (window.attachEvent) {
	addLoadEvent(sfHover);					// Son of Suckerfish CSS menu
}

// onUnload Events
addUnloadEvent(stylesheetUnload);	// Stylesheet switcher (for font controls)