
<!--

	function listBoxItem(id, desc) {
		this.id = id
		this.desc = desc
	}	

	function moveone(myid){
		//alert(myid);
		var box1 = document.getElementById('availableOptions');
		var box2 = document.getElementById('selectedOptions');
		if(box2.length ==3){
			alert('You can select up to three groups');
			return false;
			}
		for (var x=0; x<box1.length; x++) {
			if (box1.options[x].value == myid) {
				box1.options[x].selected = true;
			//	alert('I am here');
				moveItem(box1, box2);
			}
		}
	}
	function moveItem(listBox1, listBox2) {
		//alert('did I come here');
		var selected
		var numSel
		var currItem
		var newIndex
		var j
		var aryNotSelected
		
		//Check whether any item is selected
		for (var x=0; x<listBox1.length; x++) {
			if (listBox1.options[x].selected == true && listBox1.options[x].value != "") {
				selected = true
			}
		}
		
		if (!selected) {
			alert ('Please highlight item(s) from the list first!')
		
		} else {
						
			if (listBox2.length == 1 && listBox2.options[0].value == "") {
				listBox2.length = 0
			}
			
			numSel = 0 
							
			//Loop thru the listBox1 and move any selected item to listBox2
			for (var m=0; m<listBox1.length; m++) {
				currItem = listBox1.options[m]	
				if (currItem.selected) {
						//Count the selected items
						numSel++
						//Add new item
						newIndex = listBox2.length
						listBox2.options[newIndex] = new Option(currItem.text, currItem.value, false, false)
						listBox2.length = newIndex + 1
				} 		
			}

			//Get non-selected items from listBox1 and store into an array
			j = 0
			if (numSel != 0) {
				aryNotSelected = new Array(listBox1.length - numSel)
				for (var n=0; n<listBox1.length; n++) {
					currItem = listBox1.options[n]
					if (!currItem.selected) {
						aryNotSelected[j++] = new listBoxItem(currItem.value, currItem.text)
					}
				}
			}
				
			//Delete all items from listBox1
			listBox1.length = 0
		
			//Loop thru the not selected Array and fill in listBox1
			for (var i=0; i<aryNotSelected.length; i++) {	
				//Add new item
				listBox1.options[i] = new Option(aryNotSelected[i].desc, aryNotSelected[i].id)
			}
			//************************
		}
	}

/*
function moveItem(listBox1, listBox2,len) {
		var selected
		var numSel
		var currItem
		var newIndex
		var j
		var aryNotSelected
		
		//Check whether any item is selected
		for (var x=0; x<listBox1.length; x++) {
			if (listBox1.options[x].selected == true && listBox1.options[x].value != "") {
				selected = true
			}
		}
		
		if (!selected) {
			alert ('Please highlight item(s) from the list first!')
		
		} else {
						
			if (listBox2.length == 1 && listBox2.options[0].value == "") {
				listBox2.length = 0
			}
			
			numSel = 0 
							
			//Loop thru the listBox1 and move any selected item to listBox2
			for (var m=0; m<listBox1.length; m++) {
				currItem = listBox1.options[m]	
				if (currItem.selected) {
						//Count the selected items
						numSel++
						//Add new item
						newIndex = listBox2.length
						listBox2.options[newIndex] = new Option(currItem.text.substring(0,len).concat("..."), currItem.value, false, false)
						listBox2.length = newIndex + 1
				} 		
			}

			//Get non-selected items from listBox1 and store into an array
			j = 0
			if (numSel != 0) {
				aryNotSelected = new Array(listBox1.length - numSel)
				for (var n=0; n<listBox1.length; n++) {
					currItem = listBox1.options[n]
					if (!currItem.selected) {
						aryNotSelected[j++] = new listBoxItem(currItem.value, currItem.text)
					}
				}
			}
				
			//Delete all items from listBox1
			listBox1.length = 0
		
			//Loop thru the not selected Array and fill in listBox1
			for (var i=0; i<aryNotSelected.length; i++) {	
				//Add new item
				listBox1.options[i] = new Option(aryNotSelected[i].desc, aryNotSelected[i].id)
			}
			//************************
		}
	}

*/
function up(obj)
{
  var currernt;
  var reverse;
  if(obj.options[obj.options.selectedIndex].index > 0)
  {
    current = obj.options[obj.options.selectedIndex].text;
    reverse = obj.options[obj.options[obj.options.selectedIndex].index-1].text;
    obj.options[obj.options.selectedIndex].text = reverse;
    obj.options[obj.options[obj.options.selectedIndex].index-1].text = current;
    self.focus();
    obj.options.selectedIndex--;
  }
}

function down(obj)
{
  var currernt;
  var next;
  if(obj.options[obj.options.selectedIndex].index != obj.length-1)
  {
    current = obj.options[obj.options.selectedIndex].text;
    next = obj.options[obj.options[obj.options.selectedIndex].index+1].text;
    obj.options[obj.options.selectedIndex].text =  next;
    obj.options[obj.options[obj.options.selectedIndex].index+1].text = current;
    self.focus();
    obj.options.selectedIndex++;
  }
}

//-->


