function checkWholeForm(theForm) {
    var why = "";
    for (i=0, n=theForm.symbol.length; i<n; i++) {
        if (theForm.symbol[i].checked) {
            var checksymbol = theForm.symbol[i].value;
            break;
        } 
    }
    
    for (i=0, n=theForm.swatch.length; i<n; i++) {
        if (theForm.swatch[i].checked) {
            var checkswatch = theForm.swatch[i].value;
            break;
        } 
    }
    
    for (i=0, n=theForm.message.length; i<n; i++) {
        if (theForm.message[i].checked) {
            var checkmessage = theForm.message[i].value;
            break;
        } 
    }
    
    why += checkRadio(checksymbol,"symbol");
    why += checkRadio(checkswatch,"swatch");
    why += checkRadio(checkmessage,"message");

    why += checkFirstName(theForm.firstname.value);
    why += checkLastName(theForm.lastname.value);
    why += checkEmail(theForm.email.value);
    why += checkRank(theForm.rank.value);
    why += checkUnit(theForm.unit.value);
    why += checkLocation(theForm.location.value);
    why += checkAddress(theForm.address.value);
    why += checkCity(theForm.city.value);
    why += checkDropdown(theForm.state.selectedIndex);
    why += checkZip(theForm.zip.value);

    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// email

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "Please enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


function checkFirstName (strng) {
var error = "";
if (strng == "") {
   error = "Please enter your first name.\n";
}
return error;
}

function checkLastName (strng) {
var error = "";
if (strng == "") {
   error = "Please enter your last name.\n";
}
return error;
}

function checkRank (strng) {
var error = "";
if (strng == "") {
   error = "Please enter your rank.\n";
}
return error;
}

function checkUnit (strng) {
var error = "";
if (strng == "") {
   error = "Please enter your unit.\n";
}
return error;
}

function checkLocation (strng) {
var error = "";
if (strng == "") {
   error = "Please enter your location.\n";
}
return error;
}

function checkAddress (strng) {
var error = "";
if (strng == "") {
   error = "Please enter your street address.\n";
}
return error;
}

function checkCity (strng) {
var error = "";
if (strng == "") {
   error = "Please enter your city.\n";
}
return error;
}

function checkZip (strng) {
var error = "";
if (strng == "") {
   error = "Please enter your zip code.\n";
} else if(strng.length!=5) {
		error = "Please enter your 5 digit zip code";
} else if(strng.length==5) {
	if(isNaN(strng)) {
		error = strng + " is not a number.  Please enter a numerical zip code.";
	}
}
return error;
}

function checkRadio(checkvalue,area) {
var error = "";
   if (!(checkvalue)) {
       error = "Please check a " + area + ".\n";
    }
return error;
}

function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
    error = "Please select a state.\n";
    }    
return error;
}    