<!-- //

/**
 * select all value for form onsubmit so that all value can get carry over
 */
function selectAll() {
}

/**
 * select all value for form onsubmit so that all value can get carry over
 */
function updateValue(fbox, valueHolderAdd, valueHolderRem) {
	var str = '';
	var val;
	var bFound = false;
	var tempArr;
	
	for(var i=0; i<fbox.options.length; i++) {
		if(fbox.options[i].selected && fbox.options[i].value != "") {
			
			tempArr = valueHolderAdd.value.split(",");
			
			val = fbox.options[i].value;
			for(var j=0; j<tempArr.length; j++)
			{
				if(tempArr[j] == val)
				{
					bFound = true; break;
				}
			}
			if(!bFound)
			{
				str = val + ",";
				valueHolderAdd.value += str;			
			}
			
			tempArr = valueHolderRem.value.split(",");
			valueHolderRem.value = "";
			for(var j=0; j<tempArr.length; j++)
			{
				if(tempArr[j] != val)
				{
					str = tempArr[j] + ",";
					valueHolderRem.value += str;
				}
			}
	   }
	}
	//alert(valueHolder.value);
}

function updateValue2(e, valueHolderAdd, valueHolderRem) {
	var str = '';
	var val;
	var bFound = false;
	var tempArr;
	
	val = e.value;
	if(val == "") return;
	tempArr = valueHolderAdd.value.split(",");
			
	for(var j=0; j<tempArr.length; j++)
	{
		if(tempArr[j] == val)
		{
			bFound = true; break;
		}
	}
	if(!bFound)
	{
		str = val + ",";
		valueHolderAdd.value += str;			
	}
			
	tempArr = valueHolderRem.value.split(",");
	valueHolderRem.value = "";
	for(var j=0; j<tempArr.length; j++)
	{
		if(tempArr[j] != val)
		{
			str = tempArr[j] + ",";
			valueHolderRem.value += str;
		}
	}
	e.value = "";
}

//sortitems = 1;  // Automatically sort items within lists? (1 or 0)
sortitems = 0;  // don't sort, the groups and users are too big for this app.

function move(fbox,tbox) {
	for(var i=0; i<fbox.options.length; i++) {
		if(fbox.options[i].selected && fbox.options[i].value != "") {
			if(tbox != null) {
				var no = new Option();
				no.value = fbox.options[i].value;
				no.text = fbox.options[i].text;
							
				tbox.options[tbox.options.length] = no;
			}
			fbox.options[i].value = "";
			fbox.options[i].text = "";			
	   }
	}
	BumpUp(fbox);
	if (sortitems) SortD(tbox);
}

function move2(tbox, idElement, textBox) {
	var found = false;
	if(idElement.value=="" || idElement.value == -1) return false;
	for(var i=0; i<tbox.options.length; i++) {
		if(tbox.options[i].value == idElement.value) {
			found = true;
			break
		}
	}
	
	if(!found)
	{
		var no = new Option();
		no.value = idElement.value;
		no.text = textBox.value;
	
							
		tbox.options[tbox.options.length] = no;

		SortD(tbox);
		
		textBox.value = "";
		
	}
	
	return !found
}

// remove fbox selected items from fbox2 if they exist.
function removeFromSel(fbox, fbox2) {
	for(var i=0; i < fbox.options.length; i++) {
		if(fbox.options[i].selected && fbox.options[i].value != "") {
			for(var j=0; j<fbox2.options.length; j++)
			{
				if(fbox2.options[j].value == fbox.options[i].value)
				{
					fbox2.options[j].value = "";
					fbox2.options[j].text = "";			
				}
			}
	   }
	}
	BumpUp(fbox2);
	if (sortitems) SortD(fbox2);
}

// add fbox selected items to tbox
function addToSel(fbox, tbox) {

	for(var i=0; i<fbox.options.length; i++) {
		if(fbox.options[i].selected && fbox.options[i].value != "") {
			var no = new Option();
			no.value = fbox.options[i].value;
			no.text = fbox.options[i].text;
						
			tbox.options[tbox.options.length] = no;
	   }
	}
	if (sortitems) SortD(tbox);
}


function BumpUp(box)  {
	for(var i=0; i<box.options.length; i++) {
		if(box.options[i].value == "")  {
			for(var j=i; j<box.options.length-1; j++)  {
				box.options[j].value = box.options[j+1].value;
				box.options[j].text = box.options[j+1].text;
			}
			var ln = i;
			break;
		}
	}
	if(ln < box.options.length)  {
		box.options.length -= 1;
		BumpUp(box);
	}
}

function SortD(box)  {
	var temp_opts = new Array();
	var temp = new Object();
	var tempValue;
	
	for(var i=0; i<box.options.length; i++)  {
		temp_opts[i] = box.options[i];
	}
	for(var x=0; x<temp_opts.length-1; x++)  {
		for(var y=(x+1); y<temp_opts.length; y++)  {
			if(temp_opts[x].text > temp_opts[y].text)  {
				temp = temp_opts[x].text;
				tempValue = temp_opts[x].value;
				temp_opts[x].text = temp_opts[y].text;
				temp_opts[x].value = temp_opts[y].value;
				temp_opts[y].text = temp;
				temp_opts[y].value = tempValue;
	      }
	   }
	}
	for(var i=0; i<box.options.length; i++)  {
		box.options[i].value = temp_opts[i].value;
		box.options[i].text = temp_opts[i].text;
   }
}


//group check box manipulation.

function doChkAllChange(chkAll, chkItemList) {
	chkItemList.checked = chkAll.checked;
	for(var i = 0; i < chkItemList.length; i++) {
		chkItemList[i].checked = chkAll.checked;
	}
}

// -->
