// JavaScript Document
function fnCheckForm(obj) {
		var vName = obj.txtName.value;
		var vDOB = obj.txtDOB.value;
		var vAddr = obj.txtAddr.value;
		var vHPhone = obj.txtHPhone.value;
		var vWPhone = obj.txtWPhone.value;
		var vIns = obj.txtInsurance.value;
		var vEmp = obj.txtEmployee.value;
		var vEmployed = obj.rbEmployed;
				
		if (!vName) {
			alert("Name is missing.  Please enter your full name to continue.  Please include middle name.");
			return false;
		}
		
		if (!vDOB) {
			alert("Date of Birth is missing. (mm/dd/yyyy)");
			return false;
		}

		if (!vAddr) {
			alert("Address is missing.");
			return false;
		}
		
		if (!vHPhone) {
			alert("Home Phone is missing. Please include area code.");
			return false;
		}

		if (!vWPhone) {
			alert("Work Phone is missing. Please include area code.");
			return false;
		}
		
		if (!vIns) {
			alert("Insurance is missing.");
			return false;
		}

		
		if (!isPhone(vHPhone)){
			alert('Home Phone format incorrect. \n -Format examples:\n  (123) 123-4567\n  123-123-4567\n  123 123 4567');
			return false;
		}

		if (!isPhone(vWPhone)){
			alert('Work Phone format incorrect. \n -Format examples:\n  (123) 123-4567\n  123-123-4567\n  123 123 4567');
			return false;
		}
		
		if (!isDOB(vDOB)){
			alert('Date of Birth format incorrect. \n -Format examples: mm/dd/yyyy or 12/21/1970');
			return false;
		}
		
		if (vEmployed[0].checked) {
			//check if txtEmployee box
			if (!vEmp) {
				alert("Employee is missing.");
				return false;
			}
		}
		
		/*if (!isEmail2(vEmail)) {
			alert('Please enter a valid formatted email address.\n -Example: name@domain.com');
			return false;
		}
		*/
	}
	
	/* With RegExp */
	function isEmail2(who) {
		var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
		return(email.test(who));
	}

	function isZip(zip){
		var re = /^[0-9]{5}$/i;
		return(re.test(zip));
	}
	
	function isPhone(phone){
		var re = /^[\(]?([0-9]{3})[\)]?\s?[-]?[0-9]{3}[-]?\s?[0-9]{4}$/i;
		return(re.test(phone));
	}
	
	function isDOB(dob){
		var re = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/i;
		return(re.test(dob));
	}