


// This toggles the collapse/expanded state of
// the element with the id indicated by the block argument,
// and updates the button element with the id indicated by
// the control argument.
function collapse(block, control){
  var block_element = doc_element_by_id(block);
  var control_element = doc_element_by_id(control);
  if(block_element.style.display != "none"){
    block_element.style.display = "none";
    control_element.innerHTML = "&nbsp;+&nbsp;";
  }
  else{
    block_element.style.display = "block";
    control_element.innerHTML = "&nbsp;-&nbsp;";
  }
}

// This takes a condition boolean value, and the ids
// of elements to enable and disable when this condition
// is true. When it is falsed, the opposite happens
// the enabled element becomes disabled, the disabled
// becomes enabled.
function enable_disable_type(condition, enable, disable, display_type){
  var enable_element = doc_element_by_id(enable);
  var disable_element = doc_element_by_id(disable);
  if(condition){
    enable_element.style.display = display_type;
    disable_element.style.display = "none";
  }
  else{
    enable_element.style.display = "none";
    disable_element.style.display = display_type;
  }
}

// A convencience function which implements enable_disable_type
// for the normally used "block" type.
function enable_disable(condition, enable, disable){
  return enable_disable_type(condition, enable, disable, 'block');
}