reEmail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

$(function() {
				$("#basicRadio").click(function() {
								$("#basic").show("fast");
								$("#support").hide();
								$("#assess").hide();
								$("#partner").hide();
						});
				$("#supportRadio").click(function() {
								$("#support").show("fast");
								$("#basic").hide();
								$("#assess").hide();
								$("#partner").hide();
						});
				$("#assessRadio").click(function() {
								$("#assess").show("fast");
								$("#basic").hide();
								$("#support").hide();
								$("#partner").hide();
						});
				$("#partnerRadio").click(function() {
								$("#partner").show("fast");
								$("#basic").hide();
								$("#support").hide();
								$("#assess").hide();
						});

				$("#basicOrder").submit(basicValidate);
				$("#supportOrder").submit(supportValidate);
				$("#assessOrder").submit(assessValidate);
				$("#partnerOrder").submit(partnerValidate);
		});


function basicValidate() {
		genChk = false;
		for(i=0; i<this.gender1.length; i++){
				if(this.gender1[i].checked) {
						genChk=true;
				}
		}

		if(!genChk) {
				alert("Please select either male or female");
				return false;
		}
		if(this.firstName1.value == '') {
				alert("Please enter your first name");
				return false;
		}
		if(this.lastName1.value == '') {
				alert("Please enter your last name");
				return false;
		}
		if(!reEmail.test(this.emailAddr1.value)) {
				alert("Please enter a valid email address");
				return false;
		}
		if(this.emailAddr1.value != this.confEmailAddr1.value) {
				alert("Please make sure your email address and the confirmation email address match");
				return false;
		}

		return true;
}


function supportValidate() {
		genChk = false;
		for(i=0; i<this.gender1.length; i++){
				if(this.gender1[i].checked) {
						genChk=true;
				}
		}
		if(!genChk) {
				alert("Please select your gender, either male or female");
				return false;
		}
		if(this.firstName1.value == '') {
				alert("Please enter your first name");
				return false;
		}
		if(this.lastName1.value == '') {
				alert("Please enter your last name");
				return false;
		}
		if(!reEmail.test(this.emailAddr1.value)) {
				alert("Please enter a valid address for your email");
				return false;
		}
		if(this.emailAddr1.value != this.confEmailAddr1.value) {
				alert("Please make sure your email address and the confirmation email address match");
				return false;
		}

		genChk=false;
		for(i=0;i<this.gender2.length;i++) {
				if(this.gender2[i].checked) {
						genChk=true;
				}
		}
		if(!genChk) {
				alert("Please select the gender of the person you are evaluating, either male or female");
				return false;
		}
		if(this.firstName2.value == '') {
				alert("Please enter the first name of the person you are evaluating");
				return false;
		}
		if(this.lastName2.value == '') {
				alert("Please enter the last name of the person you are evaluating");
				return false;
		}

		return true;
}



function assessValidate() {
		genChk = false;
		for(i=0; i<this.gender1.length; i++) {
				if(this.gender1[i].checked) {
						genChk = true;
				}
		}
		if(!genChk) {
				alert("Please select gender of the person taking the STAR Energizer Basic");
				return false;
		}
		if(this.firstName1.value == '') {
				alert("Please enter the first name of the person taking the STAR Energizer Basic");
				return false;
		}
		if(this.lastName1.value == '') {
				alert("Please enter the last name of the person taking the STAR Energizer Basic");
				return false;
		}
		if(!reEmail.test(this.emailAddr1.value)) {
				alert("Please enter a valid email address for the person taking the STAR Energizer Basic");
				return false;
		}
		if(this.emailAddr1.value != this.confEmailAddr1.value) {
				alert("Please make sure the email address and the confirmation email address match for the person taking the STAR Energizer Basic");
				return false;
		}

		genChk=false;
		for(i=0;i<this.gender2.length;i++) {
				if(this.gender2[i].checked) {
						genChk=true;
				}
		}
		if(!genChk) {
				alert("Please select gender of the person taking the STAR Energizer Advisor");
				return false;
		}
		if(this.firstName2.value == '') {
				alert("Please enter the first name of the person taking the STAR Energizer Advisor");
				return false;
		}
		if(this.lastName2.value == '') {
				alert("Please enter the last name of the person taking the STAR Energizer Advisor");
				return false;
		}
		if(!reEmail.test(this.emailAddr2.value)) {
				alert("Please enter a valid email address for the person taking the STAR Energizer Advisor");
				return false;
		}
		if(this.emailAddr2.value != this.confEmailAddr2.value) {
				alert("Please make sure the email address and the confirmation email address match for the person taking the STAR Energizer Advisor");
				return false;
		}

		return true;
}


function partnerValidate() {
		genChk = false;
		for(i=0; i<this.gender1.length; i++){
				if(this.gender1[i].checked) {
						genChk = true;
				}
		}
		if(!genChk) {
				alert("Please select either male or female for Partner 1");
				return false;
		}
		if(this.firstName1.value == '') {
				alert("Please enter Partner 1's first name");
				return false;
		}
		if(this.lastName1.value == '') {
				alert("Please enter Partner 1's last name");
				return false;
		}
		if(!reEmail.test(this.emailAddr1.value)) {
				alert("Please enter a valid email address for Partner 1");
				return false;
		}
		if(this.emailAddr1.value != this.confEmailAddr1.value) {
				alert("Please make sure the email address and the confirmation email address match for Partner 1");
				return false;
		}

		genChk=false;
		for(i=0;i<this.gender2.length;i++){
				if(this.gender2[i].checked) {
						genChk=true;
				}
		}
		if(!genChk) {
				alert("Please select either male or female for Partner 2");
				return false;
		}
		if(this.firstName2.value == '') {
				alert("Please enter Partner 2's first name");
				return false;
		}
		if(this.lastName2.value == '') {
				alert("Please enter Partner 2's last name");
				return false;
		}
		if(!reEmail.test(this.emailAddr2.value)) {
				alert("Please enter a valid email address for Partner 2");
				return false;
		}
		if(this.emailAddr2.value != this.confEmailAddr2.value) {
				alert("Please make sure the email address and the confirmation email address match for Partner 2");
				return false;
		}

		return true;
}