function changeFromSelect (obj) 
{
  var toObj = document.getElementById ('to_' + obj.id.substring (5));

  if (1 * toObj.options[toObj.selectedIndex].value > 1 * obj.options[obj.selectedIndex].value) return;
  else {
      try {
        index = toObj.selectedIndex;
        toObj.options[index].selected = false;
        toObj.options[index+1].selected = true;
        changeFromSelect (obj);
      } catch (e) 
      {
        return;
      }
  }

}


function changeToSelect (obj) 
{
  var fromObj = document.getElementById ('from_' + obj.id.substring (3));

  if (1 * fromObj.options[fromObj.selectedIndex].value < 1 * obj.options[obj.selectedIndex].value) return;
  else {
      try {
        index = fromObj.selectedIndex;
        fromObj.options[index].selected = false;
        fromObj.options[index-1].selected = true;
        changeToSelect (obj);
      } catch (e) 
      {
        return;
      }
  }

}

function findOption(word1, word2) {
  var a = document.getElementById ('sel');
  var pattern = "";
  if(word1.length != 0 || word2.length != 0)
    pattern = "^" + word1 + ".* " + word2 + ".*$";
  re = new RegExp(pattern,"i");

  for(var icount = 0; icount < a.length; icount++) {
    if(re.test(a.options[icount].text)) {
      a.selectedIndex = icount;
      break;
    }
  }
}

