// JavaScript Document

var regEx = new RegExp("")

function validateSignup(){
	
	var form2 = document.form2;
	
	//check required fields - Requestor Name
	if(!checkNameFilled(form2.name, "name")) return

	//check required fields - Email Address
	if(!checkFilled(form2.email, "email")) return
	if(!validateEmail(form2.email)) return
	
	//make sure one of the checkboxes is checked
	if(!checkCheckBoxes()) return
	
	form2.submit();
	
}

//functions

function checkNameFilled(ctl, str){
	if(ctl.value.length == 0 || ctl.value == "Name"){
		alert("Please fill in the Name field before submitting your information")
		ctl.focus()
		return false
	}
	return true
}

function checkFilled(ctl, str){
	if(ctl.value.length == 0){
		alert(str + " is a required field. Please fill it in prior to submitting your information.")
		ctl.focus()
		return false
	}
	return true
}

function validateEmail(ctl){
	regEx = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
	if(!regEx.test(ctl.value)){
		alert("The email address you entered is invalid.")
		return false
	}
	return true
}

function checkCheckBoxes() {	
	if (document.form2.existing.checked == false && document.form2.newcon.checked == false){		
		alert ('Please choose existing practice or new construction')	
		return false		
	}		
	return true		
}



