function emailvalidation(entered, alertbox)
{
// E-mail Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
apos=value.indexOf("@"); 
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>4 || lastpos-dotpos<2) 
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
} 

function emptyvalidation(entered, alertbox)
{
// Emptyfield Validation by Henrik Petersen / NetKontoret
// Explained at www.echoecho.com/jsforms.htm
// Please do not remove this line and the two lines above.
with (entered)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function mailValidation(thisform)
{
	with (thisform)
		{
			if (emailvalidation(to,"The email address you entered isn't valid. Please retype the address.")==false) {to.focus(); return false;};
			if (emptyvalidation(name,"Please enter your name.")==false) {name.focus(); return false;};
			if (emailvalidation(email,"Your email address isn't valid. Please retype the address.")==false) {email.focus(); return false;};
		}
	return true;
}

function contactValidation(thisform)
{
	with (thisform)
		{
			if (emptyvalidation(name,"Please enter your full name.")==false) {name.focus(); return false;};
			if (emailvalidation(email,"The email address you entered isn't valid. Please retype the address.")==false) {email.focus(); return false;};
			if (emptyvalidation(subject,"Please enter a subject.")==false) {subject.focus(); return false;};
			if (emptyvalidation(message_form,"Please enter your message.")==false) {message_form.focus(); return false;};
		}
	return true;
}

function commentValidation(thisform)
{
	with (thisform)
		{
			if (emptyvalidation(author,"Please enter your name.")==false) {author.focus(); return false;};
			if (emptyvalidation(subject,"Please enter a subject.")==false) {subject.focus(); return false;};
			if (emptyvalidation(content,"Please enter your comment.")==false) {content.focus(); return false;};
			if (emptyvalidation(user_code,"Please fill the letters as show in the image.")==false) {user_code.focus(); return false;};
		}
	return true;
}
