// JavaScript Document

// Form Validation

function fcnValidateReservationFields()
{
var f=document.forms[0];
var apos=f.email.value.indexOf("@");
var dotpos=f.email.value.lastIndexOf(".");
if (f.name.value=="")
{
fcnLightUp('txtName');
document.getElementById("feedback").innerHTML="Please add your name.";
return false;
}
else if (((f.email.value.length<3)||(apos<1||dotpos-apos<2))&&(f.phone.value.length<7))
{
fcnLightUp('txtEmail');
fcnLightUp('txtPhone');
document.getElementById("feedback").innerHTML="Please enter a valid email or phone number";
return false;
}
else
{
return true;
}
}

function fcnLightUp(id)
{
document.getElementById(id).style.border="medium solid #AE001C";
}

function fcnPutOutTheLights()
{
var f=document.forms[0];
for(i=0; i<f.elements.length; i++)
{
f.elements[i].style.border="1px solid #000000";
}
}

function fcnValidateReservationForm()
{
document.getElementById("feedback").innerHTML="working...";
var f=document.forms[0];
fcnPutOutTheLights();
if (fcnValidateReservationFields())
{
f.submit();
return true;
}
else
{
return false;
}
}
