// JavaScript Document

/*
This code is based on a code example from the article "Javascript navigation - cleaner, not meaner" by Christian Heilmann
URL: http://www.evolt.org/article/Javascript_navigation_cleaner_not_meaner/17/60273/index.html
Modified by Christa Dickson
*/

function show(s) {
	var id = s.href.match(/#(\w.+)/)[1];
	hideAll();
	document.getElementById(id).style.display = 'block';
	s.innerHTML = "Contents &uarr;";
	//s.onclick = function() {
	//	hide(this); return false;
	//}
}

function hide(s) {
	var id = s.href.match(/#(\w.+)/)[1];
	document.getElementById(id).style.display = 'none';
	s.innerHTML = "Contents &darr;";
	s.onclick = function() {
		show(this); return false;
	}
}
document.write("<style type=\"text/css\"> .hidden{ display: none; } </style>");

function hideAll() {
	var things = document.getElementsByTagName("div");
	for (var i=0; i < things.length; i++) {
		var thing = things[i];
		var thisclass = thing.className;
		if ((thisclass.indexOf("hidden") != -1)) {
			thing.style.display = 'none';
		}
		if ((thisclass.indexOf("instruction") != -1)) {
			thing.className = 'hidden';
		}
	}
}



// This script pops up all external links in a new window.
function popLinks(){
  var serverone = document.location.hostname;
  // Enter an additional domain that you DON'T want in new windows here 
  //var servertwo = "http://www.websiteurlhere.com";
  
  if (!document.getElementsByTagName) return null;
  var anchors = document.getElementsByTagName("a");
  for(var i=0; i < anchors.length; i++){
    var a = anchors[i];
    var href = a.href;
    if ((href.indexOf("http") != -1) && (href.indexOf(serverone) == -1)) { 
	  a.setAttribute("title","This link will open in a new window.");  
	  
	  // Change the width/height of the popup window below, if you wish
	  a.onclick = function() { window.open(this.getAttribute('href'), "popUp", "toolbar,location,resizable,scrollbars,width=500,height=400"); return false; }
    }
  }
}


// This script pops up all .pdf files and any href with 'class="new_win"' in a new window.
function newWin(){
  var serverone = document.location.hostname;
  // Enter an additional domain that you DON'T want in new windows here 
  //var servertwo = "http://www.websiteurlhere.com";
  
  if (!document.getElementsByTagName) return null;
  var anchors = document.getElementsByTagName("a");
  for(var i=0; i < anchors.length; i++){
    var a = anchors[i];
    var href = a.href;
	var thisClass = a.className;
    if ((thisClass.indexOf("new_win") != -1) || (href.indexOf(".pdf") != -1))  { 
	  a.setAttribute("title","This link will open in a new window.");  
	  
	  // Change the width/height of the popup window below, if you wish
	  a.onclick = function() { window.open(this.getAttribute('href'), "popUp", "toolbar,location,resizable,scrollbars,width=500,height=400"); return false; }
    }
  }
}


// Function to allow multiple onload functions to be called
function multipleOnload()
{
// Add multiple Onload functions to the list below
popLinks();
newWin();
}
window.onload = multipleOnload;
// end function