function toggleThis(toggle, sectionid) {
  var section = document.getElementById(sectionid);

  if (!section) {
    alert ('no section found: ' + sectionid);
    return;
  }

  if (section.style.display == 'none') {
    section.style.display = 'block';
    toggle.innerHTML = 'Hide';
  } else {
    section.style.display = 'none';
    toggle.innerHTML = 'Show';
  }

  // need to make a clean separation b/w toggleThis and the editor-tabs.js -- resizing routine will have to be passed in
  if (top.resizePane) {
    top.resizePane(top.currentPane);
  }
}

function showSelection(selectPopup) 
{
    if (!selectPopup) {
        return;
    }
    for (var i = 0; i < selectPopup.options.length; i++) {
        var value = selectPopup.options[i].value;
        if (value != "0") {
            var box = document.getElementById(value);
            if (box) {
                if (i == selectPopup.selectedIndex) {
                    box.style.display = 'block';
                } else {
                    box.style.display = 'none';
                }
            }
        }
    }
    if (top.resizePane) {
        top.resizePane(top.currentPane);
    }
}

function showTableRows(selectPopup) {
    if (!selectPopup) {
        return;
    }
    for (var i = 0; i < selectPopup.options.length; i++) {
        var value = selectPopup.options[i].value;
        if (value != "0") {
            if (i == selectPopup.selectedIndex) {
                showRowsBySectionId(value);
            } else {
                hideRowsBySectionId(value);
            }
        }
    }
}

function showRowsBySectionId(sectionId) {
    var index = 1;
    var row = document.getElementById(sectionId + "_" + index);

    while (row) {
        try {
            row.style.display='table-row';
        } catch(e) {
            row.style.display = 'block';
        }      
        index++;
        row = document.getElementById(sectionId + "_" + index);
    }

}

function hideRowsBySectionId(sectionId) {
    var index = 1;
    var row = document.getElementById(sectionId + "_" + index);

    while (row) {
        row.style.display='none';
        index++;
        row = document.getElementById(sectionId + "_" + index);
    }
}
