// Declare to make available to multiple pages.
var sections;

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

switchTo = function(now) {
if (document.getElementById(now).className=="off"){
	var sections = ["safety","participation","environmental","reviews","inspections","hearings"];
	for (i=0; i<=5; i++) {
		if (sections[i]!=now){
			Effect.BlindUp(sections[i], {duration: 0.5});
			Effect.Fade(sections[i], {duration: 0.6});
			window.setTimeout ('document.getElementById("'+sections[i]+'").className="off"', 500 );
			document.getElementById(sections[i]+"_button").className="off";
		}
	}
	Effect.BlindDown(now, {duration: 0.5});
	Effect.Appear(now, {duration: 0.7});
	document.getElementById(now).className="on";
	document.getElementById(now+"_button").className="on";
}
}

loadSections = function() {
//	alert("Called loadSections()");
	sections = new Array();
	var i, j;
	j = 0;
	var faq_list = document.getElementById("faq_list");
	if (faq_list != null) {
		for (i=0; i<faq_list.childNodes.length; i++){
			if (faq_list.childNodes[i].nodeName == "DD") {
				sections[j] = faq_list.childNodes[i].id;
				j++;
			}
		}
	}
//	alert("Exiting loadSections() with array length of:" + sections.length);
}

/* Made this function a bit more generic so that you can have any number of questions and answers on a page, but it's still 
dependent on specific class ids (faq_list, q1, q2, q3, etc.) as well as a structure that uses the html definition list -- <dl>. 
See loadSections above. MK 07/11/2008 
*/
switchToFAQ = function(now) {
if (document.getElementById(now).className=="off"){
	if (sections == null || sections.length < 1) {
		loadSections();
	}
/* NOT optimal
	var sections = ["q1","q2","q3","q4","q5","q6", "q7", "q8", "q9", "q10", "q11", "q12"];
*/
	for (i=0; i<sections.length; i++) {
		if (sections[i]!=now){
			Effect.BlindUp(sections[i], {duration: 0.5});
			Effect.Fade(sections[i], {duration: 0.6});
			window.setTimeout ('document.getElementById("'+sections[i]+'").className="off"', 500 );
			document.getElementById(sections[i]+"_button").className="off";
		}
	}
	Effect.BlindDown(now, {duration: 0.5});
	Effect.Appear(now, {duration: 0.7});
	document.getElementById(now).className="on";
	document.getElementById(now+"_button").className="on";
}
}

switchTo2 = function(now, total) {
//total is the total number of switchable layers on the page - used to make this function more dynamic.
//The switchable layers on the page should be given ids of consecutive integers staring with zero.
if (document.getElementById(now).className=="off"){
	
	for (i=0; i<total; i++) {
		if (i!=now){
			Effect.BlindUp(i.toString(), {duration: 0.5});
			Effect.Fade(i.toString(), {duration: 0.6});
			window.setTimeout ('document.getElementById("'+i+'").className="off"', 500 );
			document.getElementById(i+"_button").className="off";
		}
	}
	Effect.BlindDown(now, {duration: 0.5});
	Effect.Appear(now, {duration: 0.7});
	document.getElementById(now).className="on";
	document.getElementById(now+"_button").className="on";
}
}


function MM_popupMsg(msg) { //v1.0
  alert(msg);
}

// MK 07/22/2008
function imagePopup(imageUrl, imageCaption, width, height) {
	var lastParam = "width=" + width + ",height=" + height + ",scrollbars,resizable";
	pu=window.open(imageUrl,"",lastParam);
	pu.document.title=imageCaption;
}



