<!-- 

var is_spaces = "                                                  " ;
var idec_lineTime = 0.00 ;
var ib_errors = false ;

function of_formatPilotID( fe )
{
   var s = fe.value ;
   
   if ( s.length > 0 )
      {
      s = "0000".substr( 0, ( 5 - s.length )) + s ;
      fe.value = s.toUpperCase() ;
      }
      
   return( fe ) ;
}

function of_upIt( fe )
{
    fe.value = fe.value.toUpperCase() ;
    return( true ) ;
}

function of_formatValue( fe, maxlen, upit )
{
   var s = fe.value ;
   
   s += is_spaces.substr( 0, ( maxlen - s.length )) ;
   
   if ( upit == 1 )
      s = s.toUpperCase() ;
      
   fe.value = s ;
      
   return( fe ) ;
}

function of_formatDate( fe )
{
   var s = fe.value ;
   
   li_pos = s.indexOf( "/" ) ;
   
   if ( li_pos > 2 )
      return( fe ) ;
      
   m = s.substr( 0, li_pos ) ;
   m = "00".substr( 0, 2 - m.length ) + m ;
   
   li_ptr = li_pos + 1 ;
   li_pos = s.indexOf( "/", li_ptr ) ;
   d = s.substr( li_ptr, li_pos - li_ptr ) ;
   d = "00".substr( 0, 2 - d.length ) + d ;
   
   li_ptr = li_pos + 1 ;
   y = s.substr( li_ptr, 4 ) ;
   
   if ( y.length == 2 )
      if ( y < 90 )
         y = "20" + y ;
      else
         y = "19" + y ;
   else
      if ( y.length < 4 )
         y = "2000".substr( 0, 4 - y.length ) + y ;

   fe.value = y + "/" + m + "/" + d ;
   return( fe ) ;
}   

function of_formatRoute( d, a )
{
    var li_len_d, li_len_a ;
    var ls_r ;
    
    li_len_d = 4 - d.length ;
    li_len_a = 4 - a.length ;
    
    ls_r = d + "/" + a ;
    ls_r += is_spaces.substr( 0, ( li_len_d + li_len_a )) ;
    return( ls_r.toUpperCase() ) ;
}

function of_formatLineNumber( fe )
{
   var s = fe.value ;
   
   if ( isNaN( s.substr( 0, 1 )) )
      s = s + is_spaces.substr( 0, 5 - s.length ) ;
   else
      s = "00000".substr( 0, 5 - s.length ) + s ;
   
   fe.value = s.toUpperCase() ;

   return( fe ) ;
}

function of_formatHHMM( fe )
{
   var li_adjust = 1 ;
   var s = fe.value ;
   
   li_pos = s.indexOf( ":" ) ;
   if ( li_pos < 0 )
      li_pos = s.indexOf( "." ) ;
   
   if ( li_pos < 0 )
      if ( s.length < 5 )
         {
         li_adjust = 0 ;
         li_pos = 2 ;
         s = "0000".substr( 0, 4 - s.length ) + s ;
         }
      else
         {
         ib_errors = true ;
         return( "BADTM" ) ;
         }
   
   h = s.substr( 0, li_pos ) ;
   h = "00".substr( 0, 2 - h.length ) + h ;
   
   if (( parseInt( h ) > 23 ) || ( isNaN( h )) )
      {
      ib_errors = true ;
      return( "BADHR" ) ;
      }
   
   m = s.substr( li_pos + li_adjust, s.length - li_pos - li_adjust ) ;
   m = m + "00".substr( 0, 2 - m.length ) ;

   if (( parseInt( m ) > 60 ) || ( isNaN( m )) )
      {
      ib_errors = true ;
      return( "BADMN" ) ;
      }
 
   return( h + m ) ;
}


function of_formatTime( fv, fo )
{
   var li_adjust = 1 ;
   
   li_pos = fv.value.indexOf( ":" ) ;
   if ( li_pos < 0 )
      li_pos = fv.value.indexOf( "." ) ;
   
   if ( li_pos < 0 )
      if ( fv.value.length < 5 )
         {
         li_adjust = 0 ;
         li_pos = 2 ;
         fv.value = "0000".substr( 0, 4 - fv.value.length ) + fv.value ;
         }
      else
         {
         alert( "The time format is not recognized... please correct! " + fv.value ) ;
         fv.focus()
         return( false ) ;
         }
   
   h = fv.value.substr( 0, li_pos ) ;
   h = "00".substr( 0, 2 - h.length ) + h ;
   
   if (( parseInt( h ) > 23 ) || ( isNaN( h )) )
      {
      alert( "The hour is not valid (must be between 0 and 23)... please correct! " + h );
      fv.focus()
      return( false ) ;
      }
   
   m = fv.value.substr( li_pos + li_adjust, fv.value.length - li_pos - li_adjust ) ;
   m = m + "00".substr( 0, 2 - m.length ) ;

   if (( parseInt( m ) > 60 ) || ( isNaN( m )) )
      {
      alert( "The minutes are not valid (must be between 0 and 59)... please correct! " + m );
      fv.focus()
      return( false ) ;
      }
 
   fv.value = h + m ;
   fo = of_computeHHHH( fv, fo ) ;
   return( true ) ;
}

function of_formatLineTime()
{
   var li_pos ;
   var ls_left, ls_right ;
  
   s = "" + idec_lineTime ;
   
   li_pos = s.indexOf( "." ) ;
   if ( li_pos < 0 )
      {
      ls_right = "00" ;
      ls_left = "00".substr( 0, 2 - s.length ) + s ;
      }
   else
      {
      ls_left = s.substr( 0, li_pos ) ;
      ls_right = s.substr( li_pos + 1, s.length ) ;
      ls_left = "00".substr( 0, 2 - ls_left.length ) + ls_left ;
      ls_right += "00".substr( 0, 2 - ls_right.length ) ;
      }

   idec_lineTime = 0.00 ;      
   return( ls_left + "." + ls_right.substr( 0, 2 )) ;
}

function of_computeHHHH( fe, fo )
{
   var s ;

   s = fe.value ;
   //s = formatHHMM( s ) ;
   hh = ( parseFloat( s.substr( 2, 2 )) / 60.00 ) * 100 ;
   hh = Math.round( hh ) ;

   if ( hh < 10 ) 
      s = s.substr( 0, 2 ) + ".0" +  hh ;
   else
      s = s.substr( 0, 2 ) + "." +  hh ;
   
   //idec_lineTime += parseFloat( s ) ;
   fo.value = s ;
   return( fo ) ;
}

function of_validateData( f )
{
   var li_maxError = 0 ;
   var ls_msg = "" ;

   of_formatDate( f.flightDate ) ;

   if ( f.flightDate.value == "" )
      {
      ls_msg += "Flight Date, " ;
      li_maxError = 4 ;
      }
   
   if ( f.pilotEmail.value == "" )
      {
      ls_msg += "Pilot Email, " ;
      li_maxError = 3 ;
      }
   
   if ( f.pilotName.value == "" )
      {
      ls_msg += "Pilot Name, " ;
      li_maxError = 2 ;
      }

   if ( f.pilotNumber.value == "" )
      {
      ls_msg += "Pilot Number, " ;
      li_maxError = 1 ;
      }
   
   if ( !(f.fileReport.checked || f.requestBid.checked) )
      {
      ls_msg += "File Report or Request Bid, ";
      li_maxError = 5;
      }

   if ( ls_msg.length > 0 )
      {
      ls_msg = ls_msg.substr( 0, ls_msg.length - 2 ) ;
      alert( "The following required fields were not entered:  " + ls_msg ) ;
      
      switch( li_maxError )
         {
         case 1:
            f.pilotNumber.focus() ;
            break ;
         case 2:
            f.pilotName.focus() ;
            break ;
         case 3:
            f.pilotEmail.focus() ;
            break ;
         case 4:
            f.flightDate.focus() ;
            break ;
         case 5:
            break ;
         default:
            alert( "NO CASE FOUND" );
         }
         
      return( false ) ;
      }
   
   return( true ) ;
}
// -->
