// JavaScript Document

// Form Validation
// requires jQuery

function fcnValidateFields()
{
var f=$("#CFR");
var apos=$("#email").val().indexOf("@");
var dotpos=$("#email").val().lastIndexOf(".");
if ($("#last_name").val() == "") {
	fcnLightUp("#last_name");
	$("#feedback").html("<span>Please enter your last name</span>");
	return false;
}
else if ($("#company").val() == "") {
	fcnLightUp("#company");
	$("#feedback").html("<span>Please enter your company name</span>");
	return false;
} else if ($("#title").val() == "") {
	fcnLightUp("#title");
	$("#feedback").html("<span>Please select the most appropriate title</span>");
	return false;
} else if (($("#email").val().length<3||(apos<1||dotpos-apos<2))) {
	fcnLightUp("#email");
	$("#feedback").html("<span>Please enter a valid email address</span>");
	return false;
}
else
{
return true;
}
}

function fcnLightUp(id)
{
$(id).css({border:"1px solid #8DD1FF"});
}

function fcnPutOutTheLights()
{
$("#WebToLeadForm :input").css({border:"1px solid #000;"});
}

function fcnValidateForm()
{
$("#feedback").html("<span>working...</span>");
fcnPutOutTheLights();
if (fcnValidateFields())
{
$("#CFR").submit();
return true;
}
else
{
return false;
}
}
