
function toggle(box,theId) { 
if(document.getElementById) { 
var cell = document.getElementById(theId); 
if(box.checked) { 
cell.className = "on"; 
} 
else { 
cell.className = "off"; 
} 
} 
} 

//validating the fields when user clicks submit
function validate() {
	var cboRules = document.getElementById('cboRules');
	
	if(document.registration.txtFirst.value=="") {
		alert("Please fill in your first name.");
		document.registration.txtFirst.focus();
		return false;
	}else if(document.registration.txtLast.value=="") {
		alert("Please fill in your last name.");
		document.registration.txtLast.focus();
		return false;
	}else if(document.registration.txtDept.value=="") {
		alert("Please fill in your department.");
		document.registration.txtDept.focus();
		return false;
	}else if(!checkEmail(document.registration.txtEmail.value)) {
		alert("Please fill in a valid email address.");
		document.registration.txtEmail.focus();
		return false;
	} else if (!document.registration.rdSess1[0].checked &&
			!document.registration.rdSess2[0].checked && 
			!document.registration.rdSess3[0].checked && 
			!document.registration.rdSess4[0].checked) {
		alert("You must select at least one session to attend");
		return false;
	}
}



function checkEmail(email) {
	var emailpat = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/;
	if (trimStr(email) == "") {		
		return false;		
	} else {
		if(emailpat.test(email)) {
			return true;
		}else{
			return false;
		}
	}
}

// trims a string value
function trimStr(str) {
    return str.replace(/^\s+|\s+$/g,"");
}
