var kImageDir = 'resources/images'; //IE doesn't like const keyword

var iCategory = 0;
var iItem = 0;

// The following toggles all disclosures to the closed position. By performing
// this in JavaScript instead of the stylesheet, we ensure noscript browsers
// see all disclosures in their open state for a graceful failure.
document.write(
  '<style type="text/css">.slToggleGroup {display:none;}</style>');

//______________________________
function toggleDiv(sSectionName) {
  var bDisclosed=(document.getElementById(sSectionName +
    '_list').style.display == 'block');
  document.getElementById(sSectionName + '_list').style.display =
    (bDisclosed)?'none':'block';
  document.getElementById(sSectionName + "_arrow").src =
    (bDisclosed)?kImageDir + '/disclosure_right.png' :
      kImageDir +'/disclosure_down.png';
  // Factor-out arrows to the stylesheet (won't work in IE)
//  document.getElementById(sSectionName + '_system').setAttribute('class',
//    (bDisclosed)?'slSystem':'slSystemAlt');
  return false; //return false should allow href="#" instead of void(0);
}

// Considered client-side XMLHttpRequest to an ASP to dynamically load all
// files, but that will not fail gracefully on noscript browsers. Could use
// a PHP module, but it's best to stay away from increasing the complexity of
// this site. The last option is probably an ASP that presents preformatted
// HTML to be manually copied and pasted to the article from Joomla
// author mode. The code below was for another experiment.

//_____________________________
function startSection(sSection) {
  document.write('<tr><td colspan="3">');
  document.write('<h3 style="margin-bottom:0;">');
  document.write(sSection);
  document.write('</h3>');
  document.write('</td></tr>');
  document.write('<tr><td width="4%"></td>');
}

//____________________
function startColumn() {
  document.write('<td width="48%">');
}

//___________________________
function startCategory(sName) {
  iItem = ++iItem;
  document.write('<a href="javascript:void(0);" onclick="toggleList(\'' +
    iItem + '\');" style="text-decoration:none;">');
  document.write('<h4 style="font-weight:normal;">');
  document.write('<img height="9" width="9" ' +
    'src="' + kImageDir +'/disclosure_right.png" ' +
    'id="' + iItem + '_arrow">');
  document.write('&nbsp;' + sName);
  document.write('</h4>');
  document.write('</a>');
  document.write('<div id="' + iItem + '_list" style="display:none;"0>');
  document.write('<ul>');
}

//____________________________
function addItem(sName, sHref) {
  document.write('<li>');
  document.write('<a href="' + sHref + '" target="_blank">');
  document.write(sName);
  document.write('</a></li>');
}

//____________________
function endCategory() {
  document.write('</ul>');
  document.write('</div>');
}

//__________________
function endColumn() {
  document.write('</td>');
}

//___________________
function endSection() {
  document.write('</tr>');
}
