/**
* Call to prepare external links
* Place here so you don't forget to add it!
*/
addLoadEvent(prepareExternalLinks);

/**
* addLoadEvent
* @author Simon Willison - http://simon.incutio.com/
*
* Accepts a function name and stacks the "window.onload" even
*/
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

/**
* prepareExternalLinks
* @author Peter McWilliams - http://www.augustash.com/
*
* Checks the document for all link nodes with a class name "external"
* and opens them in a new window
*/
function prepareExternalLinks() {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	var links = document.getElementsByTagName('a');
	for (var i=0; i<links.length; i++) {
		if (links[i].className == "external") {
		//if (links[i].getAttribute("class") == "external") {
			links[i].onclick = function() {
				popUp(this.getAttribute("href"), "external", "");
				return false;
			}
		}
	}
}

/**
* popUp
*
* The same old popup function that is always used!
*/
function popUp(url, name, features) {
	window.open(url, name, features);
	return false;
}

/* Son of Suckerfish drop down menu - http://www.htmldog.com */
sfHover = function() {
  if (!document.getElementById("nav")) { return; }
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
