<!--
var count1 = 0;
var count2 = 0;

function insertOptionBefore(theItem, num)
{
  var elSel = document.getElementById(theItem);
  if (elSel.selectedIndex >= 0) {
    var elOptNew = document.createElement('option');
    elOptNew.text = 'Insert' + num;
    elOptNew.value = 'insert' + num;
    var elOptOld = elSel.options[elSel.selectedIndex];  
    try {
      elSel.add(elOptNew, elOptOld); // standards compliant; doesn't work in IE
    }
    catch(ex) {
      elSel.add(elOptNew, elSel.selectedIndex); // IE only
    }
  }
}

function removeOptionSelected(theItem)
{
  var elSel = document.getElementById(theItem);
  var i;
  for (i = elSel.length - 1; i>=0; i--) {
    if (elSel.options[i].selected) {
      elSel.remove(i);
    }
  }
}

function appendOptionLast(theItem, theText, theValue, itsSelected)
{
  //var elOptNew = document.createElement('option');
  var elOptNew = new Option(theText, theValue, false, itsSelected);
  
  
  var elSel = document.getElementById(theItem);

  try {
    //elSel.add(elOptNew, null); // standards compliant; doesn't work in IE
   
		elSel.options[elSel.length] = elOptNew;
  }
  catch(ex) {
    elSel.add(elOptNew); // IE only
  }
  
  try {
   if(itsSelected) {
   		//debugObj.log("setting selected index");
   		//var theNumber = elSel.options.length-1;
   		//debugObj.log("setting selected index on "+elSel.id+" with "+theNumber.toString());
   		//debugObj.dir(elSel);
    	//elSel.selectedIndex = elSel.options.length-1;
    	//debugObj.log("passed setting selected index on "+elSel.id+" with "+elSel.selectedIndex);
    }
 	}
 	catch(e) {
 		debugObj.log("ALERT: FAILED TO SELECT OPTION "+elSel.id+" for "+theText);
 		debugObj.dir(e);
 	}
  return(elSel);
}

function removeOptionLast(theItem)
{
  var elSel = document.getElementById(theItem);
  if (elSel.length > 0)
  {
    elSel.remove(elSel.length - 1);
  }
}

function removeAllOptionsExceptOne(theItem)
{
  var elSel = document.getElementById(theItem);
  try {
	  while (elSel.length > 1)
	  {
	    elSel.remove(elSel.length - 1);
	  }
  }
  catch(e) {
  
  }
}
//-->
