function update_all()
{
  update_options('x_options');
  update_options('y_options');
  update_options('str_options');
  update_options('spore_options');
}
function update_options(el_id)
{
  var num = document.getElementById(el_id);
  var i=1;
  var s;
  /*Not sure why the next line gives a warning in Java Console:*/
  var p = parseInt(num.value);
  p++;
  var len = document.getElementById(el_id+"_len");
  if(el_id == "x_options")
  s = "divx";
  if(el_id == "y_options")
  s = "divy";
  if(el_id == "str_options")
  s = "divs";
  if(el_id == "spore_options")
  s = "divp";

  for(i = 1; i <= num.value; i++)
  {
    document.getElementById(s + i).style.display = "inline";
  }
  for(i=p; i <=len.value; i++)
  {
    document.getElementById(s + i).style.display = "none";
  }
}

function update_prob(el_id)
{
  var el_b;
  var el_nb;
  if(el_id == "pb" || el_id == "pnb")
    {
      el_b = document.getElementById("pb");
      el_nb = document.getElementById("pnb");
    }
  else
    if(el_id =="spb" || el_id == "spnb")
      {
      el_b = document.getElementById("spb");
      el_nb = document.getElementById("spnb");
      }
    else
      if(el_id =="spore_prob" || el_id == "no_spore_prob")
        {
          el_b = document.getElementById("spore_prob");
          el_nb = document.getElementById("no_spore_prob");
        }
  if(el_id =="sub-con_prob" || el_id=="no_sub-con_prob")
    {
      el_b = document.getElementById("sub-con_prob");
      el_nb = document.getElementById("no_sub-con_prob");
    }
  if(el_id == "pcb" || el_id == "pncb")
    {
      el_b = document.getElementById("pcb");
      el_nb = document.getElementById("pncb");
    }
  if(el_id == "prim_conid_branch" || el_id == "no_prim_conid_branch")
    {
      el_b = document.getElementById("prim_conid_branch");
      el_nb = document.getElementById("no_prim_conid_branch");
    }
  var bfl;
  var nbf;
  if(el_id == "pb" || el_id == "spb" || el_id == "spore_prob" || el_id =="sub-con_prob" || el_id == "pcb"
	|| el_id == "prim_conid_branch")
    {//set the pnb to be 1 - pb                                                                                                 
      bfl = parseFloat(el_b.value);
      el_nb.value= (1.0 - bfl).toFixed(3);
    }
  else
    if(el_id == "pnb" || el_id == "spnb" || el_id == "no_spore_prob" || el_id == "no_sub-con_prob"
       || el_id == "pncb" || el_id == "no_prim_conid_branch")
      {
        nbf = parseFloat(el_nb.value);
        el_b.value= (-1.0*nbf + 1.0).toFixed(3);
      }
}
