// Used in the left nav to collapse and expand link panels
// Collapses up to 11 elements before expanding the clicked panel header
function bb_switch(item, name, objBold) {
	//turn off appropriate layers
	for (i=0; i <= 10; i++) {
		if (document.getElementById('aa'+i) && document.getElementById('a'+i)) {
			document.getElementById('aa'+i).style.display='none';
			//document.getElementById('img'+i).style.display='none';
			document.getElementById('a'+i).style.fontWeight='';
		}
	}			 

	//turn on layer
	document.getElementById('aa'+item).style.display='';
	//document.getElementById('img'+item).style.display='';
	//objBold.style.fontWeight='bold';
}

/* ************************************************
	NEWSLETTER SIGNUP FORM FUNCTIONS
   ************************************************ */

// Used onClick or onKeyPress to remove the instructional text in the email address form field
function removeInstructionalText() {
	if (document.emailForm.EMAIL.value == "Enter e-mail address") {
		document.emailForm.EMAIL.value = "";
	}
}

// Returns true if the string passed is a true email address, false otherwise
function checkEmail(strVar) {
	var emailReg = /^(\w){1}[^\*\$\^\&\!\#\%\(\)\+\`\~\,\/\?\:\;\\\"\|\[\]\{\}\@]+\@(\w){1}(\w|-|\.)+\.[a-z]{2,4}$/i;
	var emOK = true;
	if(strVar.length > 1){
		if(!emailReg.test(strVar)){
			emOK = false;
		}
	} 
	return emOK;
}

function validateEmail() {
	if ((document.emailForm.EMAIL.value != "") && (document.emailForm.EMAIL.value != document.emailForm.EMAIL.defaultValue)) {
		if (!checkEmail(document.emailForm.EMAIL.value)) {
			alert("Invalid email address");
			return false;
		} 
	} else { //email is blank
		alert("Invalid email address");
		return false;
	}
	return true;
}