function switch_off(box) {
    box.checked = false;
    return true;
}

function new_seqtype(the_form, f_value) {

  var dmatrix = new Array('+5/-4', 'blastn2', '+4/-4', '+4/-8');

  var pmatrix = new Array('Blosum50', 'Blosum62', 'BlastP62', 'Blosum80', 'Pam250',
			  'Pam120', 'MD20', 'MD10');

  var smatrix = new Array;
  var the_gap = the_form['gap'];
  var the_ext = the_form['ext'];
  var dna_off;

  if (f_value == 1) {
    // Protein
    smatrix = pmatrix;	
    dna_off = 0;
	
    if (the_form['program'].value=='lalign') {
      the_gap.value= -12;
    } else {
      the_gap.value= -10;
    }
    the_ext.value= -2;
  } 
  else if (f_value >= 2 && f_value <= 4) {
    // DNA
    smatrix = dmatrix;
    dna_off = 10;
    the_gap.value= -12;
    the_ext.value= -4;
  } else {
    // no value set yet?
    smatrix = pmatrix;
    dna_off = 0;
    the_gap.value= -10;
    the_ext.value= -2;
  }

  the_obj = the_form['smatrix'];
  for (var i=0; i < smatrix.length; i++) {
    the_obj.options[i]=new Option(smatrix[i],i+dna_off,false);
  }
  the_obj.options[0].selected=true;
  the_obj.options.length=smatrix.length;
}

function update_gap(form) {

  var po_matrix = new Array('-12','-8','-12','-12','-12','-20','-26','-27');
  var pe_matrix = new Array('-2' ,'-1', '-1', '-2', '-2', '-4', '-4', '-4');

  var sel_index = form['smatrix'].selectedIndex;
  var matrix_index = form['smatrix'].options[sel_index].value;

//  alert('seqtype checked: '+form.seqtype[0].checked+'value: '+form.seqtype[0].value+'matrix_index :'+matrix_index);

  if (form['program'].value=='lalign') {pe_matrix[1]='-2';}

  if (form.seqtype[0].checked!=true) {
     form.gap.value = '-12';
     form.ext.value = '-4';
  }
  else {
     form.ext.value = pe_matrix[matrix_index];
     form.gap.value = po_matrix[matrix_index]-pe_matrix[matrix_index];
  }
}

// this program should update the seqtype options given the program

function update_pgm(form) {

  if (!form.program[0].checked) {
      form.seqtype[0].checked=true;
      form.seqtype[0].selectedIndex=0;
      new_seqtype(form,1);
  }
}

