/**
 * base.js
 * 
 * Collection of boilerplate/common functions.
 * @author Stefan T. 
 * @version 1.0 
 */

/**
 * Simon Willison's solution for attaching multiple functions 
 * to the window.onload() event handler
 * 
 * @see http://simonwillison.net/2004/May/26/addLoadEvent/
 * @param Function func - the function to attach to the window.onload() event
 */
function addLoadEvent (func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

/**
 * stops event propagation and prevents default action for a given event
 * @param {Event} event The event to cancel
 * @see http://www.openjs.com/articles/prevent_default_action/
 */
function stopEvent (event) {
	if ('function' === typeof event.preventDefault) {
		event.preventDefault();
		event.stopPropagation();
	} else {
		event.returnValue = false;
		event.cancelBubble = true;
	}
}
