// JavaScript Document
function setupRollover(){
	if(!document.getElementsByTagName)
		return;
	var links_array = document.getElementsByTagName('a');
	for (var i=0; i<links_array.length; i++){
		var lnk = links_array[i];
		if(lnk.className && (' ' + lnk.className + ' ').indexOf(' rollover ') != -1){
			if(lnk.childNodes && lnk.childNodes.length == 1 && lnk.childNodes[0].nodeName.toLowerCase() == 'img'){
				lnk.onmouseover = mouseover;
				lnk.onmouseout = mouseout;
			}
		}
	}
}

function findTarget(elt){
	var target;
	
	if(window.event && window.event.srcElement)
		target = window.event.srcElement;
	else if(elt && elt.target)
		target = elt.target;
	if(!target)
		return null;
		
	while(target != document.body && target.nodeName.toLowerCase() != 'a')
		target = target.parentNode;
	
	if(target.nodeName.toLowerCase() != 'a')
		return null;
	
	return target;
}

function mouseover(elt){
	var target = findTarget(elt);
	if(!target) return;
	
	var img_tag = target.childNodes[0];
	
	img_tag.src = img_tag.src.replace(/(\.[^.]+)$/, '_over$1');
}

function mouseout(elt){
	var target = findTarget(elt);
	if(!target) return;
	
	var img_tag = target.childNodes[0];
	
	img_tag.src = img_tag.src.replace(/_over(\.[^.]+)$/, '$1');
}

// menu for IE
startList = function() {
if (document.all&&document.getElementById) {
	navRoot = document.getElementById("nav");
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
				this.className+=" over";
  			}
  			node.onmouseout=function() {
  				this.className=this.className.replace(" over", "");
   			}
   		}
  	}
}
}

/** separate function to reveal faqs **/
hideAnswers = function() {
qs = document.getElementsByTagName("UL");
for(i=0; i<qs.length; i++){
  	if(qs[i].hasChildNodes){
		for(j=0; j<qs[i].childNodes.length; j++){
			node = qs[i].childNodes[j];
			if(node.nodeName=="LI"){
			  	for(k=0; k<node.childNodes.length; k++){
			  		ans = node.childNodes[k];
					if(ans.className=="qs"){
					  ans.title = 'Reveal Answer';
					}
				    if(ans.nodeName=="DIV"){
					  ans.style.display = 'none';
					  ans.style.border = '1px #F3F3F3 solid';
					  ans.style.width = '490px';
					  ans.style.padding = '5px';
					  ans.style.background = '#F3F3F3';
					}
				}
			}
		}
	}
}
}
function revealAnswer(id){
  ansdiv = document.getElementById('answer'+id);
  qlink = document.getElementById('question'+id);
  if(ansdiv.style.display == 'block'){
    ansdiv.style.display = 'none';
    qlink.title = 'Reveal Answer';
  } else {
    ansdiv.style.display = 'block';
    qlink.title = 'Close Answer';
  }
}


function getPopupWindow(thefile,thename){
  	mywin = window.open(thefile,thename,'width=840,height=600,left=100,top=100,resizable=no,toolbar=no,status=no,scrollbars=yes');
  	mywin.document.close();
}

function getCalendar(){
	mywin = window.open('calendar.php','Calendar','width=720, height=650, left=100, top=100, resizable=no, toolbar=no, status=no, scrollbars=yes, location=no, toolbar=no');
	mywin.document.close();
}

window.onload = function(){
	setupRollover();
	startList();
	hideAnswers();
}