<link rel="stylesheet" type="text/css" href="calendar/includes/addGig/autocomplete/jquery.ui.all.css" />
<script type="text/javascript" src="calendar/includes/addGig/autocomplete/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="calendar/includes/addGig/autocomplete/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="calendar/includes/addGig/autocomplete/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="calendar/includes/addGig/autocomplete/jquery.ui.position.min.js"></script>
<script type="text/javascript" src="calendar/includes/addGig/autocomplete/jquery.ui.menu.min.js"></script>
<script type='text/javascript' src='calendar/includes/addGig/autocomplete/jquery.ui.autocomplete.min.js'></script>
<link rel="stylesheet" type="text/css" href="_calendar/includes/addGig/autocomplete/jquery.ui.autocomplete.min.css" />
<link rel="stylesheet" type="text/css" href="calendar/includes/addGig/autocomplete/autocomplete.css" />

<?php
  // take this array from gigkalender.ini.php instead
  $allFields = array('GigCountry', 'GigDistrict', 'GigPostalCode', 'GigCity', 'GigEvent', 'GigEventURL', 'GigEntranceFee', 'GigVenue',
    'GigVenueURL', 'GigOrganizer', 'GigOrganizerURL', 'GigArtist', 'GigArtistURL', 'GigLineup', 'GigVisitors', 'GigStageBuilding',
    'GigBeginning', 'GigDuration', 'GigEnding');

  echo '<script type="text/javascript">
    $(function() {
  ';

  for ($i=0; $i<count($allFields); $i++)
  {
    echo 'var '.$allFields[$i].'Array = "'.getArrayForAutoSuggest($allFields[$i]).'".split("|");
    ';
    echo '$( "#'.$allFields[$i].'" ).autocomplete({
      minLength: 1,
      source: '.$allFields[$i].'Array
    });
    ';
  }
  echo '});</script>';

/* match only the beginning of terms:

  source: function( request, response ) {
    var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( request.term ), "i" );
    response( $.grep( '.$allFields[$i].'Array, function( item ){
      return matcher.test( item );
    }) );
  }
  */
?>

      