// JavaScript Document
// Funciton to validate the form of an email address
function checkEmail(s)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(s)) {
		return true;
	} else {
		alert ('Invalid email address');
	return false;	
	}
}

function validate() {
	var valid = true, output = '';	
		
	if (document.form1.Full_Name.value.length == 0) {
		 valid = false;
		 output+= 'Name: Please enter your full name.\r\n';
		 document.form1.Full_Name.style.backgroundColor = '#FFFFCC';
	}	
	if (document.form1.Email.value.length == 0) {
		 valid = false;
		 output+= 'Email: Please enter your email address so we can respond.\r\n';
		 document.form1.Email.style.backgroundColor = '#FFFFCC';
	} else {		
		if( checkEmail (document.form1.Email.value) == false ) {
			 valid = false;
			 output+= 'Email: Please enter a valid email address.\r\n';
		}
	}
	if (document.form1.City.value.length == 0) {
		// not mandatory		
		 output+= 'City: We\'d love to know where you are from.\r\n';
		 document.form1.City.style.backgroundColor = '#FFFFCC';
	}
	if (document.form1.Comments.value.length == 0) {
		 valid = false;
		 output+= 'Comments: Don\'t forget to leave your comment!\r\n';
		 document.form1.Comments.style.backgroundColor = '#FFFFCC';
	}
	
	if (!valid) {			
		alert(output);				
	}
	
	return valid;
} 