function OnChange_Country() {
	var theForm = document.register;
	theForm.buttonClicked.value = "edit";
	theForm.submit();
}

function FormValidation_Register() {
	var theForm = document.register;
	
	var theDay = theForm.birthDate.options[theForm.birthDate.selectedIndex].value;
	var theMonth = theForm.birthMonth.options[theForm.birthMonth.selectedIndex].value;
	var theYear = theForm.birthYear.options[theForm.birthYear.selectedIndex].value;
	var theBirthDate = theMonth + '/' + theDay + '/' + theYear;
	
	//alert(getSelectedCheckbox(theForm.interestID).length);
	
	if (trimWhitespace(theForm.username.value) == '') {
		alert("Username is required.");
		return false;
	}
	else if (!isAlphanumeric(theForm.username.value)) {
		alert("Username only accepts alphanumeric characters.");
		return false;
	}
	else if (trimWhitespace(theForm.username.value).length < 5 || trimWhitespace(theForm.username.value).length > 20) {
		alert("Username only accepts 5 to 20 of characters.");
		return false;
	}
	else if (trimWhitespace(theForm.password.value) == '') {
		alert("Password is required.");
		return false;
	}
	else if (trimWhitespace(theForm.password.value).length < 5 || trimWhitespace(theForm.password.value).length > 20) {
		alert("Password only accepts 5 to 20 of characters.");
		return false;
	}
	else if (trimWhitespace(theForm.emailAddress.value) == '') {
		alert("Email Address is required.");
		return false;
	}
	else if (!isValidEmail(theForm.emailAddress.value)) {
		alert("Email Address is invalid.");
		return false;
	}
	else if (trimWhitespace(theForm.emailAddress.value) != trimWhitespace(theForm.verifyEmailAddress.value)) {
		alert("Email and Verify Email Address should be same.");
		return false;
	}
	else if (trimWhitespace(theForm.city.value) == '') {
		alert("City is required.");
		return false;
	}
	else if (theForm.country.options[theForm.country.selectedIndex].value == 'United States' && theForm.state.options[theForm.state.selectedIndex].value == '') {
		alert("State is required.");
		return false;
	}
	else if (theForm.country.options[theForm.country.selectedIndex].value == 'Canada' && theForm.province.options[theForm.province.selectedIndex].value == '') {
		alert("Province is required.");
		return false;
	}
	else if (theForm.country.options[theForm.country.selectedIndex].value != 'United States' && theForm.country.options[theForm.country.selectedIndex].value != 'Canada' && trimWhitespace(theForm.stateProvince.value) == '') {
		alert("State/Province is required.");
		return false;
	}
	else if (theForm.country.options[theForm.country.selectedIndex].value == 'United States' && trimWhitespace(theForm.zipCode.value) == '') {
		alert("Zip Code is required.");
		return false;
	}
	else if (theForm.country.options[theForm.country.selectedIndex].value == 'United States' && !isValidZipcode(theForm.zipCode.value)) {
		alert("Zip Code is invalid.");
		return false;
	}
	else if (theForm.country.options[theForm.country.selectedIndex].value == 'Canada' && trimWhitespace(theForm.postalCode.value) == '') {
		alert("Postal Code is required.");
		return false;
	}
	else if (theForm.country.options[theForm.country.selectedIndex].value == 'Canada' && !isValidPostalcode(theForm.postalCode.value)) {
		alert("Postal Code is invalid.");
		return false;
	}
	else if (theForm.country.options[theForm.country.selectedIndex].value != 'United States' && theForm.country.options[theForm.country.selectedIndex].value != 'Canada' && trimWhitespace(theForm.zipPostalCode.value) == '') {
		alert("Zip/Postal Code is required.");
		return false;
	}
	else if (theForm.action.value == 'insert' && !isValidDate(theDay, theMonth, theYear)) {
		alert("Date Of Birth is invalid.");
		return false;
	}
	else if (theForm.action.value == 'insert' && theForm.raceID.options[theForm.raceID.selectedIndex].value == '') {
		alert("My Race is required.");
		return false;
	}
	else if (getSelectedCheckbox(theForm.interestID).length == 0) {
		alert("I am Interested in is required.");
		return false;
	}
	else if (trimWhitespace(theForm.weight.value) == '') {
		alert("Weight is required.");
		return false;
	}
	else if (theForm.heightFt.options[theForm.heightFt.selectedIndex].value == '') {
		alert("Height is required.");
		return false;
	}
	else if (theForm.action.value == 'insert' && theForm.adult.checked == false) {
		alert("I am over 18 years old is required.");
		return false;
	}
	else if (theForm.action.value == 'insert' && theForm.acceptTerms.checked == false) {
		alert("I agree to Terms and Agreement is required.");
		return false;
	}
	else {
		return true;
	}
}
