<!--
function eCheckNum(sn){
    s= sn.value;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if (((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == " ")  || (ch == ".")  || (ch == "-")   || (ch == "&")  ||  (ch == ",")  ||  (ch == "_")  ||  (ch == "(")  ||  (ch == ")")  ||  ch == "@"))
           {
             return false;
        theForm.elements[eCheckNum.arguments[i]].focus();
             //(ch >= "0" && ch <= "9") ||
				}
        }
   return true;
}

function CheckNum(theForm){
   for(var i=1; i<CheckNum.arguments.length; i++)
         if (!eCheckNum(theForm.elements[CheckNum.arguments[i]])){
            alert("Field entry is not valid");
            theForm.elements[CheckNum.arguments[i]].focus();
            return false;
        }
   return true;
}

function eCheckAlphaNum(sn){
    s= sn.value;
    for (var i = 0; i < s.length; i++) {
        ch = s.substring(i, i + 1)
        if (!((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z") || (ch == " ")  || (ch == ".")  || (ch == "-")   || (ch == "&")  ||  (ch == ",")  ||  (ch == "_")  ||  (ch == "(")  ||  (ch == ")")  || (ch >= "0" && ch <= "9") || ch == "@"))
           {
             return false;
        theForm.elements[eCheckAlphaNum.arguments[i]].focus();

				}
        }
   return true;
}

function CheckAlphaNum(theForm){
   for(var i=1; i<CheckAlphaNum.arguments.length; i++)
         if (!eCheckAlphaNum(theForm.elements[CheckAlphaNum.arguments[i]])){
            alert("Field entry is not valid");
            theForm.elements[CheckAlphaNum.arguments[i]].focus();
            return false;
        }
   return true;
}

function CheckRequiredFields(theForm)
{
   for(i=1; i<CheckRequiredFields.arguments.length; i++)
        if(theForm.elements[CheckRequiredFields.arguments[i]].value==""){
            alert("This field is required");
            theForm.elements[CheckRequiredFields.arguments[i]].focus();
            return false;
        }
   return true;
}

// * start checking the actual form stuff here
// * replace field and form names below

    var bValid;
    var f;
    var i;
    var sString;

function ProcessForm(bFinal)
    {
        if (!f)
            f = document.freeGoBoating;

        if (bFinal == "TRUE")
        {
            CheckSubmit();
        }
        else
        {
            document.freeGoBoating.submit();
        }
    }

// * field names go here
function CheckSubmit()
    {
        bValid = true;

        CheckValid(f.first_name.value, "First Name is a required field!");
        CheckValid(f.last_name.value, "Last Name is a required field!");
        CheckValid(f.address.value, "Address is a required field!");
        CheckValid(f.city.value, "City is a required field!");
        sString = f.state.options[f.state.selectedIndex].value;
        CheckValid(sString, "State is a required field!");
        CheckValid(f.zip.value, "Zip Code is a required field!");
//        CheckValid(f.phone.value, "Phone Number is a required field!");
//        bbString = f.state_of_birth.options[f.state_of_birth.selectedIndex].value;
//        CheckValid(bbString, "State of Birth is a required field!");
        CheckRadio(f.plan_to_purchase, "Please answer the question 'I am planning to buy a boat'");
        CheckRadio(f.own_a_boat, "Please answer the question 'I currently own a boat'");		
        CheckValid(f.monthborn.value, "The month you were born is a required field!");
        ccString = f.hearFrom.options[f.hearFrom.selectedIndex].value;
        CheckValid(ccString, "Please answer the question 'How did you hear about us?'");
        CheckCheckBox(f.yes_want_free, "Please place a check next to the question 'Yes, I want my subscription to Go Boating Magazine?'");
		
	if (bValid)

        {
            document.freeGoBoating.submit();
        }
    }

function CheckValid(strFieldName, strMsg)
{
	if (strFieldName == "" || strFieldName == null || strFieldName == " ")
	{
		if (bValid)
		{
			alert(strMsg);
			bValid = false;
		}
	}
}

function getCheckedRadioButton(radioSet)
  { 
  for (var i=0; i<radioSet.length; i++)
    if (radioSet[i].checked)
      return i;
  return -1;
  }
  
function getCheckedCheckboxes(checkboxSet)
  {
//  var arr = new Array();
//  for (var i=0,j=0; i<checkboxSet.length; i++)
//    if (checkboxSet[i].checked)
if (checkboxSet.checked)
//      arr[j++] = i;
//  if (arr.length > 0)
    return 1;
  else
    return -1;
  }

// validate checkbox
function CheckCheckBox(checkBox, strMsg)
{
  if (getCheckedCheckboxes(checkBox) == -1)
    {
			if (bValid)
			{
				alert(strMsg);
				bValid = false;
			}
	}
}

//  else if (getCheckedCheckboxes(form.hobbiesCheckbox).length != 2)
//    {
//    alert("Please choose *exactly* two hobbies.");
//    return false;
//    }
 
 
// validate radio
function CheckRadio(radio, strMsg)
	{
	  if (getCheckedRadioButton(radio) == -1)
	    {
			if (bValid)
			{
				alert(strMsg);
				bValid = false;
			}
		}
	}

function CheckPassword()
    {
        sString = new String(f.Password.value);
        if (sString.length < 4 || sString.length > 16)
        {
            if (bValid)
            {
                alert("Your Password must be between 4 and 16 characters!");
                bValid = false;
            }
        }
        if (f.Password.value != f.Confirm.value)
        {
            if (bValid)
            {
                alert("The Password fields must match!");
                bValid = false;
            }
        }
    }

function CheckEMail()
    {
        sString = new String(f.Email.value);
        if (sString.indexOf("@", 0) == -1)
        {
            if (bValid)
            {
                alert("Please include a valid Email Address in the format 'name@domain.xxx'");
                bValid = false;
            }
        }
        if (sString.indexOf(".", 0) == -1)
        {
            if (bValid)
            {
                alert("Please include a valid Email Address in the format 'name@domain.xxx'");
                bValid = false;
            }
        }
    }

function CheckPhone()
    {
        var sOrigPhone = new String(f.HomePhone.value);
        var sNewPhone = new String();
        var i;

        if (bValid != true)
            //an error was previously detected
            return;

        for(i=0;i < sOrigPhone.length;i++)
        {
            if (!isNaN(parseInt(sOrigPhone.charAt(i))))
            {
                sNewPhone = sNewPhone + sOrigPhone.charAt(i);
            }
        }
        if (sNewPhone.length < 10)
        {
            bValid = false;
            alert("Your phone number must be at least 10 digits long");
        }
    }

function PWKeyUp()
    {
        var sChar;
        var lLength;

        if(!f)
            f = document.freeGoBoating;

        sString = new String(f.Password.value);
        lLength = sString.length;

        for(i = 0; i < lLength; i++) {
            sChar = sString.charAt(i);
            if ((sChar >= "0" && sChar <= "9") || (sChar >= "a" && sChar <= "z") || (sChar >= "A" && sChar <= "Z"))    {
            }
            else {
                alert("Your Password must contain only Letters or Numbers!");
                f.Password.value = sString.substring(0, sString.length-1);
            }
        }
    }


//-->