// JavaScript Document
<!--

function MM_openBrWindow(theURL) { //v2.0
  window.open(theURL,'ActiFi','scrollbars=yes,width=620,height=550');
}

function moveToPage(page){
	document.optionsForm.action=page;
	document.optionsForm.submit();
}
function alert_pop(){
	var decision = confirm("Are you sure you want to clear this form?\nYou will lose all of the questions you have answered.");
	if (decision == true){
		window.location = "index.php?reset=yes";
	}
}
function toggleDisplay(obj){
		var el = document.getElementById(obj);
		if (el.style.display == 'none' || !el.style.display) {
			//safe function to show an element with a specified id
			if(navigator.appName.indexOf("Microsoft") > -1){
				var tog = 'block'
			} else {
				var tog = 'table-row';
			}
		} else {
				var tog = 'none';
		}
		//safe function to toggle an element with a specified id
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(obj).style.display = tog;
		}
		else {
			if (document.layers) { // Netscape 4
				document.obj.display = tog;
			}
			else { // IE 4
				document.all.obj.style.display = tog;
			}
		}
}

function validate_email(page){
	
	var e = document.optionsForm.email.value;
	if(document.optionsForm.email.value == ""){
		document.optionsForm.email.style.backgroundColor = "ffffff";
		moveToPage(page);
	} else {

		var valid = true;
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		
		if (!reg1.test(e) && reg2.test(e)) { // if syntax is valid
			document.optionsForm.email.style.backgroundColor = "ffffff";
			moveToPage(page);
		} else {
			window.alert('Please provide a valid email address');	
			document.optionsForm.email.style.backgroundColor = "fab7b7";
			document.optionsForm.email.focus();
		}
	}
}

function validate_email_PDF(){
	
	var e = document.form_email.email.value;
	if(document.form_email.email.value == ""){
		window.alert('Please provide a valid email address');	
		document.form_email.email.style.backgroundColor = "fab7b7";
		document.form_email.email.focus();
	} else {

		var valid = true;
		var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
		var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		
		if (!reg1.test(e) && reg2.test(e)) { // if syntax is valid
			document.form_email.email.style.backgroundColor = "ffffff";
			document.form_email.submit();
		} else {
			window.alert('Please provide a valid email address');	
			document.form_email.email.style.backgroundColor = "fab7b7";
			document.form_email.email.focus();
		}
	}
}