function set_section_expand (id, expanded)
{
  div = document.getElementById(id + '-list').style;
  head = document.getElementById(id);

  if (expanded) {
    div.display = 'block';
    head.className = 'section-unexpand';
  } else {
    div.display = 'none';
    head.className = 'section-expand';
  }
}


function toggle_div (id)
{
  expand = document.getElementById(id + '-list').style.display == 'none';
  set_section_expand (id, expand);
  return false;
}


function new_section ()
{
  section = prompt ('Enter new section name:');
  if (section == null || section == "") {
    return false;
  }

  top.location = '?action=addsection&description=' + escape(section);
}


function delete_section (sectionid)
{
  if (confirm ("Are you sure you want to delete this section (and all links contained within it)?")) {
    top.location = '?action=deletesection&sectionid=' + sectionid;
  }
}


function delete_link (linkid)
{
  if (confirm ("Are you sure you want to delete this link?")) {
    top.location = '?action=deletelink&linkid=' + linkid;
  }
}


function edit_section (sectionid, description)
{
  section = prompt ('Section name:', description);
  if (section == null || section == "") {
    return false;
  }

  top.location = '?action=editsection&sectionid=' + sectionid + '&description=' + escape(section);
}


