var pageMode = "assessing"

/*
This page can either run automatically based on what month it is, 
or can be set to display a particular message.

Possible values for the pageMode variable (above) are:
	pending: pending
	current: currently recruiting
	assessing: being assessed
	interviews: scheduling/conducting interviews
	interviewcomplete: interviews complete
	eligibility: eligibility list underway
	filled: all positions filled
	
	auto: automatically update the page to one of the
		above, based on the current date.
	
	all: debug mode, show everything simultaneously
*/


/*source code originally from http://www.bobbyvandersluis.com/articles/unobtrusiveshowhide.php */

if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
	window.onload = initShowHide;
}

function initShowHide() {
	// Hide the container with all toggleable elements 
	//document.getElementById('contentPool').style.display = 'none';

	var as = document.getElementById('toggle').getElementsByTagName('a');
	
	for (var i = 0; i < as.length; i++) {
		as[i].onclick = function() {
			showClick(this);
			return false;
		}
	}


}


function showClick(l) {
	var id = l.href.match(/#(\w.+)/)[1];
	show(id);
}

var contentPool = document.getElementById('contentPool')

function show(s) {
	//alert ("Showing " + s)
	hide();
	//document.getElementById(s).style.display = 'block';
	//contentPool.getElementById(s).style.display = 'block';
	
	// Get a reference to all the div elements from the content pool
	var divs = document.getElementById('contentPool').getElementsByTagName('div');
	// Show all the divs from the content pool that have the same category classname assigned 
	for (var i = 0; i < divs.length; i++) {
		if (divs[i].className.indexOf(s) != -1) {
			divs[i].style.display = 'block';
			// Within the div, hide all debug paragraphs, unless we are in "all" mode
			if (s != 'all') {
				// Hide the menu
				document.getElementById('toggle').style.display = 'none';
				var ps = divs[i].getElementsByTagName('p');
				for (var j=0; j < ps.length; j++) {
					if ( ps[j].className.indexOf('debug') != -1) {
						// this is a debug paragraph
						ps[j].style.display = 'none';
					} else {
						// this is not a debug para
					}
					
					
				}
			} else {
			// This is "all" - show the menu
			document.getElementById('toggle').style.display = 'block';
			}
			
		}
	}
	document.getElementById('contentPool').style.display = 'block';
	
}

function hide() {
	var toggleable = document.getElementById('contentPool').getElementsByTagName('div');
	for (var i = 0; i < toggleable.length; i++) {
		toggleable[i].style.display = 'none';
	}
}

function showPageContent() {
	var month=new Array(12)
	month[0] ="Jan"
	month[1] ="Feb"
	month[2] ="Mar"
	month[3] ="Apr"
	month[4] ="May"
	month[5] ="Jun"
	month[6] ="Jul"
	month[7] ="Aug"
	month[8] ="Sep"
	month[9] ="Oct"
	month[10]="Nov"
	month[11]="Dec"

	// Display the current month's update.
	var m = new Date().getMonth()

	// To display a particular month (user-entered) for debugging, 
	// uncomment the next line.
	//m = prompt("Enter a number from 1 to 12 (month number)") - 1

	
	//show ('msg' + month[m]) // automatic timed updates
	//show ('current') // currently accepting applications	
	//show ('pending') // will soon be accepting applications	
	//show ('all') // show everything, for editing & debug.

	switch (pageMode) {
		case "auto": show ('msg' + month[m]); break;
		default: show(pageMode);break;
		}
	
}

