
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');
	
	// Validates correct E-Mail formatting via RegExp
	if(document.survey.txtEmail.value != "" && !checkEmail(document.survey.txtEmail.value)) {
		alert("Please fill in a valid email address.");
		document.survey.txtEmail.focus();
		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,"");
}
