/**
* 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
*/
/**
* 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"), "");
				return false;
			}
		}
	}
}
function prepareDetailLinks() {
	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 == "detail") {
		//if (links[i].getAttribute("class") == "external") {
			links[i].onclick = function() {
				popUp(this.getAttribute("href"), "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=480,height=500");
				return false;
			}
		}
	}
}

/**
* popUp
*
* The same old popup function that is always used!
*/
function popUp(url, features) {
	day = new Date();
	id = day.getTime();
	window.open(url, id, features);
}

/**
* toggleDisplay
* @author Public Domain
*
* Toggles the CSS display of an element
* Used in conjunction with the collapseAll function
*/
function toggleDisplay(id) {
	if (!document.getElementsByTagName) return false;
	if (!document.getElementById) return false;
	var obj = document.getElementById(id);
	if (obj.style.display != 'none') {
		obj.style.display = 'none';
	} else {
		obj.style.display = 'block';
	}
}