function checkDonation(){
if (document.getElementById('contactList').checked==true){
	document.getElementById('Pledge').value="";
	document.getElementById('messageOne').style.display = 'none';
	document.getElementById('messageTwo').style.display = 'inline';
	}
	else{
	document.getElementById('Pledge').value="$10"
	document.getElementById('messageTwo').style.display = 'none';
	document.getElementById('messageOne').style.display = 'inline';
	}

}

function checkEmail(){
var emailAddress = document.getElementById('myEmail').value;
if(emailAddress!==""){
re=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

if(re.test(emailAddress)){return true}
window.alert(emailAddress + " does not look like an email address to me.\nPlease try again?");
document.getElementById('myEmail').focus();
document.getElementById('myEmail').select();
}
}

function checkFields(){
if (document.getElementById('firstName').value ==""){
	window.alert("Please enter your first name");
	document.getElementById('firstName').focus(); 
	return false}
if (document.getElementById('familyName').value ==""){
	window.alert("Please enter your family name");
	document.getElementById('familyName').focus();
	return false}
if (document.getElementById('postalAddress').value ==""){
	window.alert("Please enter your postal address");
	document.getElementById('postalAddress').focus();
	return false}
if (document.getElementById('Suburb').value ==""){
	window.alert("Please enter your suburb");
	document.getElementById('Suburb').focus();
	return false}
if (document.getElementById('postCode').value ==""){
	window.alert("Please enter your post code");
	document.getElementById('postCode').focus();
	return false}
if (document.getElementById('postCode').value!=""){
	PC=parseInt(document.getElementById('postCode').value);
	re=/\d{4}/;
		if (!re.test(PC) || document.getElementById('postCode').value.length > 4){
		window.alert("A post code contains four numbers");
		document.getElementById('postCode').focus();
		document.getElementById('postCode').select();
		return false}
return true;	
}
}

function checkForm(){

if (document.getElementById('mailDollars').checked == true){
test = checkFields();
	if(test) {
	alert("Thank you.\nPlease print the form and mail it with your donation to the Treasurer.\nA receipt will be sent to your postal address");
	window.print();
	return true;
	}
	else{
	return false
	}
}
if (document.getElementById('eDollars').checked == true){
test = checkFields();
	if(test) {
	alert("Thank you.\nA receipt will be issued.\nwhen we receive your donation.");
	return true
	}
	else{
	return false
	}
}
if (document.getElementById('emailList').checked == true){

	if(document.getElementById("myEmail").value != "") {
	alert("Thank you.\nWe will add you to our email list.")
	return true
	}
	else{
	test= checkFields();
		if(test){
		alert("Thank you.\nWe will add your details to our contact list");
		return true
		}
		else{
		return false
		}
	}
}
}
function messageTwo(){
if (document.getElementById('firstName').value ==""){
	window.alert("Please enter your first name");
	document.getElementById('firstName').focus(); 
	return false}
if (document.getElementById('familyName').value ==""){
	window.alert("Please enter your family name");
	document.getElementById('familyName').focus();
	return false}
if (document.getElementById('postalAddress').value ==""){
	window.alert("Please enter your postal address");
	document.getElementById('postalAddress').focus();
	return false}
if (document.getElementById('Suburb').value ==""){
	window.alert("Please enter your suburb");
	document.getElementById('Suburb').focus();
	return false}
if (document.getElementById('postCode').value ==""){
	window.alert("Please enter your post code");
	document.getElementById('postCode').focus();
	return false}
if (document.getElementById('postCode').value!=""){
	PC=parseInt(document.getElementById('postCode').value);
	re=/\d{4}/;
		if (!re.test(PC) || document.getElementById('postCode').value.length > 4){
		window.alert("A post code contains four numbers");
		document.getElementById('postCode').focus();
		document.getElementById('postCode').select();
		return false}
}
var com = document.getElementById('comments').value;
re = /[\<\>]/i;
	if (re.test(com)){
	
	window.alert('Please do not add html symbols (< or >)in your comments');
	
	return false;
	}
return true;	
	}
	

