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 emptyfirstname(realname, alertbox){
with (realname){
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}}}

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

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

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

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

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

//function valbuttonlocation(location, alertbox) {
// place any other field validations that you require here
// validate myradiobuttons
//myOption = -1;
//for (i=mainform.location.length-1; i > -1; i--) {
//if (mainform.location[i].checked) {
//myOption = i; i = -1;
//}
//if (myOption == -1) {
//{if (alertbox!="") {alert(alertbox);} return false;}
//else {return true;}


function formvalidation(mainform)
{
with (mainform)
{
if (emptyfirstname(realname,"All required fields (in red) must be filled. Please fill in your full name.")==false) {realname.focus(); return false;};
if (emptytitle(Title,"All required fields (in red) must be filled. Please fill in your title.")==false) {Title.focus(); return false;};
if (emptycompany(Company,"All required fields (in red) must be filled. Please fill in your company's name.")==false) {Company.focus(); return false;};
if (emptyaddress(Address,"All required fields (in red) must be filled. Please fill in your address.")==false) {Address.focus(); return false;};
if (emptyphone(Phone,"All required fields (in red) must be filled. Please fill in your phone number.")==false) {Phone.focus(); return false;};
if (emailvalidation(email,"All required fields (in red) must be filled. Please enter a valid email address.")==false) {email.focus(); return false;};
//if (valbuttonlocation(location,"All required fields (in red) must be filled. Please tell us where your generator is located.")==false) {location.focus(); return false;};
}
}
