// GLOBAL FUNCTIONS
// (add functionality to the DOM scripts I use)

// addLoadEvent - used to add multiple events to the window.onload method
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// getNextElement - gets the next element (usually want to supply it with node.nextSibling to get it to work)
function getNextElement(node) {
	if(node.nodeType == 1) {
		return node;
	}
	if (node.nextSibling) {
		return getNextElement(node.nextSibling);
	}
	return null;
}

// addClass - adds the class name given to the element *in addition* to any existing classes
function addClass(element,value) {
	// if element doesn't have a class name then just add the value as class name
	if (!element.className) {
		element.className = value;
	// otherwise concatenate the value as a class name to existing class name(s)
	} else {
		var newclassname = element.className;
		newclassname += " ";
		newclassname += value;
		element.className = newclassname;
	}
}