/*
* Executes Javascript on page load
* From http://simonwillison.net/2004/May/26/addLoadEvent/
* Credit goes to Simon Willison
*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		};
	}
}


/*
* Get elements from class name
* @param class name to check for
* @param root node to start checking from
* @return all elements that match the class name
*/
function GetElementsByClassName(class_name, root_node) {
	//if a default root node isnt given, make it the whole doc
	if (root_node === null) { root_node = document; }
	
	//get all of the nodes within the root node
	var all_elements = root_node.getElementsByTagName('*');

	//scan through the nodes and get nodes that match the class name
	var elements = [];
	
	if (all_elements !== null) {
		for(var i=0, j=0; i < all_elements.length; i++) {
			//test whether the class name exists in the nodes class name
			if (all_elements[i].className.match(class_name)) {
				 elements[j++] = all_elements[i];
			}
		}
	}
	
	//return the elements that matches (if any)
	return elements;
}