/*
	JavaScript Library for "The Internet Treehouse"
*/


// Open links with rel="external" HTML attribute in a new window (replaces target="_blank" attribute/value pair)
	function externalLinks() {
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") &&
			anchor.getAttribute("rel") == "external")
			anchor.target = "_blank";
		}
	}

// Original Suckerfish dropdown menu "helper" for Internet Explorer 5/6
	function startList() {
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("menu");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" hover";
					}
					node.onmouseout=function() {
						this.className=this.className.replace(" hover", "");
					}
				}
			}
		}
	}

// Open link with rel="audio" ("The Danplayer") in a new window
	function audioPlayer() {
		if (!document.getElementsByTagName) return;
		var anchors = document.getElementsByTagName("a");
		for (var i=0; i<anchors.length; i++) {	
			if (anchors[i].getAttribute("rel") == "audio") {	
				anchors[i].onclick = function() {	
				openMediaPlayer(this.getAttribute("href"));	
				return false; 	
				} 	
			}
		} 
	}

// Set the size of "The Danplayer" when called
	function openMediaPlayer(linkURL) {
		window.open(linkURL,'audio','width=395,height=240')
	}

// Gather all scripts that require the use of window.onload and call them here (since no more than one window.onload event handler can be used)
	window.onload = function() {
		audioPlayer();
		externalLinks();
		startList();
	}