function setPDFbutton() {
  var EventID = $("#SelectEvent").val();
  if (ev != 0) {
    EventID = ev;
  }
  $.get("whats_available.php?EventID=" + EventID,
    function(data) {
      // alert(data);
      darray = data.split(",");

      if (Number(darray[0])>0) // Final Results PDF available
	{
	// The jQuery to re-enable the button doesn't work
	//see http://stackoverflow.com/questions/6478333/jquery-disabled-button-not-working-with-ie
	//$('#FinalResultsPDF').removeAttr('disabled');
	document.getElementById('FinalResultsPDF').removeAttribute('disabled');
	} 
      else 
	{
	$('#FinalResultsPDF').attr('disabled','disabled');
	}

      if (darray[1]=='Y') // Show Award Winners
	{
	// The jQuery to re-enable the button doesn't work
	//see http://stackoverflow.com/questions/6478333/jquery-disabled-button-not-working-with-ie
	//$('#AwardWinners').removeAttr('disabled');
	document.getElementById('AwardWinners').removeAttribute('disabled');
	} 
      else 
	{
	$('#AwardWinners').attr('disabled','disabled');
	}

      if (darray[2]=='Y') // Make Notes available
	{
	// The jQuery to re-enable the button doesn't work
	//see http://stackoverflow.com/questions/6478333/jquery-disabled-button-not-working-with-ie
	//$('#Notes').removeAttr('disabled');
	document.getElementById('Notes').removeAttribute('disabled');
	} 
      else 
	{
	$('#Notes').attr('disabled','disabled');
	}

      if (darray[3]=='Y') // selected event has Special Tests
	{
	$('#btnLeaderBoards').attr('title','Results to highest available test, automatically updated');

	$('#btnCombined').attr('value','Test & Overall Results');
	$('#btnCombined').attr('title','Times on a test and results after the test: for everyone, by class, group, award and category');

	$('#btnOverallPositions').attr('value','Results to a test');

	$('#btnStageTimes').attr('value','Times for a test');
	$('#btnStageTimes').attr('title','Times on a test: for everyone, by class, group, award and category');

	$('#btnWithTimes').attr('value','Times for a block of tests');
	$('#btnWithTimes').attr('title','Results after a test with times for a block of previous tests');

	$('#btnComparison').attr('title','Comparison of test times of up to 6 competitors');

	$('#btnIgnoring').attr('title','Results ignoring specified tests and/or road penalties');

	$('#btnStageChart').attr('value','Test Chart');
	$('#btnStageChart').attr('title','Overall positions after every test: in text and graphically');

	$('#btnTimeChart').attr('title','Positions on every test: in text and graphically');

	$('#btnBest').attr('title','Ten best times on every test');

	$('#btnLeaders').attr('title','Ten leading positions after every test');

	$('#btnSummary').attr('value','Test Positions');
	$('#btnSummary').attr('title','Summary of leading performances on every test');

	} 
      else // Selected Event has Special Stages
	{
	$('#btnLeaderBoards').attr('title','Results to highest available stage, automatically updated');

	$('#btnCombined').attr('value','Stage & Overall Results');
	$('#btnCombined').attr('title','Times on a stage and results after the stage: for everyone, by class, group, award and category');

	$('#btnOverallPositions').attr('value','Results to a stage');

	$('#btnStageTimes').attr('value','Times for a stage');
	$('#btnStageTimes').attr('title','Times on a stage: for everyone, by class, group, award and category');

	$('#btnWithTimes').attr('value','Times for a block of stages');
	$('#btnWithTimes').attr('title','Results after a stage with times for a block of previous stages');

	$('#btnComparison').attr('title','Comparison of stage times of up to 6 competitors');

	$('#btnIgnoring').attr('title','Results ignoring specified stages and/or road penalties');

	$('#btnStageChart').attr('value','Stage Chart');
	$('#btnStageChart').attr('title','Overall positions after every stage: in text and graphically');

	$('#btnTimeChart').attr('title','Positions on every stage: in text and graphically');

	$('#btnBest').attr('title','Ten best times on every stage');

	$('#btnLeaders').attr('title','Ten leading positions after every stage');

	$('#btnSummary').attr('value','Stage Positions');
	$('#btnSummary').attr('title','Summary of leading performances on every stage');

	}
    });
}

$(document).ready(function() {
  // do things when the DOM is ready
  $("#SelectEvent").change(setPDFbutton);
  // $('body').css({ 'background-color' : background } );
  // $('#tcsdynamicweb table.noborder th').css({ 'background-color' : background_table } );
  setPDFbutton();
})

