var currentSection = 0;

function displaySection (inSectionToDisplay)
{
  var object = document.getElementById (sectionList[inSectionToDisplay]);
  if (object) object.style.display = "BLOCK";
  setLabelCurrent (inSectionToDisplay);

}

function hideSection (inSectionToDisplay)
{
  var object = document.getElementById (sectionList[inSectionToDisplay]);
  if (object) object.style.display = "NONE";
  setLabelNonCurrent (inSectionToDisplay);
}

function setLabelCurrent (inLabelToSet)
{
  var object = document.getElementById (sectionLabelList[inLabelToSet]);
  if (object) object.className = "sectionLabelCurrent";

  var object = document.getElementById (sectionLabelBoxList[inLabelToSet]);
  if (object) object.className = "sectionLabelBoxCurrent";
}

function setLabelNonCurrent (inLabelToSet)
{
  var object = document.getElementById (sectionLabelList[inLabelToSet]);
  if (object) object.className = "sectionLabel";

  var object = document.getElementById (sectionLabelBoxList[inLabelToSet]);
  if (object) object.className = "sectionLabelBox";
}

function showAllSections ()
{
  showingAll = true;

  l = sectionLabelList.length;

  for (var x=0; x<l; x++)
  {
    displaySection (x);
  }
}

function hideAllSections ()
{
  showingAll = false;

  l = sectionLabelList.length;

  for (var x=0; x<l; x++)
  {
    hideSection (x);
  }
}

  

function selectSection (inSectionToSelect)
{
  if (showingAll)
    hideAllSections ();
  else
    hideSection (currentSection);

  displaySection (inSectionToSelect);

  currentSection = inSectionToSelect;
}

function selectSectionPrev ()
{
  newSection = currentSection - 1;
  if (newSection < 0)
    newSection = 0;

  selectSection (newSection);
}

function selectSectionNext ()
{
  newSection = currentSection + 1;
  if (newSection > maxSectionIndex)
    newSection = maxSectionIndex;

  selectSection (newSection);
}

