// JavaScript Document

function validate_form() {	
  var hasContent = true;
  
  if (document.contactform.username.value.length < 1) {
    hasContent = alert("Warning: You have not entered your name.");
	return false;
  }
  if (document.contactform.subject.value.length < 1) {
    hasContent = alert("Warning: You have not entered a subject.");
	return false;
  }
  if (document.contactform.mainmessage.value.length < 1) {
    hasContent = alert("Warning: You have not entered a message.");
	return false;
  }
  if (document.contactform.email.value.length < 1) {
    hasContent = alert("Warning: You have not entered an email address.");
	return false;
  }
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  if (document.contactform.email.value.length > 1) {
    if (document.contactform.email.value.search(validRegExp) == -1) {
      hasContent = alert("Warning: You have not entered a valid email address!");
      return false;
	}
  }	
  if (document.contactform.email_check.value.length < 1) {
    hasContent = alert("Warning: You have not entered an email address for checking purposes.");
    return false;
  }
  if (document.contactform.email_check.value.length > 1) {
    if (document.contactform.email_check.value.search(validRegExp) == -1) {
      hasContent = alert("Warning: You have not entered a valid email address for checking purposes.");
      return false;
    }
  }
  if (document.contactform.email.value.length != document.contactform.email_check.value.length) {
    hasContent = alert("Warning: The email addresses you've entered do not match.");
	return false;
  }
  return hasContent;
  if (hasContent==true){
    return true; 
  }
}