// JavaScript Document
function validate(myForm) {
	var errs = '';
	var first = '';
	if (myForm.firstname.value.length < 1) {
		errs += ' first name;';
	}
	if (myForm.lastname.value.length < 1) {
		errs += ' surname;';
	}
	if (myForm.email.value.length < 1) {
		errs += ' email;';
	}	
	if (myForm.email.value != myForm.email2.value) {
		errs += ' your email does not match;';
	}	
    var emailPat = /^\w+([\'\.\-]\w+)*\@\w+([\'\.\-]\w+)*\.[a-z]{2,4}$/i;
    var matchArray = myForm.email.value.match(emailPat);
    if (myForm.email.value.length > 1) {
	    if (matchArray == null) {
	        errs += ' email (must be a valid email address);';
        }
    }	
	if (myForm.message.value.length > 2000) {
		errs += ' your message must be less than 2000 characters;';
	}	
	if (errs.length > 3) {
		errs = 'You are missing some required fields.\n\nPlease provide:' + errs; 
		alert(errs); 
		return false;
	} else {
		return true; 
	}
}
