// UI Functions for light booking form.
  $(document).ready(function () { 
    var today = new Date();
    var startDate = new Date(today.getFullYear(),today.getMonth(),today.getDate(),0,0);
    var endDate = new Date(today.getFullYear() + 1,today.getMonth(),Math.min(today.getDate(),28),0,0);
    $('#date1').calendar({ 
        prevText: '<< ',
        nextText: ' >>',
        minDate: startDate, 
        maxDate: endDate, 
        yearRange: '0,+1', 
        speed: 'fast', 
        autoPopUp: 'button', 
        buttonImageOnly: true, 
        buttonImage: 'images/calendar_icon.gif', 
        buttonText: 'Calendar' 
    }); 

    $('input#from').autocomplete('./stop_lookup.php' , { 
        onItemSelect:selectFromStop,
        autoFill:true, 
        delay:300, 
        minChars:3, 
        matchSubset:1, 
        selectFirst:true,
        cacheLength:30,
        mustMatch:0,
        maxItemsToShow:20,
        width: 200
	} );

    $('input#to').autocomplete('./stop_lookup.php' , { 
        onItemSelect:selectToStop,
        autoFill:true, 
        delay:300, 
        minChars:3, 
        matchSubset:1, 
        selectFirst:true,
        cacheLength:30,
        mustMatch:0,
        maxItemsToShow:20,
        width: 200
	} );

  }); 
  function selectFromStop(retData) { 
    if (retData.selectValue > '') {
      $('#from').attr('title',retData.extra[0]);
      $('#to').focus().select();
    }
  }; 
  function selectToStop(retData) { 
    if (retData.selectValue > '')  {
      $('#to').attr('title',retData.extra[0]);
      $('#date1').focus().select();
    }
  }; 


