

// This switches the notebok to the given tab number.
function notebook_tab_switch(notebook_id, tab_number){
  var tab_index = 1;
  var tab_element = null;
  var label_element = null;
  set_cookie(notebook_id + '__tab_select', tab_number);
  // Loop until we can't find any more numbered tab ids, setting
  // the proper display state.
  while((tab_element = doc_element_by_id(notebook_id + '-tab-' + tab_index)) &&
        (label_element = doc_element_by_id(notebook_id + '-label-' + tab_index))){
    if(tab_index == tab_number){
      tab_element.style.display = "block";
      label_element.className = "notebook-label-selected js-clickable";
    }
    else{
      tab_element.style.display = "none";
      label_element.className = "notebook-label js-clickable";
    }
    tab_index = tab_index + 1;
  }
}
