
function ClientFlightValidate(source, clientside_arguments)
{
    var tmp = clientside_arguments.Value;
    if(tmp != "")
    {
        var reg = '\\([A-Za-z][A-Za-z][A-Za-z]\\)';
        if(tmp.match(reg))
        {
            clientside_arguments.IsValid = true;
        }
        else
        {
            clientside_arguments.IsValid = false;
        }
    }
    else
    {   
        clientside_arguments.IsValid = false;
    }
}

function getCalendarValue() 
{
    document.getElementById('iFrameSearchFormUC_DepartureDate').value = document.getElementById('iFrameSearchFormUC_DepartureDateImg').value;
}
function getCalendarValueReturn() 
{
    document.getElementById('iFrameSearchFormUC_ReturnDate').value = document.getElementById('iFrameSearchFormUC_ReturnDateImg').value;
}
function ClientDepartureValidate(source, clientside_arguments)
{  
  if (clientside_arguments.Value != "" )
  {        
      var format = document.getElementById('iFrameSearchFormUC_DepartureDate');
      var tempf = format.value;
      while(tempf.indexOf('-') != -1)
          tempf = tempf.replace('-','.');
      while(tempf.indexOf('/') != -1)
          tempf = tempf.replace('/','.');
      while(tempf.indexOf('\\') != -1)
        tempf = tempf.replace('\\','.');
      format.value = tempf;
      var str_temp = format.value.split('.');
      if(str_temp.length != 3)
      {
        clientside_arguments.IsValid = false;
      }
      else
      {
          for(var i = 0; i < 2; i++)
          {
            if(str_temp[i].length == 1)
            {
                str_temp[i] = '0' + str_temp[i];        
            }
          }
          if(str_temp[2].length == 2)
          {    
            str_temp[2] = '20' + str_temp[2];
          }
          else if(str_temp[2].length == 1)
          {
            str_temp[2] = '200' + str_temp[2];
          }
          var rdy_temp = "";
          for(var i = 0; i < 2; i++)
          {
            rdy_temp += str_temp[i] + '.';
          }
          rdy_temp += str_temp[2];
          format.value = rdy_temp;
          clientside_arguments.Value = rdy_temp;
          var tmp = clientside_arguments.Value;
          var reg = "(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}";
          if(tmp.match(reg))
          {
              clientside_arguments.IsValid=true;
          }
          else
          {
              clientside_arguments.IsValid=false;
          }
        }
  }
  else 
  {
    clientside_arguments.IsValid=false;
  }      
}     
    
function ClientReturnValidate(source, clientside_arguments)
{
    var returnrb = document.getElementById('iFrameSearchFormUC_ReturnRB');
    if(returnrb.checked)
    {
          if (clientside_arguments.Value != "" )
          {            
              var format = document.getElementById('iFrameSearchFormUC_ReturnDate');
              var tempf = format.value;
              while(tempf.indexOf('-') != -1)
                  tempf = tempf.replace('-','.');
              while(tempf.indexOf('/') != -1)
                  tempf = tempf.replace('/','.');
              while(tempf.indexOf('\\') != -1)
                tempf = tempf.replace('\\','.');
              format.value = tempf;
              var str_temp = format.value.split('.');              
              if(str_temp.length != 3)
              {
                clientside_arguments.IsValid = false;
              }
              else
              {
                  for(var i = 0; i < 2; i++)
                  {
                        if(str_temp[i].length == 1)
                        {
                            str_temp[i] = '0' + str_temp[i];        
                        }
                  }
                  if(str_temp[2].length == 2)
                  {    
                    str_temp[2] = '20' + str_temp[2];
                  }
                  else if(str_temp[2].length == 1)
                  {
                    str_temp[2] = '200' + str_temp[2];
                  }
                  var rdy_temp = "";
                  for(var i = 0; i < 2; i++)
                  {
                    rdy_temp += str_temp[i] + '.';
                  }
                  rdy_temp += str_temp[2];
                  format.value = rdy_temp;
                  clientside_arguments.Value = rdy_temp;
                  
                  var tmp = clientside_arguments.Value;
                  var reg = "(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}";
                  if(tmp.match(reg))
                  {
                      clientside_arguments.IsValid=true;
                  }
                  else
                  {
                      clientside_arguments.IsValid=false;
                  }
               }
            }
            else 
            {
                 clientside_arguments.IsValid=false;
            }
   }
   else
   {
       clientside_arguments.IsValid = true;
   }        
}  

function ClientValidate(source, clientside_arguments)
{
  var tmp = clientside_arguments.Value;    
  tmp = tmp.toUpperCase();       
  if (tmp.match('^FI[A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9][A-Za-z0-9]$'))
  {
     clientside_arguments.IsValid=true;
  }
  else 
  { 
    clientside_arguments.IsValid=false;
  }
} 

function checkInfants(source, clientside_arguments)
{
  var adultscount = document.getElementById('iFrameSearchFormUC_Adults');
  var infantcount = document.getElementById('iFrameSearchFormUC_Infants');
  if(infantcount.value > adultscount.value)
  {
    clientside_arguments.IsValid = false;
  }
  else
  {
    clientside_arguments.IsValid = true;
  }
} 
               
$(document).ready(function() 
{
//    var currentFocus = null; 
//    $(':input').focus( function() 
//            { 
//                currentFocus = this; 
//            }
//        ).blur( function() 
//            { 
//                currentFocus = null; 
//            }
//        )
//    ;    
//    document.onkeypress = processKey;
//    function processKey(e)
//    {
//        if (null == e)        
//            e = window.event;   
//        if (e.keyCode == 13 && currentFocus != null && currentFocus.id != null && currentFocus.id != "" && currentFocus.id == "ctl00_TopRegion_QuickSearch1_SearchText")  
//        {            
//            window.location.href = document.getElementById('iFrameSearchFormUC_QuickSearchButton').href;
//            return false;    
//        }
//    }
} 
);      
