var Elements = {
	_sort:function(s,val){
		// JW: sorts select list 'sel' and selects them 'val'
		sel = document.getElementById(s);
		var data = new Array();
		data[0] = new Array();
		data[1] = new Array();
		// window.status = sel.length;
		for (x=0;x<=sel.length-1;x++){
			data[0][x] = sel.options[x].text;
			data[1][x] = sel.options[x].value;
		}
		data[0].sort();
		sel.options.length=null;
		for (x=0;x<data[0].length;x++){
			//sel.options[sel.length] = new Option( data[0][x],  data[1][x],val,val);
			sel.options[sel.length] = new Option( data[0][x],  data[1][x]);	
		}
	},
	_selectAll:function(sel){
		tbox = document.getElementById(sel);
		for(i = 0; i <= tbox.options.length-1; i++){
			 tbox.options[i].selected=true;
		}
	},
	_addOption:function(theSel, theText, theValue){
		var newOpt = new Option(theText, theValue);
		var selLength = theSel.length;
		theSel.options[selLength] = newOpt;
	},
	_deleteOption:function(theSel, theIndex){ 
		var selLength = theSel.length;
		if(selLength>0){
			theSel.options[theIndex] = null;
		}
	},
	_moveSelects:function(selFrm, selTo){
		theSelFrom = document.getElementById(selFrm);
		theSelTo = document.getElementById(selTo);
		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;
				Elements._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--){
			Elements._addOption(theSelTo, selectedText[i], selectedValues[i]);
		}
	}	
};