// Form Validation

//Nominate form
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

function processnominateform(fAction){

document.forms[0].action = fAction; 
document.forms[0].encoding = 'application/x-www-form-urlencoded';

	var ftxt = '';
	
	if (document.forms[0].firstname.value==''){
		ftxt += '\n- Please enter a First Name.';
	}
	
	if (document.forms[0].surname.value==''){
		ftxt += '\n- Please enter a Surname.';
	}
	
	if (isValidEmail(document.forms[0].sender.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}

	if (document.forms[0].firstname2.value==''){
		ftxt += '\n- Please enter the First Name of the person you are nominating.';
	}
	
	if (document.forms[0].surname2.value==''){
		ftxt += '\n- Please enter the Surname of the person you are nominating.';
	}
	
	if (isValidEmail(document.forms[0].email2.value)==false){
		ftxt += '\n- Please enter an Email Address for the person you are nominating.';
	}
			
	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');

	}
	else {
		document.forms[0].submit()
	}
}


function processshortform(fAction){

document.forms[0].action = fAction; 
document.forms[0].encoding = 'application/x-www-form-urlencoded';

	var ftxt = '';
	
	if (document.forms[0].firstname.value==''){
		ftxt += '\n- Please enter a First Name.';
	}
	
	if (document.forms[0].surname.value==''){
		ftxt += '\n- Please enter a Surname.';
	}
	
	if (document.forms[0].telephone.value==false){
		ftxt += '\n- Please enter your Telephone No.';
	}
	
	if (isValidEmail(document.forms[0].sender.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}

	if (document.forms[0].comments.value==''){
		ftxt += '\n- Please enter your Comments.';
	}
			
	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');

	}
	else {
		document.forms[0].submit()
	}
}

