var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);





function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{ 
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function showEm() {
	alertText = "";
	for (i=0;i<boxLen;i++) {
		alertText = alertText + dfr.options[i].value + " ";
	}
	alert(alertText);
}

function moveOptions(theSelFrom, theSelTo)
{
  
  var selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedCount = 0;
  
  var i;
  
  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }
  
  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    addOption(theSelTo, selectedText[i], selectedValues[i]);
  }
  
  if(NS4) history.go(0);
}

//-->
function moveEm(direction,listname) {
	if (listname == 'eventsinclude') {
		dfr = document.forms[1].eventsinclude;
	}
	//dfr = document.forms[0].listname;
	boxLen = dfr.length;
	currentItem = dfr.selectedIndex;

	if ((direction == 'up') && (currentItem > 0)) {  
	//reorder the text
		selText = dfr.options[currentItem].text;
		swpText = dfr.options[currentItem - 1].text;

	// reorder the value
		selValue = dfr.options[currentItem].value;
		swpValue = dfr.options[currentItem -1].value;

	//reorder the text
		dfr.options[currentItem - 1].text = selText;
		dfr.options[currentItem].text = swpText;

	// reorder the value
		dfr.options[currentItem - 1].value = selValue;
		dfr.options[currentItem].value = swpValue;
		dfr.selectedIndex = currentItem - 1;

	// write reordered values to the hidden variable
		writeList();

		} else if ((direction == 'down') && (currentItem < boxLen -1) && (currentItem != -1)) {

			selText = dfr.options[currentItem].text;
			swpText = dfr.options[currentItem + 1].text;

			// reorder the value
			selValue = dfr.options[currentItem].value;
			swpValue = dfr.options[currentItem +1].value;
                        
			//reorder the text
			dfr.options[currentItem + 1].text = selText;
			dfr.options[currentItem].text     = swpText;

			//reorder the value
			dfr.options[currentItem + 1].value = selValue;
			dfr.options[currentItem].value = swpValue;
			dfr.selectedIndex = currentItem + 1;

		// write reordered values to the hidden variable
			writeList();
			} else if (currentItem == -1) {
// alert("An item must select before it can be reordered.");
            } else {}

}

function writeList() {
	alertText = "";
	for (i=0;i<boxLen;i++) {
		// value does not work as the list is effectively unchanged
		alertText = alertText + dfr.options[i].value+ ",";
	}
	//alert(alertText);
	document.forms[1].eventsinclude.value = alertText;
}

function myStatusUpdate(n){
	var x=document.getElementById(n);
	var y=x.options[x.selectedIndex].text;
	//alert(y);
	MM_displayStatusMsg(y);
	return document.MM_returnValue;
}

//-->