/*

This is a very handy function written by Simon Willison:
http://simon.incutio.com/archive/2004/05/26/addLoadEvent

It allows you to queue up a whole series of events to be triggered when the document loads.

If you simply use window.onload = func, then you run the risk of overwriting existing functions that are supposed to run when the onload event is triggered.

*/

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}


/*

insertAfter is something that should really be part of the DOM.
It works just like insertBefore:
the first argument is the new element you've created,
the second argument is where you want it to go.

*/

function insertAfter(newelement,existingelement) {
	var parentelement = existingelement.parentNode;
	if (parentelement.lastChild == existingelement) {
		return parentelement.appendChild(newelement);
	} else {
		return parentelement.insertBefore(newelement,existingelement.nextSibling);

	}
}