// JavaScript Document
// SIMPLEFUSION.CO.UK
// Validation of Email, Name and Message
// Author: Matthew Vaughan

function ChangeDisplay(ID,Display){document.getElementById(ID).style.display = Display;}
function Validation(){
Return = 3
with(document.EmailForm){
	if (name.value==null||name.value==""){
		ChangeDisplay("NameError","inline");
		Return-=1;
		}else{
		ChangeDisplay("NameError","none");
		}
	theATpos=email.value.indexOf("@");
	dotpos=email.value.lastIndexOf(".");
	if (theATpos<1||dotpos-theATpos<2){
		ChangeDisplay("EmailError", "inline");
		Return-=1;
		} else {
		ChangeDisplay("EmailError", "none");
		}
	if (message.value==null||message.value==""){
		ChangeDisplay("MessageError", "inline");
		Return -= 1
		}else{
		ChangeDisplay("MessageError", "none");
		}
	}
	if (Return < 3){return false;}else{return true;}
}
function clearForm(){
if (confirm('Are you sure you want to clear the form?')){
		with(document.EmailForm){
		name.value = ""
		email.value = ""
		message.value = ""
		}
		} 
}