	 

function validateFormOnSubmit() {
	

 theForm = document.reg_form;

var reason = "";

  reason += validateEmpty(theForm.reg_firstname, "Please enter your firstname <br/>");
  reason += validateEmpty(theForm.reg_surname, "Please enter your surname <br/>");
  reason += validateEmpty(theForm.reg_address1, "Please enter your address <br/>");
  reason += validateEmpty(theForm.reg_postcode, "Please enter your postcode <br/>");
 
    reason += validateChecked(theForm.terms, "Please agree to the terms and conditions <br/>");
      
	
  if (reason != "") {
    document.getElementById('formerror').innerHTML=reason+"<br/><br/>";
		document.getElementById('formerror').style.display='block';
    return false;
  }else{

   theForm.submit();
  }
     return false;
}

function validateEmpty(fld, warning) {
   
 
    if (fld.value.length == 0) {
        fld.style.background = 'Yellow'; 
       
    } else {
        fld.style.background = '#bbbdc0';
		warning = "";
    }
    return warning;  
}
function validateChecked(fld, warning) {
   
 
    if (!fld.checked) {
        fld.style.background = 'Yellow'; 
       
    } else {
        fld.style.background = '#bbbdc0';
		warning = "";
    }
    return warning;  
}

function hideErrors()
{
document.getElementById('formerror').style.display='none';	
}