function emailValidate(element) {
    //Validating the email field
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    if (! element.value.match(re)) {
        alert("Invalid email address");
        element.focus();
        element.select();
        return (false);
    }
    return(true);

}

function textValidate(field,alerttxt)
{

	with (field)
	{
		if (value == "") {
			{alert(alerttxt);
			return false}
			}
		else {
			field.action = "submit_order.php";
			return true}
	}
}

function numberValidate(field,alerttxt)
{

	with (field)
	{
		if (value == "") {
			{alert(alerttxt);
			return false}
			}
		else if (value <= 0) {
			{alert(alerttxt);
			return false}
			}
		else {
			field.action = "submit_order.php";
			return true}
	}
}

function formValidate()
{
	if (textValidate(document.samplesForm.field_n,"Please enter a name.")==false)
		{document.samplesForm.field_n.focus();return false}
	else if (emailValidate(document.samplesForm.field_e)==false)
		{document.samplesForm.field_e.focus();return false;}
	else if (textValidate(document.samplesForm.field_tele,"Please enter a phone number.")==false)
		{document.samplesForm.field_tele.focus();return false}
	else if (textValidate(document.samplesForm.field_add,"Please enter a street address or P.O. box.")==false)
		{document.samplesForm.field_add.focus();return false}
	else if (textValidate(document.samplesForm.field_code,"Please enter a postal or zip code.")==false)
		{document.samplesForm.field_code.focus();return false}
	else if (textValidate(document.samplesForm.field_prov,"Please enter a Province or State.")==false)
		{document.samplesForm.field_prov.focus();return false}
	else if (textValidate(document.samplesForm.field_town,"Please enter a town or city.")==false)
		{document.samplesForm.field_town.focus();return false}
	else if (textValidate(document.samplesForm.field_coun,"Please enter a country.")==false)
		{document.samplesForm.field_coun.focus();return false}
	else if ((document.samplesForm.field_TCOD[0].checked==false) || (document.samplesForm.field_TCOD[1].checked==false) || (document.samplesForm.field_TCOD[2].checked==false))
	{
		alert ("Please enter a type of Camelina Oil desired.");
		return false;
	}

	else if (emailValidate(document.samplesForm.field_e)==true)
		{document.samplesForm.action = "submit_order.php";}
}

