/**
 * javascript common functions
 *
 * @author: Zhen Xie
 * @date:   02/22/2002
 */

/**
 * To make sure in a pair, if one is filled in, the other should have value too.
 * return value indicates the empty field name.
 */
 
// Disable Back
javascript:window.history.forward(1);

function showSelects(show)
{

   var selects = document.all.tags("SELECT");   
   for (ssi=0;ssi<selects.length;++ssi)
      if (selects[ssi].id.substring(0,5) == "hide_")
	   {
		   if (show == false)
	         selects[ssi].style.display = 'none';
		   else
            selects[ssi].style.display = '';
      }
      return true;
} /* end showSelect */



function doForward(location)
{
    window.location.href = location;
}


function setNull(inputValue)
{
    if(inputValue == '')
        return '$$';
    else
        return inputValue;
}

function isInt(inputValue, fieldName)
{
    var msg = '';
    if(isNaN(inputValue))
        msg += fieldName + ' is a number field.\n';
    else if(inputValue.substring(0,1) == '-')
        msg += fieldName + ' can not be a negative number.\n';
    else if(inputValue.indexOf('.') > 0)
        msg += fieldName + ' is a non-decimal number field.\n';
    else if(inputValue == '' || inputValue.substring(0,1) == ' ')
        msg += fieldName + ' can not be blank.\n';
    return msg;
}

function replaceSpace(inputValue)
{
    var tmp = '';
    for(var i=0;i<inputValue.length;i++)
    {
        if(inputValue.charAt(i) == ' ')
            tmp += '&nbsp;'
        else
            tmp += inputValue.charAt(i);
    }
    return tmp;
}

//type:1, date can not greater than sysdate
function checkDate(inputDate, type)
{
    var tmp = '';
    if(type == 1)
    {
        if(inputDate == '')
            return tmp;
        else if(inputDate.length != 11)
            tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
        else
        {
            var month = isMonth(inputDate.substring(0,3));
            if(month == -1 || isNaN(inputDate.substring(4,6)) || isNaN(inputDate.substring(7,11)))
                tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
            else
            {
                var currentDate = new Date(inputDate.substring(7,11), month, inputDate.substring(4,6));
                var today = new Date();
                if(currentDate > today)
                    tmp = 'Hire/Birth Date can not be greater than current date.';
            }
        }
    }
    else if(type == 2)
    {
        if(inputDate == '')
            return tmp;
        else if(inputDate.length != 11)
            tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
        else
        {
            var month = isMonth(inputDate.substring(0,3));
            if(month == -1 || isNaN(inputDate.substring(4,6)) || isNaN(inputDate.substring(7,11)))
                tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
            else
            {
                    var expDate = new Date(inputDate.substring(6,10), inputDate.substring(0,2)-1, inputDate.substring(3,5));
                    var tmptoday = new Date();
                    var today = new Date(tmptoday.getYear(), tmptoday.getMonth() , tmptoday.getDate());
                    var days = 0; 
		    var difference = 0;	    
		    today = new Date(); 		    
		    difference = expDate - today;
		    days = (difference/(1000*60*60*24)); 
                    if(days <= -1)
                      tmp = 'Expiration Date can not be earlier than current date.';
            }
        }
    }
    return tmp;
}

function isMonth(inputMonth)
{
    if(inputMonth == 'JAN')
        return 0;
    else if(inputMonth == 'FEB')
        return 1;
    else if(inputMonth == 'MAR')
        return 2;
    else if(inputMonth == 'APR')
        return 3;
    else if(inputMonth == 'MAY')
        return 4;
    else if(inputMonth == 'JUN')
        return 5;
    else if(inputMonth == 'JUL')
        return 6;
    else if(inputMonth == 'AUG')
        return 7;
    else if(inputMonth == 'SEP')
        return 8;
    else if(inputMonth == 'OCT')
        return 9;
    else if(inputMonth == 'NOV')
        return 10;
    else if(inputMonth == 'DEC')
        return 11;
    else
        return -1;
}


function jumpTo(URL_List)
{
    var URL = URL_List.options[URL_List.selectedIndex].value;
    if (URL == "blank")
      return false;
    else
        window.location.href = URL;
}


var isNav6, isIE4, isIE5

isIE4 = false;
if (parseInt(navigator.appVersion.charAt(0)) >= 5) {
   isNav6 = (navigator.appName == "Netscape") ? true : false
   isIE5 = (navigator.appName.indexOf("Microsoft" != -1)) ? true : false
}
else isIE4 = true;


function runValidatePrev(inDate,showMsg)
{
dateOK = true;
  check = '';
  if (inDate.value != null && inDate.value != "")
  {
    dateOK = validateDate(inDate.value,showMsg);
  }
  if (dateOK)
  {
    inDate.value = convertDateMM(inDate.value);
    check = checkDateMM(inDate.value, 1);
    
      if(check == ''){
        return true;
      }else{
        alert(check);
        inDate.value='';
        inDate.focus();
        return false;
      }
  }
  else
  {
    inDate.value='';
    inDate.focus();
    return false;
  }

}

function runValidatePost(inDate,showMsg)
{
dateOK = true;
  check = '';
  if (inDate.value != null && inDate.value != "")
  {
    dateOK = validateDate(inDate.value,showMsg);
  }
  if (dateOK)
  {
    inDate.value = convertDateMM(inDate.value);
    check = checkDateMM(inDate.value, 2);
    
      if(check == ''){
        return true;
      }else{
        alert(check);
        inDate.value='';
        inDate.focus();
        return false;
      }
  }
  else
  {
    inDate.value='';
    inDate.focus();
    return false;
  }

}

function runValidatePlus90(inDate,showMsg)
{
dateOK = true;
  check = '';
  if (inDate.value != null && inDate.value != "")
  {
    dateOK = validateDate(inDate.value,showMsg);
  }
  if (dateOK)
  {
    inDate.value = convertDateMM(inDate.value);
    check = checkDateMM(inDate.value, 3);
    
      if(check == ''){
        return true;
      }else{
        alert(check);
        inDate.value='';
        inDate.focus();
        return false;
      }
  }
  else
  {
    inDate.value='';
    inDate.focus();
    return false;
  }

}

function runValidate(inDate,showMsg)
{
  dateOK = true;
  if (inDate.value != null && inDate.value != "")
  {
    dateOK = validateDate(inDate.value,showMsg);
  }
  if (dateOK)
  {
    inDate.value = convertDateMM(inDate.value);
    return true;
  }
  else
  {
    inDate.value='';
    inDate.focus();
    return false;
  }
}


function convertToMon(inMonth)
{
  convertedMonth = '';
  if(inMonth == '01')
    convertedMonth = 'JAN';
  else if (inMonth == '02')
    convertedMonth = 'FEB';
  else if (inMonth == '03')
    convertedMonth = 'MAR';
  else if (inMonth == '04')
    convertedMonth = 'APR';
  else if (inMonth == '05')
    convertedMonth = 'MAY';
  else if (inMonth == '06')
    convertedMonth = 'JUN';
  else if (inMonth == '07')
    convertedMonth = 'JUL';
  else if (inMonth == '08')
    convertedMonth = 'AUG';
  else if (inMonth == '09')
    convertedMonth = 'SEP';
  else if (inMonth == '10')
    convertedMonth = 'OCT';
  else if (inMonth == '11')
    convertedMonth = 'NOV';
  else if (inMonth == '12')
    convertedMonth = 'DEC';

  return convertedMonth;
}


  function convertDate(dateToConvert)
  {
    newMonth = '';
    totalNewDate = '';
    if (dateToConvert.length == 8)
    {
      defMonth = dateToConvert.substring(0,2);
      defMonthInt = parseInt(defMonth,10);
      newMonth = convertToMon(defMonthInt);
      defYear = dateToConvert.substring(4,8);// year
     defDay = dateToConvert.substring(2,4);// day
     newMonth = newMonth.toUpperCase();
      totalNewDate = newMonth + '-' + defDay + '-' +defYear;
      return totalNewDate;
    }
    if (dateToConvert.length == 9)
    {
      defMonth = dateToConvert.substring(0,3)
      defYear = dateToConvert.substring(5,9);// year
      defDay = dateToConvert.substring(3, 5);;// day
      defMonth = defMonth.toUpperCase();
      totalNewDate = defMonth + '-' + defDay + '-' +defYear;
      return totalNewDate;
    }
    if (dateToConvert.length == 10)
    {
      defMonth = dateToConvert.substring(0,2);
      defMonthInt = parseInt(defMonth,10);
      newMonth = convertToMon(defMonthInt);
      defYear = dateToConvert.substring(6,10);// year
     defDay = dateToConvert.substring(3,5);// day
     newMonth = newMonth.toUpperCase();
      totalNewDate = newMonth + '-' + defDay + '-' +defYear;
      return totalNewDate;
    }
    if (dateToConvert.length == 11)
    {
     defMonth = value.substring(0,3)// month
     defDay = value.substring(4,6);// day
     defYear = value.substring(7, 11);// year
     newMonth = defMonth.toUpperCase();
      totalNewDate = newMonth + '-' + defDay + '-' +defYear;
      return totalNewDate;
    }
    if (dateToConvert.length == 0)
    {
      return dateToConvert;
    }

  }


  function isDigit (inValue)
  {
     return ((inValue >= "0") && (inValue <= "9"))
  }

  
  function checkDay(inDay,inMonth, inYear)
  {
    dayErr = 0;
    defDayInt = inDay;
    defMonth = inMonth;
    defMonth = defMonth.toUpperCase();
    defYearInt = inYear;
    if(isNaN(defDayInt))
    {
      //alert("Please enter a valid day")
      dayErr = 1;
    }
    if((defDayInt<1 || defDayInt>31) || ((defMonth==2 || defMonth=='FEB') && inDay>daysInFebruary(defYearInt)))
    {
      //alert("Please enter a valid day")
      dayErr = 1;
    }
    return dayErr;
  }
  
  function checkYear(inYear,inYearString)
  {
    yearErr = 0;
    defYearInt = inYear;
    defYear = inYearString;
    var minYear=1900;
    var maxYear=2200;
    if (isNaN(defYearInt))
    {
      //alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
      yearErr = 1;
    }
    if (defYear.length != 4 || defYearInt==0 || defYearInt<minYear || defYearInt>maxYear)
    {
      alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
      yearErr = 1;
    }
    return yearErr
  }

  function daysInFebruary(inYear)
  {
  // February has 29 days in any year evenly divisible by four,
  // EXCEPT for centurial years which are not also divisible by 400.
    return (((inYear % 4 == 0) && ( (!(inYear % 100 == 0)) || (inYear % 400 == 0))) ? 29 : 28 );
  }

  function DaysArray(n)
  {
    for (var i = 1; i <= n; i++)
    {
      this[i] = 31
      if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
      if (i==2) {this[i] = 29}
    }
    return this
  }

  function validateDate(inDate,showMsg)
  {
     errMessage = '';
     var err=0;
     value = inDate;
     var daysInMonth = DaysArray(12)
     var monthArray = new Array("JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC");
     if (value.length < 8)
     {
       errMessage = errMessage + '  Field Length  ';
       err=1;
     }
     if (value.length > 11)
     {
       errMessage = errMessage + '  Field Length  ';
       err = 1;
     }
     if (value.length == 0)
     {
       errMessage = errMessage + '  Field Length  ';
       err = 0;
     }

     //MMDDYYYY
     if (value.length == 8)
     {
       tempErr = 0;
       defMonth = value.substring(0, 2);// month
       defMonthInt = parseInt(defMonth,10);
       defYear = value.substring(4,8);// year
       defYearInt = parseInt(defYear);
       defDay = value.substring(2,4);// day
       defDayInt = parseInt(defDay,10);
       defDayTemp = defDay.substring(0,1);
       if (defDayTemp == '/')
       {
         defDay = value.substring(3,5);
         defDayInt = parseInt(defDay,10);
       }
       if (defMonthInt <1 || defMonthInt >12)
       {
         //alert('Please enter a valid month');
         errMessage = errMessage + '  Month  ';
         err = 1;
         tempErr = 1;
       }
       if (isNaN(defMonthInt))
       {
         //alert('Please enter a valid month');
         errMessage = errMessage + '  Month  ';
         err = 1;
         tempErr = 1;
       }       
       if(defDayInt > daysInMonth[defMonthInt])
       {
         alert('There are only '+daysInMonth[defMonthInt]+' days in '+monthArray[defMonthInt-1]+'.');
         return false;
       }
       err = checkDay(defDayInt,defMonth,defYearInt);
       if (err == 1)
       {
         errMessage = errMessage + '  Day  ';
         tempErr = 1;
       }

       err = checkYear(defYearInt,defYear);
       if (err == 1)
       {
         errMessage = errMessage + '  Year  ';
         err = 1;
       }
       if (err == 0 && tempErr ==1)
       {
         err = 1;
       }
     }
     //MONDDYYYY
     if (value.length == 9)
     {
       var validMonth = false;
       tempErr = 0;
       defDay = value.substring(3, 5);
       defDayInt = parseInt(defDay,10);
       defMonth = value.substring(0,3);
       defMonthInt = parseInt(defMonth,10);
       defYear = value.substring(5,9);
       defYearInt = parseInt(defYear);
       
       err = checkDay(defDayInt,defMonth,defYearInt);
       if (err == 1)
       {
         errMessage = errMessage + '  Day  ';
         tempErr = 1;
       }
       for(x=0; x < monthArray.length; x++)
    {
      if (defMonth.toUpperCase() == monthArray[x])
      validMonth = true;
    }
           
           if(defDayInt > daysInMonth[defMonthInt])
           {
             alert('There are only '+daysInMonth[defMonthInt]+' days in '+monthArray[defMonthInt-1]+'.');
             return false;
       }
    if (validMonth == false)
    {
      //alert('Please enter a valid month');
      errMessage = errMessage + '  Month  ';
      err = 1;
      tempErr = 1;
       }

       err = checkYear(defYearInt,defYear);
       if (err == 1)
       {
         errMessage = errMessage + '  Year  ';
         err = 1;
       }
       if (err == 0 && tempErr ==1)
         err = 1;

     }
     //MM/DD/YYYY
     if (value.length == 10)
     {
       tempErr = 0;
       defDay = value.substring(3, 5);
       defDayInt = parseInt(defDay,10);
       defMonth = value.substring(0, 2);
       defMonthInt = parseInt(defMonth,10);
       firstSlash = value.substring(2, 3);
       secondSlash = value.substring(5, 6);
       defYear = value.substring(6,10);
       defYearInt = parseInt(defYear);
       if (firstSlash != '/')
       {
         err = 1;
         errMessage = errMessage + '  Slash in wrong position for this format  ';
         tempErr = 0;
       }
       if (secondSlash != '/')
       {
         err = 1;
         errMessage = errMessage + '  Slash in wrong position for this format  ';
         tempErr = 0;
       }
       err = checkDay(defDayInt,defMonth,defYearInt);
       if (err == 1)
       {
         errMessage = errMessage + '  Day  ';
         tempErr = 1;
       }
       
       if(defDayInt > daysInMonth[defMonthInt])
       {
         alert('There are only '+daysInMonth[defMonthInt]+' days in '+monthArray[defMonthInt-1]+'.');
         return false;
       }
       if (defMonthInt <1 || defMonthInt >12)
       {
         //alert('Please enter a valid month');
         errMessage = errMessage + '  Month  ';
         err = 1;
         tempErr = 1;
       }
       if (isNaN(defMonthInt))
       {
      //alert('Please enter a valid month');
      errMessage = errMessage + '  Month  ';
      err = 1;
      tempErr = 1;
    }
       err = checkYear(defYearInt,defYear);
       if (err == 1)
       {
         errMessage = errMessage + '  Year  ';
         err = 1;
       }
       if (err == 0 && tempErr ==1)
      err = 1;
     }

     //MON-DD-YYYY
     if (value.length == 11)
     {
       tempErr = 0;
       var validMonth = false;
       defMonth = value.substring(0,3)// month
       defMonthInt = parseInt(defMonth,10);
       firstDash = value.substring(3,4)// '-'
       defDay = value.substring(4,6);// day
       defDayInt = parseInt(defDay,10)
       secondDash = value.substring(6,7);// '-'
       defYear = value.substring(7, 11);// year
       defYearInt = parseInt(defYear);

       if (firstDash != '-')
       {
         err = 1;
         errMessage = errMessage + '  Dash in wrong position for this format  ';
         tempErr = 1;
       }
       if (secondDash != '-')
       {
         err = 1;
         errMessage = errMessage + '  Dash in wrong position for this format  ';
         tempErr = 1;
       }
       err = checkDay(defDayInt,defMonth,defYearInt);
       if (err == 1)
       {
         errMessage = errMessage + '  Day  ';
         tempErr = 1;
       }
       
       if(defDayInt > daysInMonth[defMonthInt])
       {
         alert('There are only '+daysInMonth[defMonthInt]+' days in '+monthArray[defMonthInt-1]+'.');
         return false;
       }
       for(x=0; x < monthArray.length; x++)
    {
      if (defMonth.toUpperCase() == monthArray[x])
      validMonth = true;
    }
    if (validMonth == false)
    {
      //alert('Please enter a valid month');
      errMessage = errMessage + '  Month  ';
      err = 1;
      tempErr = 1;
       }

       err = checkYear(defYearInt,defYear);
       if (err == 1)
       {
         errMessage = errMessage + '  Year  ';
         err = 1;
       }
       if (err == 0 && tempErr ==1)
      err = 1;
     }

     if (err==1)
     {
       //alert("The following field(s) are incorrect: " + errMessage);
       if (showMsg != false) alert('The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY');
       return false;
     }
     if (err==2)
     {            
            if (showMsg != false) alert('There are not that many days in the month selected.');
            return false;
     }
     else
       return true;
  }





  
function displayErrorMsg(message)
{
    if(message != '')
        alert(message);
}


   function stripQuotes(field)
   {
      var s = field.value;
      var re = /"/gi;

      s= field.value.replace(re,"");

      // s.replace(/"([^"]*)"/g, "``$1''");

      field.value = s;

      return true;
   }

function checkValidNum(value)
{

 if(isNaN(value.value))
 {

   var chars = value.value;
   var goodChars = chars.substring(0,chars.length - 1);
   value.value = goodChars;
   alert('Please enter a valid number.');

   return false;
 }
 else
 {
   return true;
 }

}


  


  
  


      
      // checkRequiredFields
      // this checks to see if the pr_ fields are filled in
         function checkRequiredFields(thisForm,doAlert) 
         {      
            var errorMsg; 
            var hasErrors; 
            errorMsg = 'The following items are required. \\n \\n';     
            hasErrors = false; 
            for (i=0;i<thisForm.elements.length;++i) 
            { 
               if (thisForm.elements[i].name.substring(0,3) == 'pr_') 
               { 
                  if (thisForm.elements[i].value == '') 
                  { 
                     if (thisForm.elements[i].style) thisForm.elements[i].style.backgroundColor = '#FFEEEE'; 
                     errorMsg = errorMsg + thisForm.elements[i].name.substring(3,thisForm.elements[i].name.length) + '\\n'; 
                     hasErrors = true; 
                  } 
                  else 
                     if (thisForm.elements[i].style) thisForm.elements[i].style.backgroundColor = '#FFFFFF'; 
               } 
            }      
            if (hasErrors == true) 
            { 
               if (doAlert == true) alert(errorMsg); 
               return false;  
            }             
            return true; 
         } 




function clearFields(thisForm)
{
for (i=0;i<thisForm.elements.length;++i)         
  thisForm.elements[i].style.backgroundColor = '#ffffff';

}


function isVersionSix()
{
   var nVer = navigator.appVersion;
   var nAgt = navigator.userAgent;
   
   var fullVersion = parseFloat(nVer);
   var majorVersion = parseInt(nVer);

   // In Internet Explorer, the true version is after "MSIE" 
   
   if ((verOffset=nAgt.indexOf("MSIE"))!=-1) 
   {
     fullVersion = parseFloat(nAgt.substring(verOffset+5,nAgt.length));
     majorVersion = parseInt(''+fullVersion);
   }
  
   // In Opera, the true version is after "Opera"

   if ((verOffset=nAgt.indexOf("Opera"))!=-1) 
   {
     fullVersion = parseFloat(nAgt.substring(verOffset+6,nAgt.length));
     majorVersion = parseInt(''+fullVersion);
   }   
   
   if(fullVersion == 6)
     return true;
   else if (majorVersion == 6)
     return true;
   else 
     return false;
}

timeout_one = setTimeout("endSession();", 900000 ); 

function checkTimeout()
{
   timeout_two = setTimeout("endSession();", 60000 );
   var agree = confirm("Your session is about to expire, would you like more time?");
   if (agree)
   {
       clearTimeout(timeout_two);
       timeout_one = setTimeout ( "if(checkTimeout()) endSession();", 900000 );
   }
   else
   {      
      clearTimeout(timeout_two);
      return true ;
   }
}

function endSession()
{
  setAction('TIMEOUT');
  document.MAIN.action="usp";
  document.MAIN.submit();
  return true;
}


function convertToMM(inMonth)
{
  convertedMonth = '';
  inMonth = inMonth.toUpperCase();
  if(inMonth == 'JAN')
    convertedMonth = '01';
  else if (inMonth == 'FEB')
    convertedMonth = '02';
  else if (inMonth == 'MAR')
    convertedMonth = '03';
  else if (inMonth == 'APR')
    convertedMonth = '04';
  else if (inMonth == 'MAY')
    convertedMonth = '05';
  else if (inMonth == 'JUN')
    convertedMonth = '06';
  else if (inMonth == 'JUL')
    convertedMonth = '07';
  else if (inMonth == 'AUG')
    convertedMonth = '08';
  else if (inMonth == 'SEP')
    convertedMonth = '09';
  else if (inMonth == 'OCT')
    convertedMonth = '10';
  else if (inMonth == 'NOV')
    convertedMonth = '11';
  else if (inMonth == 'DEC')
    convertedMonth = '12';

  return convertedMonth;
}

function convertDateMM(dateToConvert)
  {
    newMonth = '';
    totalNewDate = '';
    if (dateToConvert.length == 8)
    {
      defMonth = dateToConvert.substring(0,2)   
      defYear = dateToConvert.substring(4,8);// year
      defDay = dateToConvert.substring(2,4);// day     
      totalNewDate = defMonth + '-' + defDay + '-' +defYear;      
      return totalNewDate;
    }
    if (dateToConvert.length == 9)
    {
      defMonth = dateToConvert.substring(0,3)
      newMonth = convertToMM(defMonth);
      defYear = dateToConvert.substring(5,9);// year
      defDay = dateToConvert.substring(3, 5);;// day      
      totalNewDate = newMonth + '-' + defDay + '-' +defYear;
      return totalNewDate;
    }
    if (dateToConvert.length == 10)
    {
      defMonth = dateToConvert.substring(0,2);
      defYear = dateToConvert.substring(6,10);// year
      defDay = dateToConvert.substring(3,5);// day
      totalNewDate = defMonth + '-' + defDay + '-' +defYear;
      return totalNewDate;
    }
    if (dateToConvert.length == 11)
    {
      defMonth = value.substring(0,3)// month
      newMonth = convertToMM(defMonth);
      defDay = value.substring(4,6);// day
      defYear = value.substring(7, 11);// year     
      totalNewDate = newMonth + '-' + defDay + '-' +defYear;
      return totalNewDate;
    }
    if (dateToConvert.length == 0)
    {
      return dateToConvert;
    }
  }
  
  //type:1, date can not greater than sysdate
    function checkDateMM(inputDate, type)
    {
        var tmp = '';
        if(type == 1)
        {
            if(inputDate == '')
                return tmp;
            else if(inputDate.length != 10)
                tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
            else
            {
                
                if(isNaN(inputDate.substring(0,2)) || isNaN(inputDate.substring(3,5)) || isNaN(inputDate.substring(6,10)))
                    tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
                else
                {                    
                    var currentDate = new Date(inputDate.substring(6,10), inputDate.substring(0,2)-1, inputDate.substring(3,5));
                    var today = new Date();
                    if(currentDate > today)
                        tmp = 'Hire/Birth Date can not be greater than current date.';
                }
            }
        }
        else if(type == 2)
        {
            if(inputDate == '')
                return tmp;
            else if(inputDate.length != 10)
                tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
            else
            {
                if(isNaN(inputDate.substring(0,2)) || isNaN(inputDate.substring(3,5)) || isNaN(inputDate.substring(6,10)))
                    tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
                else
                {
                    var expDate = new Date(inputDate.substring(6,10), inputDate.substring(0,2)-1, inputDate.substring(3,5));
                    var tmptoday = new Date();
                    var today = new Date(tmptoday.getYear(), tmptoday.getMonth() , tmptoday.getDate());
                    var days = 0; 
		    var difference = 0;	    
		    today = new Date(); 		    
		    difference = expDate - today;
		    days = (difference/(1000*60*60*24)); 
                    if(days <= -1)
                        tmp = 'Date can not be earlier than current date.';
                }
            }
        }
        
	else if(type == 3)
	{
	    if(inputDate == '')
		return tmp;
	    else if(inputDate.length != 10)
		tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
	    else
	    {
		if(isNaN(inputDate.substring(0,2)) || isNaN(inputDate.substring(3,5)) || isNaN(inputDate.substring(6,10)))
		    tmp = 'The date must be in one of the following formats: MMDDYYYY,MONDDYYYY,MM/DD/YYYY,MON-DD-YYYY';
		else
		{
		    var expDate = new Date(inputDate.substring(6,10), inputDate.substring(0,2)-1, inputDate.substring(3,5));
		    var tmptoday = new Date();
		    var today = new Date(tmptoday.getYear(), tmptoday.getMonth() , tmptoday.getDate());
		    var days = 0; 
		    var difference = 0;	    
		    today = new Date(); 		    
		    difference = expDate - today;
		    days = (difference/(1000*60*60*24)); 
		    if(days <= -1 || days > 90)
			tmp = 'Date cannot be earlier than the current date or later than 90 days in the future.';
		}
	    }
        }
        return tmp;
}

    // convert a field (a-z,A-Z) to upper case
   // usage onKeyUp="textToUpperCase(this);"
   function textToUpperCase(field) 
    {     
     field.value = field.value.toUpperCase();             
     return true;
   } 
   
      function validateName(element)
         {  
            if(element.value.length > 0)
   	    {
               element.style.backgroundColor = '#FFFFFF';
            }
            var originalValue = element.value;
            var finalValue = element.value;
            finalValue = finalValue.replace(/-/g,'');          
   	    finalValue = finalValue.replace(/,/g,'');    	       	     	 
   	 
   	 if(originalValue.length > finalValue.length)
   	 {
   	   element.style.backgroundColor = '#99FF00';
   	   element.value = finalValue;
   	   alert('Hyphens and commas are not allowed.');
   	   element.focus();  
   	   return true;
   	 }
   	 return true;	 
   
       }
   
   
   
   
   
   function setAction(action)
   {     
     document.MAIN.p_action.value = action;
     return true;   
   }
   
   function setAndGo(action)
   {    
      document.MAIN.p_action.value = action;      
      document.MAIN.submit();
      return true;   
   } 
    
   function goMenu(action, menu)
   {    
     document.MAIN.p_action.value = action;
     document.MAIN.p_menu.value = menu;
     document.MAIN.submit();
     return true;   
   }   
    
    
   function unlock(user)
   {          
      document.MAIN.usr_id.value = user;   
      setAction('UNLOCK');      
      document.MAIN.submit();
      return true;
   }  
   function go(action)
   {		  
   setAction(action);			
   document.MAIN.submit();
   return true; 	     
   }
       
    