var today = new Date();
var outboundDaysOffset = 21;
var inboundDaysOffset = 25;
$().ready(function() {
  location_url = 'http://www.wego.com/p/flights/locations/search?locale=en-US';
  autocompleteInit('#origin', null, location_url, '#from', 'flights', '', '300');
  autocompleteInit('#destination', null, location_url, '#to', 'flights', '', '300');
  datepickerInit();
  $('#outboundDate').datepicker();
  $('#inboundDate').datepicker();
  synchDates('#outboundDate','#inboundDate');
  $('#wegobox-search').click(function(){
    var error = false;
    $('#wegobox .validation-error').hide();
    $('#wegobox li input').each(function(){
      if ($(this).val() == ''){
        error = true;
        $(this).parent().find('.validation-error').show();
        $(this).parent().find('input').addClass('input-validation-error');
      };
    });
    if (error) {
      $('#wegobox #errors').slideDown();
      return false;
    } else {
      return true;
    }
  });
  $('#wegobox li input').keydown(function(){
    $(this).removeClass('input-validation-error');
    $(this).parent().find('.validation-error').hide();
  });
  if($.browser.msie){
    // $('table#airfares tr .go img').css('filter','alpha(opacity=50)');
    $('table#airfares tr').mouseover(function(){
      // $(this).find('.go img').css('filter','alpha(opacity=100)');
      $(this).find('.go img').css('border-color','#f28834');
    }).mouseout(function(){
      // $(this).find('.go img').css('filter','alpha(opacity=50)');
      $(this).find('.go img').css('border-color','#d3d3d3');
    });
    $('#popular-hotels .summary').mouseover(function(){
      $(this).find('.photo img').css('border','3px solid #f28834');
      $(this).find('.photo img').css('padding','0');
    }).mouseout(function(){
      $(this).find('.photo img').css('border','1px solid #D3D3D3');
      $(this).find('.photo img').css('padding','2px');
    });
    if ($.browser.version == '6.0'){
      $('#wegobox .date,#wegobox .location').mouseover(function(){
        $(this).find('input').addClass('wegobox-input');
      }).mouseout(function(){
        $(this).find('input').removeClass('wegobox-input');
      });
    };
  };
});