function checkDate(strDate, strMonth, strYear, objTarget) {
  var strMonthNumber = 0
  var strCompiledDate = strDate + " " + strMonth + " " + strYear;

  // If the year is blank then return to calling program.
  if (strYear == "") {return true}
  
  /* Using form values, create a new date object
      which looks like "Wed Jan 1 00:00:00 EST 1975". */
  var datCompiledDate = new Date( strCompiledDate );
  
  /* Convert the date to a string so we can parse it. */
  var strCompiledDate = datCompiledDate.toGMTString();

  /* Split the string at every space and put the values into an array so,
      using the previous example, the first element in the array is "Wed", the
      second element is "Jan", the third element is "1", etc. */
  var arrCompiledDate = strCompiledDate.split( ' ' );

  /* If we entered "Feb 31, 1975" in the form, the "new Date()" function
     converts the value to "Mar 3, 1975". Therefore, we compare the month
     in the array with the month we entered into the form. If they match,
     then the date is valid, otherwise, the date is NOT valid. */
  if ( arrCompiledDate[2] != strMonth ) {
    alert( 'Please ensure that a valid date is entered.' );
    return false
    } else {
               // Retrieve Month Number String         
              strMonthNumber = (strMonth == "Jan") ? "1" : strMonthNumber
              strMonthNumber = (strMonth == "Feb") ? "2" : strMonthNumber
              strMonthNumber = (strMonth == "Mar") ? "3" : strMonthNumber
              strMonthNumber = (strMonth == "Apr") ? "4" : strMonthNumber
              strMonthNumber = (strMonth == "May") ? "5" : strMonthNumber
              strMonthNumber = (strMonth == "Jun") ? "6" : strMonthNumber
              strMonthNumber = (strMonth == "Jul") ? "7" : strMonthNumber
              strMonthNumber = (strMonth == "Aug") ? "8" : strMonthNumber 
              strMonthNumber = (strMonth == "Sep") ? "9" : strMonthNumber
              strMonthNumber = (strMonth == "Oct") ? "10" : strMonthNumber
              strMonthNumber = (strMonth == "Nov") ? "11" : strMonthNumber
              strMonthNumber = (strMonth == "Dec") ? "12" : strMonthNumber
             
              /*  Write out the Value of the consolidated Date */
              objTarget.value = strMonthNumber + "/" + strDate + "/" + strYear;
              return true
              }  // End of the else valid Date.
} // End of the checkDate function.

// 
//  Kryos Systems
//
//  Description:   The validatePhone function is used to validate and return the phone number to the 
//                        calling routine for display in the hidden phone number field.
function validatePhone(objPhone,strAC, strPP, strPS, bolValidate)
{
    // Build the Phone Number in case Validation is not requried.
    var objAreaCode = objPhone.elements[strAC]
    var objPP = objPhone.elements[strPP]
    var objPS = objPhone.elements[strPS]

    var strPhoneNumber = "(" + objAreaCode.value + ") " + objPP.value + "-" + objPS.value;

   // Validate the Date.
   if (bolValidate != 0) {
      if ((bolValidate == 2 ) & ((objAreaCode.value == "") | (objPP.value == "") | (objPS.value == ""))) {
           alert("Please ensure the Phone Number is in the format (xxx) xxx-xxxx") 
           //objAreaCode.focus()
          return ""}
          
      // Validate the Area Code    
      if  ((objAreaCode.value != "") & (objAreaCode.value.length < 3)) {
         alert("Please ensure the Area Code is at least 3 numbers - more for International Numbers")
         if (bolValidate == 2) {
             //objAreaCode.focus()
            }
          return ""}      
     
      // Ensure main body of Phone number is correct. 
      if  ((objPP.value != "") & (objPP.value.length != 3)) {
         alert("Please ensure the phone number prefix is 3 digits")
         if (bolValidate == 2) {
             //objPP.focus()
             }
          return ""}         
          
      // Ensure main body of Phone number is correct. 
      if  ((objPS.value != "") & (objPS.value.length != 4)) {
         alert("Please ensure the phone number suffix is 4 digits")
         if (bolValidate == 2) {
             //objPS.focus()
             }
          return ""}         
          
      else {return strPhoneNumber}}
    else {return strPhoneNumber}
} // End of the the validatePhone Funtion


function funMainCheckPhoneNumber(objNumber ,intDesiredLength ,strName, objAreaCode,objPP,objPS,objPhoneNumber)
//  Description:   The function takes a field from a phone number and determines if it is of the proper
//					  length and is all numbers.  If it is valid (and all the other fields have a value) then the
//					  phone number is set.
{

var blnValid = "No";
if (objNumber.value != "")
	{if (funValidPhone(objNumber,intDesiredLength, strName) == "No")
		{objPhoneNumber.value = ""
		objNumber.focus()}
    else
		{if (funCheckPhoneNumbers(objAreaCode,objPP,objPS) == "OK")
			{objPhoneNumber.value = funGetPhoneNumber(objAreaCode,objPP,objPS)
			blnValid = "Yes"}}	
	if (blnValid == "No")
		{objPhoneNumber.value = ""}}

 return ""
}

function funGetPhoneNumber(objAreaCode,objPP,objPS)
{return "(" + objAreaCode.value + ") " + objPP.value + "-" + objPS.value}

function funValidPhone(objNumber,intDesiredLength,strName)
//  Description:   The function takes a field from a phone number and determines if it is of the proper
//					  length and is all numbers.  If it is valid (and all the other fields have a value) then the
//					  phone number is set.
{
var blnValid = "Yes"

if (objNumber.value.length != "")
	{	if ((objNumber.value.length < intDesiredLength) && (strName == "area code"))
		{funSetErrorMessage( "Please ensure that the " + strName + " is at least " + intDesiredLength + " numbers.")
		blnValid = "No"}
	else
		{if ((objNumber.value.length != intDesiredLength) && (strName != "area code"))
			{funSetErrorMessage( "Please ensure that the " + strName + " has " + intDesiredLength + " numbers.")
			blnValid = "No"}
		else {if (funIsNumber(objNumber) == "No")
				{funSetErrorMessage( "Please ensure that the " + strName + " has only numbers.")
				blnValid = "No"}}
		}
	}
return blnValid
}


function funCheckPhoneNumbers(objAreaCode,objPP,objPS)
{if ((objAreaCode.value != "") && (objPP.value != "") && (objPS.value != "")) {return "OK"} else {return "Not OK"}}   

function funIsNumber(objNumber)
//  Description:   This function determines if a value contains only numbers
{var intCurrentPosition = -1
var blnNumber = "Yes"
var inStr = objNumber.value

// Loop through the string and see if any character is anything besides a number
for (intCurrentPosition = 0 ; intCurrentPosition < inStr.length ;  intCurrentPosition ++)
	{var ch = inStr.substring( intCurrentPosition , intCurrentPosition+1)
	if ((ch < "0") || (ch > "9"))
		{if (ch != ".") {blnNumber = "No"}}}
}

function funAreLetters(objString)
//  Description:   This function determines if a value contains only letters; be it capital or small.

{
var intCurrentPosition = -1
var blnLetters = "Yes"
var inStr = objString.value

// Loop through the string and see if any character is anything besides a letter
for (intCurrentPosition = 0 ; intCurrentPosition < inStr.length ;  intCurrentPosition ++)
	{
	var ch = inStr.substring( intCurrentPosition , intCurrentPosition+1)
	if (((ch < "a") || (ch > "z")) && ((ch < "A") || (ch > "Z")))
		{blnLetters = "No"}}
return blnLetters}



function validatePostalZipCode(objPostalZip,strCountry)
//
//	This function uses the name of a country to determine the method of validation.  If the country is Canada it will check it for being a valid postal code.  If
//	the country is United Stated it checks it as a valid zip code.  If it is blank then it checks to see if is valid as either a postal code or a zip code.  If it is none
//	of the above it returns an error message.  When the Postal/Zip is not valid for its condition an error message is returned
{
var blnFailed = "No"

if (objPostalZip.value == "") {return}
if (strCountry == "Canada") {
	blnFailed = validatePostalCode(objPostalZip,blnFailed)

	if (blnFailed == "Yes")	{
		alert ("Please ensure that the postal code is L#L#L# or L#L #L# (L = Letter)")
		return blnFailed}	
	}
else if (strCountry == "United States")
	{
	blnFailed = validateZipCode(objPostalZip,blnFailed)
	if (blnFailed == "Yes")
		{alert ("Please ensure that the zip code is #####, ##### ####, or #####-#### (# = Number)")
	     return blnFailed}
	}
else if (strCountry == "")
	{
	blnFailed = validatePostalCode(objPostalZip,blnFailed)
	if (blnFailed =="Yes")
		{blnFailed = "No"
		blnFailed = validateZipCode(objPostalZip,blnFailed)
		if (blnFailed == "Yes")
			{alert ("Please ensure that the postal/zip is valid as either a postal or zip code")
			return blnFailed}}
	} else
	{alert ("Please ensure country is either Canada, United States or blank")
	return blnFailed}
}

function validateZipCode(objZipCode,blnFailed)
//
//	This function checks the zip code to determine if it is valid.  First it checks the length to make sure it isn't too big or too small.  Since there are two
//  different lengths of zip codes out there this handles both the ##### and #####-####.  It then checks to make sure the first 5 characters are 
//	numbers.  If they are it checks the sixth character to see if it is a hyphen and does different things based on the length.  If the length of the zip 
//  code is 9 then it means that no hyphen was there (ie entered as #########) and thus it squeezes a hyphen in.  If the length was ten characters
//  it just replaces the sixth character with a hyphen.  After inserting the hyphen the function makes sure the last four characters are numbers.  If it fails
//	any of the validation checks a variable is passed back saying that the validation failed.
{
var strZipCode = objZipCode.value

if ((strZipCode.length != 5) && (strZipCode.length != 9) && (strZipCode.length != 10))
	{blnFailed = "Yes"}
else 	{
	for (intCurrentPosition = 0 ; intCurrentPosition <=4 ;  intCurrentPosition ++)
		{var ch = strZipCode.charAt( intCurrentPosition)
		if ((ch < "0") || (ch > "9"))
			{blnFailed = "Yes"}}
	if (strZipCode.length >= 9)
		{if ((strZipCode.charAt(5) != "-") && (strZipCode.length == 9))
			{strZipCode = strZipCode.substring(0,5) + "-" + strZipCode.substring(5,10)}
		else if ((strZipCode.charAt(5) != "-") && (strZipCode.length == 10))
			{strZipCode = strZipCode.substring(0,5) + "-" + strZipCode.substring(6,10)	}
		for (intCurrentPosition = 6 ; intCurrentPosition <= 9 ;  intCurrentPosition ++)
			{var ch = strZipCode.charAt(intCurrentPosition)
			if ((ch < "0") || (ch > "9"))
				{blnFailed = "Yes"}}
		}
	}

if (blnFailed == "No")
	{objZipCode.value = strZipCode}
	
return blnFailed
}

function validatePostalCode(objPostalCode,blnFailed)
//
//	This function checks the postal code to see if it is valid as LLL LLL or LLLLLL.  First it checks the length to make sure it isn't too big or too small.  
//  If it is okay then it is changed to all uppercase.  Then the first 3 characters are checked to see if they are all letters.  If they are then the fourth
//  character is checked to see if it is a space.  If it is no then the length is checked.  If it is 6 characters it squeezes a space into the middle.  If it is 7
//  characters it replace the fourth character with a space.  Then it checks the last 3 characters to make sure they are numbers.  If it fails
//	any of the validation checks a variable is passed back saying that the validation failed.
{
var strPostalCode = objPostalCode.value

if ((strPostalCode.length < 6) || (strPostalCode.length > 7))
	{blnFailed = "Yes"}
else {
	strPostalCode = strPostalCode.toUpperCase()
	for (intCurrentPosition = 0 ; intCurrentPosition <= 2 ;  intCurrentPosition ++)
		{var ch = strPostalCode.charAt( intCurrentPosition)
		if (intCurrentPosition == 1)
			{if ((ch < "0") || (ch > "9"))
				{blnFailed = "Yes"}}
		else if ((ch < "A") || (ch > "Z"))
			{blnFailed = "Yes"}
		}
	if ((strPostalCode.length == 7) && (strPostalCode.charAt(3) != " "))
		{strPostalCode = strPostalCode.substring(0,3) + " " + strPostalCode.substring(4,7)}
	else if (strPostalCode.charAt(3) != " ")
		{strPostalCode = strPostalCode.substring(0,3) + " " + strPostalCode.substring(3,6)}
	for (intCurrentPosition = 4 ; intCurrentPosition <= 6 ;  intCurrentPosition ++)
		{
		var ch = strPostalCode.charAt(intCurrentPosition)
		if (intCurrentPosition == 5)
			{if ((ch < "A") || (ch > "Z"))
				{blnFailed = "Yes"}}
		else if ((ch < "0") || (ch > "9"))
			{blnFailed = "Yes"}}	
	}


if (blnFailed == "No")
	{objPostalCode.value = strPostalCode}
return blnFailed
}

function TrimEndSpaces(strTemp)
{
var intCurrentPosition = strTemp.length - 1
var intSpaceCounter = 0
var blnDone = "No"

while ((intCurrentPosition != 0) && (blnDone == "No"))
	{if (strTemp.charAt(intCurrentPosition) == " ")
		{intSpaceCounter ++}
	else
		{blnDone = "Yes"}
	intCurrentPosition --}

strTemp = strTemp.substring(0,(strTemp.length - intSpaceCounter))
return strTemp
}

function validatePercent(strPercent)
{
var strTemp = ""
var errMessage = ""

errMessage = funIsNumberOrPercent(strPercent) 

if  ((errMessage != "") && (strPercent != ""))
	{alert (errMessage)
	return "Yes"}
else 
	{if (strPercent.charAt(strPercent.length -1) == "%")
		{strTemp = strPercent.substring(0,strPercent.length-1)}
	else
		{strTemp = strPercent}
	if  ((strTemp != "") && ((strTemp > 100) || (strTemp < 0)))
		{alert ("Percent Values must be between 0 and 100.")
		return "Yes"}}
}

function funIsNumberOrPercent(strNumber)

//  Description:   This function determines if a value contains only numbers, pluses, minuses, or percent signs.  If it has any of the later three they
//						must be either in the first position (plus & minus) or last (percent). also if there are only signs then it is not valid.  Finally a percent
//						cannot be all symbols.  It must have some numbers.
{var intCurrentPosition = -1
var strError = ""
var intSignCount = 0
var intDecimalCount = 0

// Loop through the string and see if any character is anything besides a number, plus, minus, or percent
for (intCurrentPosition = 0 ; intCurrentPosition < strNumber.length ;  intCurrentPosition ++)
	{
	var ch = strNumber.charAt( intCurrentPosition)
	if  (((ch == "-") || ( ch == "+")) && (intCurrentPosition != 0))
		{strError = "Plusses and minuses can only begin a percent"
		}
	else if ((ch == "%") && (intCurrentPosition != strNumber.length -1))
		{strError = "Percent signs come at the end of a percent"
		}
	else if (((ch < "0") || (ch > "9")) && (ch != ".") && (ch != "%") && (ch != "+") && (ch != "-"))
		{strError = "A percent can only have #s, +, -, %, or decimals"
		}
	if ((ch == "+") || (ch == "-") || (ch == "%") || (ch == "."))
		{intSignCount ++}
	if (ch  == ".")
		{intDecimalCount ++
		if (intDecimalCount > 1)
			{strError = "Only one decimal in a percent"
			return "Yes"}}
	if (strError != "")
		{return strError}
	}
	
if (intSignCount ==strNumber.length)
	{strError = "A percent must have some numbers"
     }	
return strError
}

//**********************

function ClearFields()
// This function will clear all the values of all currently displayed fields.  It runs through all the elements on the page
//   and if the element is of the available to clear (see note below) then it is cleared.  Otherwise it is ignored.  One thing
//   to note is that with radio buttons, and list fields it makes sure that it hasn't cleared that field before (as they are
//   stored as several fields with the same name).
//
//   Note -This clears only the following fields (in notes terms):
//             Text, Rich Text, File Upload Control, Checkbox, Radio, Button, Listbox, and Dialog List
//
//   Given -   Nothing
//   Returns-  Nothing
//
//   Created - Duncan Dube 00/02/12
//
     {
     frmCurrentForm = top.fraMain.document.forms[0]
     strLastField = ""

     if (frmCurrentForm.elements.length>0)
          {
          for (i=0;i<frmCurrentForm.elements.length;i++)
               {
               switch(frmCurrentForm.elements[i].type)
                    {
                    case "text":
                         ClearTextField(i)
                         break;
                    case "select-one":
                         if (strLastField !=frmCurrentForm.elements[i].name)
                              {
                              ClearListField(i)
                              strLastField= frmCurrentForm.elements[i].name
                              }
                         break;
                    case "radio":
                         if (strLastField != frmCurrentForm.elements[i].name)
                              {
                              ClearRadioField(i)
                              strLastField= frmCurrentForm.elements[i].name
                              }
                         break;
                    case "checkbox":
                         ClearCheckBox(i)
                         break;
                    case "textarea" :
                         ClearTextField(i)
                         break;
                    case "file":
                         ClearTextField(i)
                         break;
                    }
               }
          }
     return
     }

//**********************

function ClearTextField(FieldNumber)
//This clears a text field at the element number it is passed
//
// Given  :    FieldNumber - the element array position of the field to clear
// Returns:    Nothing
//
// Created:    Duncan Dube 00/02/12

     {
     frmCurrentForm = top.fraMain.document.forms[0]
     frmCurrentForm.elements[FieldNumber].value=""
     }

//**********************

function ClearListField(FieldNumber)
//This clears a list field at the element number it is passed.  It clears it by setting the value to the first
//   possible choice in the list
//
// Given  :    FieldNumber - the element array position of the field to clear
// Returns:    Nothing
//
// Created:    Duncan Dube 00/02/12

     {
     frmCurrentForm = top.fraMain.document.forms[0]
     frmCurrentForm.elements[FieldNumber].selectedIndex = 0
     }

//**********************

function ClearRadioField(FieldNumber)
//This clears a radio field at the element number it is passed.  It clears it by setting the value to the first
//   possible choice in the list
//
// Given  :    FieldNumber - the element array position of the field to clear
// Returns:    Nothing
//
// Created:    Duncan Dube 00/02/12

     {
     frmCurrentForm = top.fraMain.document.forms[0]
     frmCurrentForm.elements[FieldNumber].checked = true
     }

//**********************

function ClearCheckBox(FieldNumber)
//This clears a checkbox field at the element number it is passed.
//
// Given  :    FieldNumber - the element array position of the field toclear
// Returns:    Nothing
//
// Created:   Duncan Dube 00/02/12

     {
     frmCurrentForm = top.fraMain.document.forms[0]
     frmCurrentForm.elements[FieldNumber].checked = false
     }

function IsCurrency(objNumber)
//
//  Description:   This function determines if the passed value is a currency value
{
    var i;
    var seenDecimalPoint = false;
    var defaultEmptyOK = false;
    var s = replaceSubstring(replaceSubstring(replaceSubstring(replaceSubstring(objNumber.value, ",", ""), "$", ""), ")", ""), "(", "-")
    if (isEmpty(s)) return true

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if ((c =="-" || c == "$") & i <= 1) {
          } else {
          if ((c == ".") && !seenDecimalPoint) seenDecimalPoint = true;
          else if (!isDigit(c)) {objNumber.value = 0
                                       return};
         }
    }

    objNumber.value = parseFloat(s)
}  // End of the IsCurrency Function

function ResetListBox(listBox) {

// Purpose: 	This function resets a list box so nothing is selected
// Inputs:  	listBox - the listBox to be reset
// Returns: 	None
// Created By:	Steve Jeske, Kryos Systems Associates, Sept 28/2000

	for (var i = 0; i < listBox.length; i++) {
		if (listBox.options[i].selected) {
			listBox.options[i].selected = false;
		}	
	}
}

function ResetRadioField(buttonGroup) {

// Purpose: 	This function resets a radio button so nothing is selected
// Inputs:  	buttonGroup - the radio button group to reset
// Returns: 	None
// Created By:	Steve Jeske, Kryos Systems Associates, Sept 28/2000

	for (var i = 0; i < buttonGroup.length; i++) {
		if (buttonGroup[i].checked) {
			buttonGroup[i].checked = false;
		}	
	}
}

function ValidateDate(strDateFormat,strDateString,strFourYearDigits)
// Kryos Systems
//
//  This function is used to validate a numeric date field.  First it validates that the field is not blank or filled with any invalid
// characters.  Then it makes sure that the formatting is in a valid format.  The reason it checks this is that it allows code
// to dynamically change the formatting and if the formatting is incorrect then the date will be invalid.  Next it grabs
// the day, month, and year from the date string.  It checks these to determine that they have the correct formatting.  Finally
// it checks that there are valid # of days in the month (ie not 30 in a February leap year).
//
//	Given :	strDateFormat - the format of the date (ie dmy would be DD/MM/YYYY or day/month/year
//				strDateString -	the string containing the date
//				strFourYearDigits - Yes/No if to display a four digit year 
//
//  Returns:	One of three things
//					1) The updated date if all went well
//					2) The old entered string (if it was a non fatal error)
//					3) "Failed" if it is a fatal error
//
//	Note:		A fatal error is one where the field should not be saved with the data inside of it.  Making a variable fatal will return
//				Failed instead of the original string, allowing you to flag and use things like focus on these particular ones.  
//				Depending on the usage of this field, this may vary from application to application.  To set a fatal 
//				error just change the Error variable to "Yes".
//
// Created : Aaron Howard/Kryos - March 22, 2000
//

{
//Possible Fatal Errors
	var ErrorIsBlank = "No"						//The field has no value
	var ErrorInvalidCharacters = "Yes"			//A character is in the string that is not a number or a hyphen
	var ErrorFormatStringInvalid = "No"		//Either the D, M or Y is missing in the format string
	var ErrorDayIsInvalid = "Yes" 				//There are >31 or < 1 days in the month
	var ErrorMonthIsInvalid = "Yes"				//The month is >12 or <1
	var ErrorYearIsInvalid = "No"				//Not currently used
	var ErrorDaysInMonth = "Yes"				//Certain months have only 30 days
	var ErrorFebruaryInvalid = "Yes"			//February has 29 days some years, only 28 others


	var intTempDay = 0
	var intPositionDay = -1
	var intPositionMonth = -1
	var intPositionYear = -1	
	var strTempLetter = ""
	var strTempString = ""
	var dteCurrentDate = new Date()
	var intCurrentDay = dteCurrentDate.getDate()
	var intCurrentMonth = dteCurrentDate.getMonth() + 1
	var intCurrentYear = dteCurrentDate.getYear()
	var strDone = "No"
	var strValidDateCharacters = "1234567890/"

    //Check to see if it is empty
	if (strDateString =="")
		{
		return IsFatalError(ErrorIsBlank,strDateString)
		}
	
	//Check to see if there are any invalid characters
	if (AnyInvalidCharacters(strDateString,strValidDateCharacters))
		{
		alert("Only numbers and /'s are allowed in dates.")
		return IsFatalError(ErrorInvalidCharacters,strDateString)
		}
   	
// This verifies that the formatting has day, month, and year	
	for (intCurrentPosition=0; intCurrentPosition<=2;intCurrentPosition++)
		{
		strTempLetter =strDateFormat.charAt(intCurrentPosition)
		if (IsDay(strTempLetter))
			{
			intPositionDay = intCurrentPosition
			}
		else if (IsMonth(strTempLetter))
			{
			intPositionMonth = intCurrentPosition
			}
		else if (IsYear(strTempLetter))
			{
			intPositionYear = intCurrentPosition
			}
		else
			{
			// Format string is invalid
			return IsFatalError(ErrorFormatStringInvalid,strDateString)
			}
	}
	
// If it does not have a day, month or year as a format choice
	if ((intPositionMonth==-1) || (intPositionDay==-1) || (intPositionYear==-1))
		{
		return strDateString
		}
	
//Grab the day, month, and year from the date string.  Then validate that it is okay.	
	intCurrentPosition =0
	while (intCurrentPosition <=2)
		{
		strTempLetter =strDateFormat.charAt(intCurrentPosition)
		if (IsDay(strTempLetter))
			{
			intDay = ValidateDay(GetField(strDateString,intCurrentPosition))
			if (intDay == false)
				{
				return IsFatalError(ErrorDayIsInvalid,strDateString)
				}
			strTempString = strTempString + intDay + "/"
			}
		else if (IsMonth(strTempLetter))
			{
			intMonth = ValidateMonth(GetField(strDateString,intCurrentPosition))
			if (intMonth == false)
				{
				return IsFatalError(ErrorMonthIsInvalid,strDateString)
				}
			strTempString = strTempString + intMonth + "/"
			}
		else if (IsYear(strTempLetter))
			{
			intYear = ValidateYear(GetField(strDateString,intCurrentPosition))
			if (intYear == false)
				{
				return IsFatalError(ErrorYearIsInvalid,strDateString)
				}
			if (strFourYearDigits == "No")
				{
				intYear = intYear + ""
				intYear = intYear.substring(intYear.length-2, intYear.length)
				}

			strTempString = strTempString + intYear + "/"
			}
		intCurrentPosition++
		}
	
		
//Check # Days in month
if (((intMonth==4) || (intMonth==6) || (intMonth==9) || (intMonth==11)) && (intDay==31))
	{
	alert(GetMonthName(intMonth) + " does not have 31 days")
	return IsFatalError(ErrorDaysInMonth,strDateString)
	}
//Check February leap year
else if (intMonth==2)
	{
	var isLeap = (intYear %4 ==0 && (intYear%100 !=0 || intYear %400 ==0))
	intTempDay = intDay
	if ((intTempDay>29) || (intTempDay==29) && (!isLeap))
		{
		alert("February " + intYear + " does not have " + intDay + " days.")
		return IsFatalError(ErrorFebruaryInvalid,strDateString)
		}
	return strTempString.substring(0,strTempString.length-1)
	}

return strTempString.substring(0,strTempString.length-1)
}

//**********************

function IsFatalError(strIsFatal,strValidString)
//This returns either a Failed messgae or a valid string dependant on if the string is valid

{
if (strIsFatal =="Yes")
	{
	return "Failed"
	}
else
	{
	return strValidString
	}
}

//**********************

function AnyInvalidCharacters(strStringToCheck,strListofValidCharacters)
//  This searches goes through a string and determines if it has any invalid characters.  It is given one string to search and
//  and another that contains all the valid characters.  It then searches the second string with each character in the first 
//  string to see if it exists in the latter and returns false if any of the characters is not in the list of valid characters
//
//  Given :	strStringToCheck - a string full of characters to check
//				strListofValidCharacters - a string full of all the characters to compare
//
//	Returns:	true - if any character is not in the valid character list
//				false- if all the characters are in the valid character list
//
//	Created:	Aaron Howard/Kryos March 22, 2000

{
	var strDone = "No"
	var intCurrentCharacter = 0
	
	while ((intCurrentCharacter < strStringToCheck.length) && (strDone=="No"))
    		{ 
		if (strListofValidCharacters.indexOf(strStringToCheck.charAt(intCurrentCharacter)) == -1)
			{
			return true
			}
		intCurrentCharacter++ 
		}
 	return false
}

//*******************

function GetMonthName(intMonthNumber)
// This function returns the month name corresponding to the month number.
//
//  Given:	intMonthNumber a number from 1 to 12
//	Returns:	The month name corresponding to the month number
//
//	Created:	Aaron Howard/Kryos March 22, 2000

{
if (intMonthNumber==1)
	{return "January"}
else if (intMonthNumber==2)
	{return "February"}
else if (intMonthNumber==3)
	{return "March"}
else if (intMonthNumber==4)
	{return "April"}
else if (intMonthNumber==5)
	{return "May"}
else if (intMonthNumber==6)
	{return "June"}
else if (intMonthNumber==7)
	{return "July"}
else if (intMonthNumber==8)
	{return "August"}
else if (intMonthNumber==9)
	{return "September"}
else if (intMonthNumber==10)
	{return "October"}
else if (intMonthNumber==11)
	{return "November"}
else if (intMonthNumber==12)
	{return "December"}
}

//*******************

function ValidateDay(intDay)
// This function determines if the day is not blank, and is between 1 and 31.  If the day is blank then it is replaced with the
//	current day.  Also, if the day has only one digit, it calls a function to add a zero to the front (ie 7 -> 07)
//
//  Given:	intDay- the date
//	Returns:	false 	- if the date is not between 1 and 31
//				intDay- the new updated date
//
//	Created:	Aaron Howard/Kryos March 22, 2000

{
	var dteCurrentDate = new Date()
	var intCurrentDay = dteCurrentDate.getDate()

	if (intDay == "")
		{
		intDay = intCurrentDay
		}
	else if ((intDay <1) || (intDay>31))
		{
		alert ("The day must be between 1 and 31")
		return false
		}
	
	intDay = CheckIfToAddZero(intDay)
	return intDay
}

//*******************

function ValidateMonth(intMonth)
// This function determines if the month is not blank, and is between 1 and 12.  If the month is blank then it is replaced with the
//	current month.  Also, if the month has only one digit, it calls a function to add a zero to the front (ie 7 -> 07)
//
//  Given:	intMonth- a number corresponding to the current month
//	Returns:	false 	- if the month is not between 1 and 12
//				intMonth- the new updated month
//
//	Created:	Aaron Howard/Kryos March 22, 2000


{
	var dteCurrentDate = new Date()
	var intCurrentMonth = dteCurrentDate.getMonth() + 1
	
	if (intMonth == "")
		{
		//This makes it a number so it does not crash the CheckItToAddZero
		intMonth = intCurrentMonth + 0
		}
	else if ((intMonth <1) || (intMonth>12))
		{
		alert ("The month must be between 1 and 12")
		return false
		}

	intMonth = CheckIfToAddZero(intMonth)
	return intMonth
}

//*******************

function ValidateYear(intYear)
// This function validates the year in several methods.  It determines that the year is not blank, If ti is then it sets it to the current
//  year.  It calls a function to add a zero to the front (ie 7 -> 07) if there is only one digit and then it does some formatting. If 
//  the year is less than 70 then it assumes it is in the 20th century and adds 2000 to the number.  If it is between 70 and 
//  99 then it adds 99.  Otherwise it leaves it alone.
//  
//  Note:		Due to bug in Netscape Navigator 4.08 that assumes if the current year is 2000, it thinks it is 100; this function
//				adds 1900 to the number until 2020.  Hopefully Netscape will have it fixed by then.
//
//  Given:	intYear- a number corresponding to the current year
//	Returns:	intYear- the new updated year
//
//	Created:	Aaron Howard/Kryos March 22, 2000

{
	var dteCurrentDate = new Date()
	var intCurrentYear = dteCurrentDate.getYear()

//This is to get around a bug in Netscape navigator
	if ((intCurrentYear >= 100) && (intCurrentYear <= 120))
		{
		intCurrentYear +=1900
		}
	if (intYear == "")
		{
		return intCurrentYear
		}
	else
		{
		intYear = CheckIfToAddZero(intYear)
		if ((intYear>70) && (intYear <=99))
			{
			intYear= 19 + intYear
			}
		else if (intYear <69)
			{
			intYear=20+ intYear
			}
		}

	return intYear
}

//*******************

function CheckIfToAddZero(intNumber)
{
// This function is used to convert single digit numbers into double digits by adding a zero to the front if they need it.
//
//  Given:	intNumber- a number to maybe change
//	Returns:	intYear- the new number
//
//	Created:	Aaron Howard/Kryos March 22, 2000

//If it is less than 10 but only one digit
intNumber= intNumber+ ""
	if (intNumber.length == 1)
		{
		intNumber ="0" + intNumber
		}
//If it is less than 10 but more than one digit (ie 07)
	else if ((intNumber<=9) && (intNumber.length == 2))
		{
		intNumber = "0"+intNumber.substring(intNumber.length-1,intNumber.length)
		}
	return intNumber
}

//*******************

function GetField(strDateString,intPosition)
// This function parses the date based on a position needed from a format based on DD/MM/YYYY but where the order of the
//  days, months, and years are unknown.  If is given the string to search and the position of the string desired.  Then it pulls
//  off any text before the position (based on if there is a slash in front of it) and any text afterwords.
//  
//  Given:	intDateString	- the date/string to parse in a format similar to DD/MM/YYYY
//				intPosition 		- the position (from 0 to 2) of the date field (ie in the above example the Day would be 0)
//	Returns:	strCurrentString	- the parsed out date field
//
//	Created:	Aaron Howard/Kryos March 22, 2000

{
	var strCurrentString = strDateString
	var intCurrentPosition =0
	var intSlashPosition = 0
	var strDone = "No"

//Remove the starting text
	while ((intCurrentPosition < intPosition) && (strDone=="No"))
		{
		intSlashPosition= strCurrentString.indexOf("/")

		if (intSlashPosition ==-1)
			{
			strCurrentString =""
			strDone="Yes"
			}
		else
			{
			strCurrentString = strCurrentString.substring(intSlashPosition+1, strCurrentString.length)
			}
		intCurrentPosition++
		}

//Remove the ending text		
	if ((intPosition!=2) && (strDone =="No"))
		{
		while (intCurrentPosition < 2)
			{
			intSlashPosition= strCurrentString.indexOf("/")
			if (intSlashPosition >0)
				{
				strCurrentString = strCurrentString.substring(0,strCurrentString.indexOf("/"))
				}
			intCurrentPosition++
			}
		}

	return strCurrentString
}


//*******************

function IsDay(strLetter)
{
	if ((strLetter == "d") || (strLetter == "D"))
		{return true}
	else
		{return false}
}

//*******************

function IsMonth(strLetter)
{
	if ((strLetter == "m") || (strLetter == "M"))
		{return true}
	else
		{return false}
}

//*******************

function IsYear(strLetter)
{
	if ((strLetter == "y") || (strLetter == "Y"))
		{return true}
	else
		{return false}
}


