function checkLink(a) {
   var sel = document.theform.year.options[document.theform.year.selectedIndex];
   if (sel.value.indexOf(a.id) == -1){
      a.href="#";
      a.disabled=true;
    }
   else {
      a.href=a.id + sel.name + '.htm';
      if (a.href == 'league2001.htm') {
        a.href = 'league.htm';
        }
      if (a.href == 'league2002.htm') {
        a.href = 'league02.htm';
        }
      a.disabled=false;
    }
}

function checkLinks() {
  var i
  for (i=0;i<document.anchors.length;i++) {
    checkLink(document.anchors[i]);
  }
}

function initialiseSelect() {
  for (i=0;i<document.theform.year.options.length;i++){
    if (document.title.indexOf(document.theform.year.options[i].innerHTML) != -1){
      document.theform.year.options[i].selected = true;
    }
  }
  checkLinks();
}

function writeLinks() {
  var sHTML = '<td align="center">';
  sHTML += '<a id="Floorers" href="#" title="Floorer and Eight-Pin Chart"><b>Floorers</b></a>';
  sHTML += '</td>';


  sHTML += '<td align="center">';
  sHTML += '<a id="Page" href="#" title="Page Cup"><b>Page</b></a>';
  sHTML += '</td>';

  sHTML += '<td align="center">';
  sHTML += '<a id="Hcap" href="#" title="Handicap Competition"><b>Handicap</b></a>';
  sHTML += '</td>';

  sHTML += '<td align="center">';
  sHTML += '<a id="Pairs" href="#" title="Field House Cup (Pairs Competition)"><b>Pairs</b></a>';
  sHTML += '</td>';

  sHTML += '<td align="center">';
  sHTML += '<a id="league" href="#" title="League Competition"><b>League</b></a>';
  sHTML += '</td>';

  sHTML += '<td align="center">';
  sHTML += '<select name="year" onchange="javascript:{checkLinks()}" border="0">';
  sHTML += '<option name="2012" value="Floorers">2012</option>';
  sHTML += '<option name="2011" value="PageHcapFloorers">2011</option>';
  sHTML += '<option name="2010" value="Floorers">2010</option>';
  sHTML += '<option name="2009" value="PageHcapFloorers">2009</option>';
  sHTML += '<option name="2008" value="PageHcapFloorers">2008</option>';
  sHTML += '<option name="2007" value="PageHcapPairsFloorers">2007</option>';
  sHTML += '<option name="2006" value="Floorers">2006</option>';
  sHTML += '<option name="2005" value="PageHcapFloorers">2005</option>';
  sHTML += '<option name="2004" value="PageHcapFloorers">2004</option>';
  sHTML += '<option name="2002" value="PageHcapPairsFloorersleague">2002</option>';
  sHTML += '<option name="2001" value="PageHcapPairsFloorersleague">2001</option>';
  sHTML += '<option name="2000" value="PageHcapPairsFloorers">2000</option>';
  sHTML += '<option name="9899" value="PageHcapPairsFloorers">98/99</option>';
  sHTML += '</select>';
  sHTML += '</td>';

  document.write(sHTML);
}

