$(document).ready(function() {
   // an arrival box is changed
   $('select.agroup').change(function () {
      //alert('arrival day was changed to ' + $('#a_day').val());
// if year was changed change the dep year if it's not already the same
// if month was changed, change arrmonth if it isn't 01
// and so on
      var ayear = $('select#fromyear').val();
      var amonth =  $('select#frommonth').val();
      var aday =  $('select#fromday').val();
      var dyear = $('select#toyear').val();
      var dmonth =  $('select#tomonth').val();
      var dday =  $('select#today').val();
      if (ayear != '' && dyear != ayear)  {
	$('select#toyear').val(ayear);
      }
      if (amonth != '' && dmonth == '01')  {
	$('select#tomonth').val(amonth);
      }
      if (aday != '' && dday == '01')  {
	$('select#today').val(aday);
      }
/*
      if (ayear != '' && amonth != '' && aday != '') {
         // if to dates haven't been changed, set them to same as from dates
         var dyear = $('select#toyear').val();
         var dmonth =  $('select#tomonth').val();
         var dday =  $('select#today').val();
         if (dyear == ayear && dmonth == '01' && dday == '01') {	//defaults
		$('select#tomonth').val(amonth);
		$('select#today').val(aday);
         }
      }
*/
   });
});