var submitted = 0;
var foc = 0;

function everything(form) {
foc = 0;
if (submitted) { alert("Form already submitted, please be patient"); return false;}

var text = "You have not correctly filled in the following fields:";
if(isemail(form) == false) {
text += "\n   your e-mail address is mandatory (format you@mail.domain)"
}
if(issubject(form) == false) {
text += "\n   a subject for your email is mandatory"
}
if (ismessage(form) == false) {
text += "\n   your message is mandatory (why else are you using this form)"
}
if (foc) { alert(text); return false; }
if (!submitted) {
form.submitit.disabled=true;
submitted = 1;
form.submit();
}}

function isemail(form) {
if ((form.replyemail.value == "" || form.replyemail.value.indexOf('@', 0) == -1) ||
form.replyemail.value.indexOf('.') == -1) {
if (!foc) {form.replyemail.focus(); foc = 1;}
return false;
}
return true;
}
function issubject(form) {
if(form.subject.value == "" || 
form.subject.value == " ") {
if (!foc) {form.subject.focus(); foc = 1;}
return false;
}
return true;
}
function ismessage(form) {
if(form.message.value == "" ||
form.message.value == " ") {
if (!foc) {form.message.focus(); foc = 1;}
return false;
}
return true;
}
document.getElementById('myform').onsubmit = function() {return everything(document.getElementById('myform'))};
