<!--
   /*** Insert validation functions for Register form here ***/

   function validateForm() {
   		courseObj = document.regform.Course;
		if (!courseObj[0].checked && !courseObj[1].checked) {
			alert("Please select a Course Date");
			return false;
		}

		titleO = document.regform.title;
		if (!titleO[0].checked && !titleO[1].checked && !titleO[2].checked && !titleO[3].checked && !titleO[4].checked && !titleO[5].checked) {
			alert("Please select your Title");
			return false;
		}
		if (titleO[5].checked && document.regform.title_other_specify.value=="") {
			alert("Please specify your Other Title");
			return false;
		}
		
		maObj = document.regform.mailing_address_same;
		if (!maObj[0].checked && !maObj[1].checked) {
			alert("Please select if your Mailing Address is the same or not");
			return false;
		}
		if (maObj[1].checked) {
			//check all mail_address fields
			if (document.regform.mail_street_number.value=="") {
				alert("Please enter your mailing address Street Number");
				return false;
			}
			if (document.regform.mail_address.value=="") {
				alert("Please enter your mailing address Street Name");
				return false;
			}
			if (document.regform.mail_city.value=="") {
				alert("Please enter your mailing address City");
				return false;
			}
			if (document.regform.mail_prov.value=="") {
				alert("Please enter your mailing address State or Province");
				return false;
			}
			if (document.regform.mail_country.value=="") {
				alert("Please enter your mailing address Country");
				return false;
			}
			if (document.regform.mail_pcode.value=="") {
				alert("Please enter your mailing address Postal Code");
				return false;
			}
			if (document.regform.mail_phone.value=="") {
				alert("Please enter your mailing address Phone Number");
				return false;
			}

		}
		
		emObj = document.regform.email;
		if (emObj.value!="") {
			if (!isemail(emObj.value) || emObj.value.length<4) {
				alert("Please enter a valid E-mail Address");
				return false;
			}
		}
		
		statusObj = document.regform.status_in_canada;
		if (!statusObj[0].checked && !statusObj[1].checked && !statusObj[2].checked) {
			alert("Please select your Status in Canada");
			return false;
		}
		if (statusObj[2].checked && document.regform.visa_expiry.value=="") {
			alert("Please enter your Visa Expiry Date");
			return false;
		}
		
		fluencyObj = document.regform.fluency;
		if (!fluencyObj[0].checked && !fluencyObj[1].checked) {
			alert("Please select if you have acheived Fluency in English or French");
			return false;
		}
		if (fluencyObj[1].checked) {
			if (document.regform.fluency_complete_month.value=="") {
				alert("Please indicate the intended month of completion for Fluency in English or French");
				return false;
			}
			if (document.regform.fluency_complete_year.value=="") {
				alert("Please indicate the intended year of completion for Fluency in English or French");
				return false;
			}
		}

		peeObj = document.regform.Pharm_Evaluating_Exam;
		if (!peeObj[0].checked && !peeObj[1].checked) {
			alert("Please select if you have passed the Pharmacy Evaluating Exam");
			return false;
		}
		if (peeObj[0].checked) {
			if (document.regform.Pharm_Evaluating_Exam_Pass_month.value=="") {
				alert("Please indicate the month you passed the Pharmacy Evaluating Exam");
				return false;
			}
			if (document.regform.Pharm_Evaluating_Exam_Pass_year.value=="") {
				alert("Please indicate the year you passed the Pharmacy Evaluating Exam");
				return false;
			}
		}
		if (peeObj[1].checked) {
			if (document.regform.Pharm_Evaluating_Exam_NotComplete_month.value=="") {
				alert("Please indicate the intended month of completion of the Pharmacy Evaluating Exam");
				return false;
			}
			if (document.regform.Pharm_Evaluating_Exam_NotComplete_year.value=="") {
				alert("Please indicate the intended year of completion of the Pharmacy Evaluating Exam");
				return false;
			}
		}
		
		P1 = document.regform.PEBC_Qualify_Exam_P1.value;
		P2 = document.regform.PEBC_Qualify_Exam_P2.value;
		frmNotCompleteP1 = false;
		frmNotCompleteP2 = false;
		
		if (P1!="") {
			if (parseInt(P1)>2) {
				if (document.regform.PEBC_P1_month3=="") frmNotCompleteP1 = true;
				if (document.regform.PEBC_P1_year3=="") frmNotCompleteP1 = true;
				if (!document.regform.PEBC_P1_Success3[0].checked && !document.regform.PEBC_P1_Success3[1].checked ) frmNotCompleteP1 = true;				
			}
			if (parseInt(P1)>1) {
				if (document.regform.PEBC_P1_month2=="") frmNotCompleteP1 = true;
				if (document.regform.PEBC_P1_year2=="") frmNotCompleteP1 = true;
				if (!document.regform.PEBC_P1_Success2[0].checked && !document.regform.PEBC_P1_Success2[1].checked ) frmNotCompleteP1 = true;		
			}
			if (parseInt(P1)>0) {
				if (document.regform.PEBC_P1_month1=="") frmNotCompleteP1 = true;
				if (document.regform.PEBC_P1_year1=="") frmNotCompleteP1 = true;
				if (!document.regform.PEBC_P1_Success1[0].checked && !document.regform.PEBC_P1_Success1[1].checked ) frmNotCompleteP1 = true;		
			}
		}

		if (P2!="") {
			if (parseInt(P2)>2) {
				if (document.regform.PEBC_P2_month3=="") frmNotCompleteP2 = true;
				if (document.regform.PEBC_P2_year3=="") frmNotCompleteP2 = true;
				if (!document.regform.PEBC_P2_Success3[0].checked && !document.regform.PEBC_P2_Success3[1].checked ) frmNotCompleteP2 = true;				
			}
			if (parseInt(P2)>1) {
				if (document.regform.PEBC_P2_month2=="") frmNotCompleteP2 = true;
				if (document.regform.PEBC_P2_year2=="") frmNotCompleteP2 = true;
				if (!document.regform.PEBC_P2_Success2[0].checked && !document.regform.PEBC_P2_Success2[1].checked ) frmNotCompleteP2 = true;		
			}
			if (parseInt(P2)>0) {
				if (document.regform.PEBC_P2_month1=="") frmNotCompleteP2 = true;
				if (document.regform.PEBC_P2_year1=="") frmNotCompleteP2 = true;
				if (!document.regform.PEBC_P2_Success1[0].checked && !document.regform.PEBC_P2_Success1[1].checked ) frmNotCompleteP2 = true;		
			}
		}
		
		if (frmNotCompleteP1) {
			alert("Please complete all the dates, month and year, and if you were successful on your attempt at the PEBC Qualifying Exam Part I");
			return false;
		}
		if (frmNotCompleteP2) {
			alert("Please complete all the dates, month and year, and if you were successful on your attempt at the PEBC Qualifying Exam Part II");
			return false;
		}

		//peepObj = document.regform.PEBC_Success_Prior_2001;
		//if (!peepObj[0].checked && !peepObj[1].checked) {
		//	alert("Please select if you have successfully completed the PEBC Qualifying Exam prior to 2001");
		//	return false;
		//}
		//if (peepObj[0].checked) {
		//	if (document.regform.PEBC_Success_Prior_2001_month.value=="") {
		//		alert("Please indicate the month you successfully completed the PEBC Qualifying Exam prior to 2001");
		//		return false;
		//	}
		//	if (document.regform.PEBC_Success_Prior_2001_year.value=="") {
		//		alert("Please indicate the year you successfully completed the PEBC Qualifying Exam prior to 2001");
		//		return false;
		//	}
		//}
		
		PayObj = document.regform.PayOption;
		if (!PayObj[0].checked && !PayObj[1].checked) {
			alert("Please select a Payment Option");
			return false;
		}
		
		return true;
   }
   
   
   function isemail(string) {
		if ((isatsymbol(string)) && (isperiodsymbol(string))) {
			return true;
		}
		else {
			return false;
		}
	}
	
	function isatsymbol(string) {
		for(var i = 0; i < string.length; i++)
		{
			var character = string.charAt(i);
			if (character == '@') {
				return true; 
				break;
			}
		}
		return false;
	}

	function isperiodsymbol(string) {
		for(var i = 0; i < string.length; i++)
			{
			var character = string.charAt(i);
			if (character == '.') {
				return true; 
				break;
			}
			}
		return false;
	}
	
   
   
//-->

