<!--

var submitcount=0;
var reEmail = /^.+\@.+\..+$/;
var reNonWhiteSpace = /^\w+$/;
var reNumberOnly =/^\d+$/;

function isEmail(elm){
  return reEmail.test(elm.value)
}

function isNumber(elm){
  return reNumberOnly.test(elm.value)
}

function isLongEnough(elm){
	if( //!reNonWhiteSpace.test(elm.value)  ||
	  elm.value.length < 8)
	  return false;
	else 
          return true;
}

function isSelected(elm){
	if(elm.value == 0 || elm.value == "Please Choose One" || elm.value == "")
	return false;
	else return true;
}

function isRegFormRadioSelected(radio){
  if(!radio.length){
    if(radio.checked){
      return true;
    }else{
      return false;
    }
  }else{
    for (var i = 0; i < radio.length; i++){
    if(radio[i].checked)
      var t = 1
    }
    if(t == null){
      return false;
    }else{
      return true;
    }
  }
}

// BEGIN REGISTRATION VALIDATION
function isRegistrationReady(form){

  if(form.VersionID != null && isRegFormRadioSelected(form.VersionID)== false){
    submitcount=0;
    alert("Please select a Course.");
    form.VersionID[0].focus();
    return false;
  }
  
  if(form.StudCompName.value.length==0){
		submitcount=0;
		alert("Please enter your company name.\n If no company name enter None");
		form.StudCompName.focus();
		return false;
	}
  
  if(form.StudRegName.value.length==0){
		submitcount=0;
		alert("Please enter your company region name.\n If none, enter Company Name exactly as you entered it above.");
		form.StudRegName.focus();
		return false;
	}
  
  if(form.StudDivName.value.length==0){
		submitcount=0;
		alert("Please enter your company division name.\n If none, enter Company Name exactly as you entered it above.");
		form.StudDivName.focus();
		return false;
	}
  
  if(form.StudDeptName.value.length==0){
		submitcount=0;
		alert("Please enter your company department name.\n If none, enter Company Name exactly as you entered it above.");
		form.StudDeptName.focus();
		return false;
	}
  
  if(form.BusAddr1 != null && form.BusAddr1.value.length==0){
		submitcount=0;
		alert("Please enter your business address.");
		form.BusAddr1.focus();
		return false;
	}
  
  if(form.BusCity != null && form.BusCity.value.length==0){
		submitcount=0;
		alert("Please enter your business city.");
		form.BusCity.focus();
		return false;
	}
  
  if(form.BusPostCode != null && form.BusPostCode.value.length==0){
		submitcount=0;
		alert("Please enter your business postal or zip code.");
		form.BusPostCode.focus();
		return false;
	}
  
  if(form.StudTitle.value.length==0){
		submitcount=0;
		alert("Please enter the title of your position with the company.");
		form.StudTitle.focus();
		return false;
	}
  
  if(form.StudFirstName.value.length==0){
		submitcount=0;
		alert("Please enter your first name.");
		form.StudFirstName.focus();
		return false;
	}
  
  if(form.StudLastName.value.length==0){
		submitcount=0;
		alert("Please enter your last name.");
		form.StudLastName.focus();
		return false;
	}
  
  if(form.StudDayPhone.value.length==0){
		submitcount=0;
		alert("Please enter your daytime telephone number.");
		form.StudDayPhone.focus();
		return false;
	}
  
  if(form.StudGender != null && form.StudGender.value==0){
		submitcount=0;
		alert("Please select your gender.");
		form.StudGender.focus();
		return false;
	}
  
  if(isEmail(form.StudEmailAddr)== false){
		submitcount=0;
		alert("Please enter your correct email address.");
		form.StudEmailAddr.focus();
		return false;
	}
  
  if(!isLongEnough(form.StudPassword)){
		submitcount=0;
		alert("Please choose a password of 8 to 20 characters.\n Don't use any of these \" ' < > { } [ ] % * ^ |");
		form.StudPassword.focus();
		return false;
	}
  
  if(!isLongEnough(form.StudConfirmPassword)){
		submitcount=0;
		alert("Please confirm your password of 8 to 20 characters.\n Don't use any of these \" ' < > { } [ ] % * ^ |");
		form.StudConfirmPassword.focus();
		return false;
	}
  
  if(form.StudPassword.value != form.StudConfirmPassword.value){
		submitcount=0;
		alert("Your confirmed password did not match your password.\nPlease enter them again.");
		form.StudConfirmPassword.focus();
		return false;
	}
  
  if(form.StudDLNumber != null && form.StudDLNumber.value.length==0){
		submitcount=0;
		alert("Please enter your drivers license number.");
		form.StudDLNumber.focus();
		return false;
	}
  
  if(form.StudLPNumber != null && form.StudLPNumber.value.length==0){
		submitcount=0;
		alert("Please enter your vehicle license plate number (no spaces).");
		form.StudLPNumber.focus();
		return false;
	}
  
  if(form.IRCourse != null && form.IRCourse.value=='0|0' && form.TDCourse != null && form.TDCourse.value=='0|0'){
		submitcount=0;
		alert("You must select a course for either Ticket Dismissal or Insurance Reduction.");
		form.TDCourse.focus();
		return false;
	}
  
  if((form.TDCourse != null && form.TDCourse.value!='0|0') && (form.TicketCourtName != null && form.TicketCourtName.value.length==0)){
		submitcount=0;
		alert("You must enter the Court Name on your ticket.");
		form.TicketCourtName.focus();
		return false;
	}
  
  if((form.TDCourse != null && form.TDCourse.value!='0|0') && (form.TicketCountyName != null && form.TicketCountyName.value.length==0)){
		submitcount=0;
		alert("You must enter the County Name on your ticket.");
		form.TicketCountyName.focus();
		return false;
	}
  
  if(form.CCType != null && form.CCType.value=='None' && form.ECBankName != null && form.ECBankName.value.length==0){
		submitcount=0;
		alert("You must select a method of payment.\nEither select a Credit Card type or enter the name of your Bank");
		form.CCType.focus();
		return false;
	}
  
  if((form.CCType != null && form.CCType.value!='None') && (form.CCNum.value.length==0 || form.CCVV.value.length==0 || form.CCExpirMonth.value=='00' || form.CCExpirYear.value=='00')){
		submitcount=0;
		alert("You must fill out or select all your Credit Card information requested.");
		form.CCType.focus();
		return false;
	}
  
  if((form.ECBankName != null && form.ECBankName.value.length!=0) && (form.ECAcctName.value.length==0 || form.ECAcctNum.value.length==0 || form.ECRouteNum.value.length==0)){
		submitcount=0;
		alert("You must fill out all your Checking Account information requested.");
		form.ECBankName.focus();
		return false;
	}
  
  // set var checkbox_choices to zero
  //var checkbox_choices = 0;
  // Loop from zero to the one minus the number of checkbox button selections
  //for (counter = 0; counter < registration.GroupAssign.length; counter++){
    // If a checkbox has been selected it will return true
    // (If not it will return false)
    //if (registration.GroupAssign[counter].checked){
      //checkbox_choices = checkbox_choices + 1;
    //}
  //}
  
  //if (checkbox_choices < 1 ){
    //submitcount=0;
    // If there were less then selections made display an alert box 
    //alert("You must assign at least one group.")
    //return false;
  //}

  if (submitcount == 0){
    submitcount++;
    return true;
  } else {
    return false;
  }
}

// BEGIN FINAL INFORMATION VALIDATION
function isFinalInfoReady(form){
  // set var checkbox_choices to zero
  var checkbox_choices = 0;
  //Checks to see if more then one checkbox with the same name
  if (!form.CourseAgreement.length){
    if (form.CourseAgreement.checked){
      checkbox_choices = 1;
    }
  } else {
    checkbox_length = form.CourseAgreement.length;
    // Loop from zero to the one minus the number of checkbox button selections
    for (counter = 0; counter < form.CourseAgreement.length; counter++){
      // If a checkbox has been selected it will return true
      // (If not it will return false)
      if (form.CourseAgreement[counter].checked){
        checkbox_choices = checkbox_choices + 1;
      }
    }
  }
  
  if(form.BillFirstName.value.length==0){
		submitcount=0;
		alert("Please enter your billing first name.");
		form.BillFirstName.focus();
		return false;
	}
  
  if(form.BillLastName.value.length==0){
		submitcount=0;
		alert("Please enter your billing last name.");
		form.BillLastName.focus();
		return false;
	}
  
  if(form.BillAddr1.value.length==0){
		submitcount=0;
		alert("Please enter your billing address.");
		form.BillAddr1.focus();
		return false;
	}
  
  if(form.BillCity.value.length==0){
		submitcount=0;
		alert("Please enter your billing city.");
		form.BillCity.focus();
		return false;
	}
  
  if(form.BillPostCode.value.length==0){
		submitcount=0;
		alert("Please enter your billing postal or zip code.");
		form.BillPostCode.focus();
		return false;
	}
  
  if(form.BillCountry.value=='None'){
		submitcount=0;
		alert("Please select your billing country.");
		form.BillCountry.focus();
		return false;
	}
  
  if(form.CertAddr1.value.length==0){
		submitcount=0;
		alert("Please enter your certificate mailing address.");
		form.CertAddr1.focus();
		return false;
	}
  
  if(form.CertCity.value.length==0){
		submitcount=0;
		alert("Please enter your certificate mailing city.");
		form.CertCity.focus();
		return false;
	}
  
  if(form.CertPostCode.value.length==0){
		submitcount=0;
		alert("Please enter your certificate mailing postal or zip code.");
		form.CertPostCode.focus();
		return false;
	}
  
  if(form.CertCountry.value=='None'){
		submitcount=0;
		alert("Please select your certificate mailing country.");
		form.CertCountry.focus();
		return false;
	}
  
  if(form.ReferrerType.value=='None'){
		submitcount=0;
		alert("Please select how you heard about us.");
		form.ReferrerType.focus();
		return false;
	}
  
  if (checkbox_choices < 1 ){
    submitcount=0;
    // If there were less then selections made display an alert box 
    alert("To proceed you must understand and agree with the terms and conditions.")
    if (!form.CourseAgreement.length){
      form.CourseAgreement.focus();
    } else {
      form.CourseAgreement[1].focus();
    }
    return false;
  }
  
  if (submitcount == 0){
    submitcount++;
    return true;
  } else {
    return false;
  }
}

// BEGIN LOGIN VALIDATION
function isLoginReady(form){
	if(form.EmailAddress.value.length==0){
		submitcount=0;
		alert("Please enter your email address");
		form.EmailAddress.focus();
		event.cancelBubble=true;
		return false;
	}

	if(form.Password.value.length==0){
		submitcount=0;
		alert("Please enter your password");
		form.Password.focus();
        event.cancelBubble=true;
		return false;
	}

if (submitcount == 0){
  submitcount++;
  return true;
  } else {
    return false;
  }
}
// END LOGIN VALIDATION

// BEGIN COURSE REGISTRATION VALIDATION
function isCourseRegistrationReady(form){
  if(isRegFormRadioSelected(form.VersionID)== false){
    submitcount=0;
    alert("Please select a Course.");
    return false;
  }
  
  if (submitcount == 0){
    submitcount++;
    return true;
    } else {
      return false;
    }
}
// END COURSE REGISTRATION VALIDATION


function isSendPasswordReady(form){
	if(form.EmailAddress.value.length==0){
		submitcount=0;
		alert("Please enter your email address");
		form.EmailAddress.focus();
		event.cancelBubble=true;
		return false;
	}

if (submitcount == 0){
  submitcount++;
  return true;
  } else {
    return false;
  }

}

//first field focus
function firstFocus()
{
   if (document.forms.length > 0)
   {
      var TForm = document.forms[0];
      for (i=0;i<TForm.length;i++)
      {
         if ((TForm.elements[i].type=="checkbox")||
				 	 (TForm.elements[i].type=="text")||
           (TForm.elements[i].type=="textarea")||
           (TForm.elements[i].type.toString().charAt(0)=="s"))
         {
//alert("putting focus in place")
            document.forms[0].elements[i].focus();
            break;
         }
      }
   }
}

//firstFocus()

//-->