function emptyvalidation(entered)
{
with (entered)
{
if (value==null || value=="" || value==0)
{return false;}
else {return true;}
}
} 

function telephonevalidation(entered)
{
with(entered)
{

var stripped = value.replace(/[^\d]+/g, "");
// strip out unacceptable non-numeric chars
if (value==null || value=="")
{
	return false;
}
else 
{
	if (isNaN(parseInt(stripped)))  
	{
		return false;
	}
	else 
	{
		if (stripped.length < 10 || stripped.length > 20) 
		// test stripped number length against acceptable range
		{
			return false;
		}
		else 
		{
			return true;
		}
	}
}
}
}

function emailvalidation(entered)
{
with(entered)
{
// var emailFilter=/^.+@.+\..{2,3}$/;
//alternate email filter (more simple)
var emailFilter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (!(emailFilter.test(value))) 
{
	return false;
}
else
{
	return true;
}
}
}

function mailvalidation()
{
var err = 0;
var code = "";

if (emptyvalidation(document.mailform.name)==false) {err++; code+="Name\n";};
if (emailvalidation(document.mailform.email)==false) {err++; code+="Email\n";};
if (telephonevalidation(document.mailform.telephone)==false) {err++; code+="Telephone (10-20 digit)\n";};
if (emptyvalidation(document.mailform.message)==false) {err++; code+="Message\n";};

if (err==0) 
{
	return true;
}
else
{
	alert ("The following information is missing or incorrect:\n\n"+code+"\nPlease correct or enter the necessary information\n");
	return false;
}
}

