function yournameempty(yourname, alertbox)
{
with (yourname)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emailvalidation(email, alertbox)
{
with (email)
{
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;

if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2) {
	
	if (alertbox) { alert(alertbox); } return false; }
else { return true; }
}
}

function whereempty(name, alertbox)
{
with (where)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function enquiryempty(name, alertbox)
{
with (enquiry)
{
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function formvalidation(contactform)
{

with (contactform)
{
if (yournameempty(yourname,"You must enter your Name")==false) {yourname.focus(); return false;};
if (emailvalidation(email,"Invalid or empty email address")==false) {email.focus(); return false;};
if (whereempty(where,"Please let us know where you heard about us.")==false) {where.focus(); return false;};
if (enquiryempty(enquiry,"Please fill in your enquiry.")==false) {enquiry.focus(); return false;};
}
}

