window.onload = function() {
	init(); // init can be considered special, and is called at load
}

function init() {
	var linksArray = new Array();
	if (!document.getElementsByTagName){ return; }
	anchors = document.getElementsByTagName("a");
	// loop through all anchor tags
	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "nav")){
			anchor.onmouseover = function () {activateNav(this); return false;}
			anchor.onmouseout = function () {deactivateNav(this); return false;}
		}
	}
}

function activateNav(linkRef) {
	linkRef.oldClass = linkRef.className;
	var newClass = ' nav_' + linkRef.oldClass + '_hover';
	linkRef.className += newClass;
	if(linkRef.getAttribute('title')) {
		var textField = linkRef.oldClass + '_text';
		if(document.getElementById(textField)) {
			document.getElementById(textField).innerHTML = linkRef.getAttribute("title");
		}
	}
	for(var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if(anchor.className == linkRef.oldClass) {
			anchor.oldClass = anchor.className;
			anchor.className += newClass;
			if(anchor.getAttribute('title')) {
				var textField = anchor.oldClass + '_text';
				document.getElementById(textField).innerHTML = anchor.getAttribute("title");
			}
		}
	}
}

function deactivateNav(linkRef) {
	linkRef.className = linkRef.oldClass;
	var textField = linkRef.className + '_text';
	if(document.getElementById(textField)) { document.getElementById(textField).innerHTML = '' };
	for(var i=0; i<anchors.length; i++) {
			if(anchors[i].oldClass == linkRef.className && anchors[i] != linkRef) {
				anchors[i].className = anchors[i].oldClass;
			}
		}
}

function popUpVideo() {
	// <a href="javascript:popUpVideo('$Video','$Name');"></a>
	// opens up a sub window to display a movie or images in a next/previous style
	var search_string="";

	/*if(popUpWin) {
		if(!popUpWin.closed) popUpWin.close();
	}*/

	for (dex=0; dex < arguments.length; dex++) {
		arg = arguments[dex];
		LCarg = arg.toLowerCase();
		if (LCarg.indexOf(".mov") > 0) {
			search_string = search_string + "movie=" + arg + "&";
		} else {
			search_string = search_string + "caption=" + escape(arg) + "&";
		}
	}
	search_string = search_string + "count=" + dex;
	
	popUpWin = open('popup_video.php?'+search_string, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes,copyhistory=no,width=400,height=370');
}