// JavaScript Document

// Contact Form Validation
// requires jQuery

function fcnValidateContactFields()
{
var f=$("#contactForm");
var apos=$("#webtolead_email1").val().indexOf("@");
var dotpos=$("#webtolead_email1").val().lastIndexOf(".");
if ($("#last_name").val() == "") {
	fcnLightUp("#last_name");
	$("#feedback").html("<span>Please enter your name</span>");
	return false;
}
else if ($("#account_name").val() == "") {
	fcnLightUp("#account_name");
	$("#feedback").html("<span>Please enter your company name</span>");
	return false;
} else if (($("#webtolead_email1").val().length<3||(apos<1||dotpos-apos<2))) {
	fcnLightUp("#webtolead_email1");
	$("#feedback").html("<span>Please enter a valid email address</span>");
	return false;
}
else
{
return true;
}
}

function fcnLightUp(id)
{
$(id).css({border:"1px solid #F00"});
}

function fcnPutOutTheLights()
{
$("#WebToLeadForm :input").css({border:"1px solid #000"});
}

function fcnValidateContactForm()
{
$("#feedback").html("<span>working...</span>");
fcnPutOutTheLights();
if (fcnValidateContactFields())
{
$("#contactForm").submit();
return true;
}
else
{
return false;
}
}