// Add a OnLoad event to the page
function addLoadEvent( func ) {
	var oldOnLoad = window.onload;
	if ( typeof window.onload != 'function' ) {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldOnLoad();
			func();
		}
	}
}

// Insert an element after the specified element
function insertAfter( newElement, targetElement ) {
	var parent = targetElement.parentNode;
	if ( parent.lastChild == targetElement ) {
		parent.appendChild( newElement );
	}
	else {
		parent.insertBefore( newElement, targetElement.nextSibling );
	}
}

// Dynamically add a CSS class to an element
function addClass( element, newClass ) {
	if ( !element.className ) {
		element.className = newClass;
	}
	else {
		newClassName = element.className;
		newClassName += " ";
		newClassName += newClass;
		element.className = newClassName;
	}
}

// Array prototype, matches value in array: returns bool
Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};