// Standardize DOM method
if(document.all && !document.getElementById) {
    document.getElementById = function(id) {
         return document.all[id];
    }
}

// Setup the dynamic JS for the page
setupMenu = function() {

	// Cycle through all of the links on the page
	var links = document.links, link, k=0;
	while(link=links[k++]) {

		// Add '(External Link)' to all links specified with the separateWindow class name.
		// 	(All external links use the onclick function to open in a new window due to the deprication of the target property.)
		if (link.className.match("separateWindow")) {
			link.onclick = function() {
				window.open(this.href);
				return false;
			}
			extraInfo = " (External Link)";
			link.title = link.title + extraInfo;
		}

		// Change links marked with #invalid to display a dialog that the link is unavailable 
		if (link.href.indexOf("#invalid")!=-1) {                                                                           
			link.href = "javascript:alert('This link is not currently available. \\n \\n If your department can contribute to this link, please contact the web administrator. \\n \\n If not, please try again later.');";
			//link.href = "javascript:void(0);";
			link.onclick = "";
			link.title = "(Unavailable Link)";
			link.className = "invalidLink";
		}
			
		// Set the status bar of the browser to display the links tooltip on mouseover
		link.onmouseover = function() {window.status = this.title; this.onclick; return true;}
		link.onmouseout = function() {window.status = ""; return true;}
	}
	
	/*var source;
	source = document.body.innerHTML.replace(/\r|\n|\r\n/g,"");
	source = source.replace(/\s+/gm, " ");
	alert(source);
	document.write(source);*/
}

function showHideTop() {
	var topNavObj = document.getElementById('topPageHalf');
	
	if(topNavObj.className.indexOf("hideElement") == -1) {
		topNavObj.className += " hideElement";
	}
	else {
		topNavObj.className = "";
	}
}

// Initialize the drop down menu
window.onload = setupMenu;
