/* ---    insertAfter and addClass --------
	by JEREMY KEITH 
	http://www.adactio.com
-----------------------------------*/

function insertAfter(newElement, targetElement){
	var parent = targetElement.parentNode;
	if(parent.lastChild == targetElement){parent.appendChild(newElement);}else{
		parent.insertBefore(newElement, targetElement.nextSibling);
	}
}

function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= " ";
    newClassName+= value;
    element.className = newClassName;
  }
}

/* end scripts by JK */ 


/* -----    addLoadEvent -----
	by SIMON WILLISON
	http://simon.incutio.com
-----------------------------------*/

function addLoadEvent(func){
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){ 
		window.onload = func;
	}else{
		window.onload = function(){
			oldonload();
			func();
		}
	}
}

/* end scripts by SW */



/* -----    getElementsByClassName  -----
	by SCOTT SCHILLER
	http://www.schillmania.com
-----------------------------------*/

function getElementsByClassName(className,oParent) {
  var doc = (oParent||document);
  var matches = [];
  var nodes = doc.all||doc.getElementsByTagName('*');
  for (var i=0; i<nodes.length; i++) {
    if (nodes[i].className == className || nodes[i].className.indexOf(className)+1 || nodes[i].className.indexOf(className+' ')+1 || nodes[i].className.indexOf(' '+className)+1) {
      matches[matches.length] = nodes[i];
    }
  }
  return matches; // kids, don't play with fire. ;)
}

/* end scripts by SS */