/*
** Function to make external or image anchors open in a new window
*/
function setExternalLinks() {
	if (document.getElementsByTagName) {
		var AnchorArray = document.getElementsByTagName("a");

		for (var i = 0; i < AnchorArray.length; i++) {

			if (AnchorArray[i].getAttribute("href") && AnchorArray[i].getAttribute("rel") == "external") {
				AnchorArray[i].target = "_new";
				AnchorArray[i].className += " externallink";
			}

			if (
				AnchorArray[i].getAttribute("href")
				&& AnchorArray[i].getAttribute("rel")
				&& AnchorArray[i].getAttribute("rel").substring(0,5) == "other"
			)
				if (AnchorArray[i].getAttribute("rel").length > 6)
					AnchorArray[i].target = AnchorArray[i].getAttribute("rel").substring(6,60);
				else
					AnchorArray[i].target = "_new";

			if (AnchorArray[i].getAttribute("href") && AnchorArray[i].getAttribute("rel") == "image")
				AnchorArray[i].target = "_new";
		}
	}
}

/*
** IE6 popup menu code from http://www.csscreator.com/menu/multimenu.php
*/
function activateDropDown(ULID) {
	if (document.getElementById(ULID)) {

		if (document.all && document.getElementById(ULID).currentStyle) {  
			var navroot = document.getElementById(ULID);
	
			/* Get all the list items within the menu */
			var lis=navroot.getElementsByTagName("LI");  
			for (i=0; i<lis.length; i++) {
	
				/* If the LI has another menu level */
				if(lis[i].lastChild.tagName=="UL"){
					lis[i].onmouseover=function() {this.lastChild.style.display="block";}
					lis[i].onmouseout=function() {this.lastChild.style.display="none";}
				}
			}
		}

	}
}

/*
** Previous version of the dropdown function - kept here for backwards compatibility
*/
function activateMenu() {
	activateDropDown('navigation');
}

/*
** Function to set the focus to the quick search bar when someone clicks one of the radio btns
*/
function quickSearchFocus() {
	SearchForm = document.getElementById("quicksearchform");
	SearchForm.q.focus();
	if (SearchForm.q.value == "SEARCH UWF")
		SearchForm.q.value = "";
}

/*
** Function to rotate header images every few seconds
*/
function rotateHeaderImage(ImgObjectID,Delay,CurrentImage,TotalImages,FilenamePrefix) {
	var ParamString = "rotateHeaderImage('" + ImgObjectID + "'," + Delay + "," 
		+ (CurrentImage+1) % TotalImages
		+ "," + TotalImages + ",'" + FilenamePrefix + "')";
		
	document.getElementById(ImgObjectID).src = FilenamePrefix + (CurrentImage % TotalImages) + ".jpg";
	
	self.setTimeout(ParamString, Delay*1000);
}
