var date1 = "20090219"
var date2 = "20090416"
var date3 = "20090521"
var date4 = "20090618"
var date5 = "20090716"
var date6 = "20090917"
var date7 = "20091015"
var date8 = "20091119"

sysDate = new Date();

newDate1 = (sysDate.getMonth() + 1) + "/";
newDate2 = sysDate.getDate() + "/";
newDate3 = sysDate.getFullYear();

if(newDate1.length == 2){
   newDate1 = "0" + newDate1;
}
if(newDate2.length == 2){
   newDate2 = "0" + newDate2;
}

newDate = newDate1 + newDate2 + newDate3;


tDate = newDate.substring(6,10)+newDate.substring(0,2)+newDate.substring(3,5);

if(document.trReg.feb.value && tDate > date1)
{
	document.trReg.feb.disabled = true;
}

if(document.trReg.apr.value && tDate > date2)
{
	document.trReg.apr.disabled = true;
}

if(document.trReg.may.value && tDate > date3)
{
	document.trReg.may.disabled = true;
}

if(document.trReg.jun.value && tDate > date4)
{
	document.trReg.jun.disabled = true;
}

if(document.trReg.jul.value && tDate > date5)
{
	document.trReg.jul.disabled = true;
}

if(document.trReg.sep.value && tDate > date6)
{
	document.trReg.sep.disabled = true;
}

if(document.trReg.oct.value && tDate > date7)
{
	document.trReg.oct.disabled = true;
}

if(document.trReg.nov.value && tDate > date8)
{
	document.trReg.nov.disabled = true;
}

function eMailValid(eMail){
  //WO18821 invalidChars = "/:,;"
  invalidChars = "/:,;<"    //WO18821 add <  

  for (i=0; i<invalidChars.length; i++) {
   badChar = invalidChars.charAt(i)
   if (eMail.indexOf(badChar,0) != -1) {
    return false
   }
  }

  atPos = eMail.indexOf("@", 1)
   if (atPos == -1) {
    return false
   }

  if (eMail.indexOf("@", atPos+1) != -1) {
   return false
  }

  periodPos = eMail.indexOf(".", atPos)
   if (periodPos == -1) {
    return false
   }

  if (periodPos+3 > eMail.length) {
    return false
  }

 return true

}

sysDate = new Date();

newDate1 = (sysDate.getMonth() + 1) + "/";
newDate2 = sysDate.getDate() + "/";
newDate3 = sysDate.getFullYear();

if(newDate1.length == 2){
   newDate1 = "0" + newDate1;
}
if(newDate2.length == 2){
   newDate2 = "0" + newDate2;
}

newDate = newDate1 + newDate2 + newDate3;


tDate = newDate.substring(6,10)+newDate.substring(0,2)+newDate.substring(3,5);

function ValidateForm() {

var objRegExp;
//Make sure at least one session is selected
if(document.trReg.feb.checked != true &&  //161
   document.trReg.apr.checked != true &&
   document.trReg.may.checked != true &&
   document.trReg.jun.checked != true &&
   document.trReg.jul.checked != true &&
   document.trReg.sep.checked != true &&
   document.trReg.oct.checked != true &&
   document.trReg.nov.checked != true) {
   alert("You must select at least one Financial Aid Training Session")
   return false
  }

//If the session date have ended, do not allow registration

if(document.trReg.feb.checked && tDate > date1 ||
   document.trReg.apr.checked && tDate > date2 ||
   document.trReg.may.checked && tDate > date3 ||
   document.trReg.jun.checked && tDate > date4 ||
   document.trReg.jul.checked && tDate > date5 ||
   document.trReg.sep.checked && tDate > date6 ||
   document.trReg.oct.checked && tDate > date7 ||
   document.trReg.nov.checked && tDate > date8 ) {
   alert("At least one of the session(s) selected has ended. Please check the calendar for another session of interest.")
   document.trReg.feb.focus()
   return false
  }




//Make Sure First Name is Supplied
if(document.trReg.fName.value.length <= 0) {
   alert("The First Name of the Primary Attendee must be supplied")
   document.trReg.fName.focus()
   document.trReg.fName.select()
   return false
  }

//Make Sure First Name contains no special characters
objRegExp = /^[a-zA-Z\s]{1,14}$/;
if(objRegExp.test(document.trReg.fName.value) == false) { 
   alert("The First Name of the Primary Attendee may not contain any special characters")
   document.trReg.fName.focus()
   document.trReg.fName.select()
   return false
  }

//Make Sure Last Name is Supplied
if(document.trReg.lName.value.length <= 0) {
   alert("The Last Name of the Primary Attendee must be supplied")
   document.trReg.lName.focus()
   document.trReg.lName.select()
   return false
  }

//Make Sure Last Name contains no special characters
objRegExp = /^[A-Za-z0-9\s]{1,25}$/;
if(objRegExp.test(document.trReg.lName.value) == false) {
   alert("The Last Name of the Primary Attendee may not contain any special characters")
   document.trReg.lName.focus()
   document.trReg.lName.select()
   return false
  }

//Make Sure Title contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s]{1,25}$/;
if(objRegExp.test(document.trReg.title.value) == false && document.trReg.title.value.length > 0) {
   alert("The Title of the Primary Attendee may not contain any special characters")
   document.trReg.title.focus()
   document.trReg.title.select()
   return false
  }

//Make Sure Years of Experience contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s]{1,10}$/;
if(objRegExp.test(document.trReg.yrsExp.value) == false && document.trReg.yrsExp.value.length > 0) {
   alert("The Years of Experience of the Primary Attendee may not contain any special characters")
   document.trReg.yrsExp.focus()
   document.trReg.yrsExp.select()
   return false
  }

//Make Sure School is Supplied
if(document.trReg.school.value.length <= 1) {
   alert("The School Name must be supplied")
   document.trReg.school.focus()
   document.trReg.school.select()
   return false
  }

//Make sure School contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s-_]{1,30}$/;
if(objRegExp.test(document.trReg.school.value) == false && document.trReg.school.value.length > 0) {
   alert("The School Name may not contain any special characters")
   document.trReg.school.focus()
   document.trReg.school.select()
   return false
  }

// Area Code must be present and numeric
       if (document.trReg.areaCode.value.length < 3) {
        alert("The Area Code must be at supplied and be at least 3 digits")
        document.trReg.areaCode.focus()    //bring focus to form field
        document.trReg.areaCode.select()   //select form field
        return false
      }

    // loop to make sure Area Code value is numeric
    for (var i=0; i < document.trReg.areaCode.value.length; i++) {
      var num = document.trReg.areaCode.value.charAt(i)
      if ( num < "0" || num > "9") {
        alert("The Area Code must be a number")
        document.trReg.areaCode.focus()    //bring focus to form field
        document.trReg.areaCode.select()   //select form field
        return false
      }
    }

// The Phone Number must be present and numeric
       if (document.trReg.phone.value.length < 7) {
        alert("The Phone Number must be at supplied and be at least 7 digits")
        document.trReg.phone.focus()    //bring focus to form field
        document.trReg.phone.select()   //select form field
        return false
      }

    // loop to make sure Phone Number value is numeric
    for (var i=0; i < document.trReg.phone.value.length; i++) {
      var num = document.trReg.phone.value.charAt(i)
      if ( num < "0" || num > "9") {
        alert("The Phone Number must be a number (i.e. 555-5555 would be 5555555")
        document.trReg.phone.focus()    //bring focus to form field
        document.trReg.phone.select()   //select form field
        return false
      }
    }

// Phone Extension must be numeric if present
  if(document.trReg.phoneExt.value.length > 0) {

    // loop to make sure Phone Extension value is numeric
    for (var i=0; i < document.trReg.phoneExt.value.length; i++) {
      var num = document.trReg.phoneExt.value.charAt(i)
      if ( num < "0" || num > "9") {
        alert("The Phone Extension must be a number")
        document.trReg.phoneExt.focus()    //bring focus to form field
        document.trReg.phoneExt.select()   //select form field
        return false
      }
    }
   }

//Check to make sure email address is valid if present
if (document.trReg.eMail.value.length > 0){
 if (!eMailValid(document.trReg.eMail.value)){
   alert("Email address is not valid")
   document.trReg.eMail.focus()
   document.trReg.eMail.select()
   return false
 }
}


//If First Name is supplied Last Name must be supplied
if(document.trReg.fNameA1.value.length > 0  &&
   document.trReg.lNameA1.value.length <= 0) {
   alert("The Last Name of Secondary Attendee 1 must be supplied")
          document.trReg.lNameA1.focus()
          document.trReg.lNameA1.select()
          return false
       }

//If Last Name is supplied First Name must be supplied
if(document.trReg.lNameA1.value.length > 0  &&
   document.trReg.fNameA1.value.length <= 0) {
   alert("The First Name of Secondary Attendee 1 must be supplied")
          document.trReg.fNameA1.focus()
          document.trReg.fNameA1.select()
          return false
       }

//If Title is supplied First Name and Last must be supplied
if(document.trReg.titleA1.value.length > 0 && (document.trReg.fNameA1.value.length <= 0  ||
   document.trReg.lNameA1.value.length <= 0)) {
   alert("The Secondary Attendee 1 Name must be supplied if a Title is supplied")
          document.trReg.fNameA1.focus()
          document.trReg.fNameA1.select()
          return false
       }

//If Years Experience is supplied First Name and Last must be supplied
if(document.trReg.yrsExpA1.value.length > 0 && (document.trReg.fNameA1.value.length <= 0  ||
   document.trReg.lNameA1.value.length <= 0)) {
   alert("The Secondary Attendee 1 Name must be supplied if Years Experience is supplied")
          document.trReg.fNameA1.focus()
          document.trReg.fNameA1.select()
          return false
       }



//Make sure extra attendee First Name contains no special characters if value is entered
objRegExp = /^[a-zA-Z\s]{1,14}$/;
if(objRegExp.test(document.trReg.fNameA1.value) == false && document.trReg.fNameA1.value.length > 0) {
   alert("The First Name of the Secondary Attendee may not contain any special characters")
   document.trReg.fNameA1.focus()
   document.trReg.fNameA1.select()
   return false
  }

//Make sure extra attendee Last Name contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s]{1,25}$/;
if(objRegExp.test(document.trReg.lNameA1.value) == false && document.trReg.lNameA1.value.length > 0) {
   alert("The Last Name of the Secondary Attendee may not contain any special characters")
   document.trReg.lNameA1.focus()
   document.trReg.lNameA1.select()
   return false
  }

//Make sure extra attendee Title contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s]{1,25}$/;
if(objRegExp.test(document.trReg.titleA1.value) == false && document.trReg.titleA1.value.length > 0) {
   alert("The Title of the Secondary Attendee may not contain any special characters")
   document.trReg.titleA1.focus()
   document.trReg.titleA1.select()
   return false
  }

//Make sure extra attendee Years of Experience contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s]{1,10}$/;
if(objRegExp.test(document.trReg.yrsExpA1.value) == false && document.trReg.yrsExpA1.value.length > 0) {
   alert("The Years of Experience of the Secondary Attendee may not contain any special characters")
   document.trReg.yrsExpA1.focus()
   document.trReg.yrsExpA1.select()
   return false
  }

//If First Name is supplied Last Name must be supplied
if(document.trReg.fNameA2.value.length > 0  &&
   document.trReg.lNameA2.value.length <= 0) {
   alert("The Last Name of Secondary Attendee 2 must be supplied")
          document.trReg.lNameA2.focus()
          document.trReg.lNameA2.select()
          return false
       }

//If Last Name is supplied First Name must be supplied
if(document.trReg.lNameA2.value.length > 0  &&
   document.trReg.fNameA2.value.length <= 0) {
   alert("The First Name of Secondary Attendee 2 must be supplied")
          document.trReg.fNameA2.focus()
          document.trReg.fNameA2.select()
          return false
       }
//If Title is supplied First Name and Last must be supplied
if(document.trReg.titleA2.value.length > 0 && (document.trReg.fNameA2.value.length <= 0  ||
   document.trReg.lNameA2.value.length <= 0)) {
   alert("The Secondary Attendee 2 Name must be supplied if a Title is supplied")
          document.trReg.fNameA2.focus()
          document.trReg.fNameA2.select()
          return false
       }

//If Years Experience is supplied First Name and Last must be supplied
if(document.trReg.yrsExpA2.value.length > 0 && (document.trReg.fNameA2.value.length <= 0  ||
   document.trReg.lNameA2.value.length <= 0)) {
   alert("The Secondary Attendee 2 Name must be supplied if Years Experience is supplied")
          document.trReg.fNameA2.focus()
          document.trReg.fNameA2.select()
          return false

}

//Make sure extra attendee First Name contains no special characters if value is entered
objRegExp = /^[a-zA-Z\s]{1,14}$/;
if(objRegExp.test(document.trReg.fNameA2.value) == false && document.trReg.fNameA2.value.length > 0) {
   alert("The First Name of the Secondary Attendee may not contain any special characters")
   document.trReg.fNameA2.focus()
   document.trReg.fNameA2.select()
   return false
  }

//Make sure extra attendee Last Name contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s]{1,25}$/;
if(objRegExp.test(document.trReg.lNameA2.value) == false && document.trReg.lNameA2.value.length > 0) {
   alert("The Last Name of the Secondary Attendee may not contain any special characters")
   document.trReg.lNameA2.focus()
   document.trReg.lNameA2.select()
   return false
  }

//Make sure extra attendee Title contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s]{1,25}$/;
if(objRegExp.test(document.trReg.titleA2.value) == false && document.trReg.titleA2.value.length > 0) {
   alert("The Title of the Secondary Attendee may not contain any special characters")
   document.trReg.titleA2.focus()
   document.trReg.titleA2.select()
   return false
  }

//Make sure extra attendee Years of Experience contains no special characters if value is entered
objRegExp = /^[A-Za-z0-9\s]{1,10}$/;
if(objRegExp.test(document.trReg.yrsExpA2.value) == false && document.trReg.yrsExpA2.value.length > 0) {
   alert("The Years of Experience of the Secondary Attendee may not contain any special characters")
   document.trReg.yrsExpA2.focus()
   document.trReg.yrsExpA2.select()
   return false
  }

}