function DoSelectionList(parrLeftListBox,pstrLeftItems)
{
	to_select = document.getElementById(parrLeftListBox);
	option_count_to = to_select.length;

	to_values = "";
	
	// pass on the number of selections
	lobjAantal = document.getElementById(pstrLeftItems);
	lobjAantal.value = option_count_to;

	// Walk through the 'to'-selectionlist for making a 'comma-seperatedlist' of all the options in 'to'-selectionlist.
	for(i=0; i < option_count_to; i++)
	{
		// When there is more then één option in the 'to'-selectionlist, put a tab behind it.
		if(i > 0)
			to_values += '\f'
			
		// String now looks like Text1,Value1\fText2,Value2
			to_values += to_select.options[i].text;
			to_values += '|';
			to_values += to_select.options[i].value;
	}
	
	lobjAantal.value = to_values;
}
//http://www.codeproject.com/jscript/iliasorter.asp
function up(obj) {
	obj = (typeof obj == 'string') ? document.getElementById(obj) : obj;
	if (obj.tagName.toLowerCase() != 'select' && obj.length < 2)
		return false;
	var sel = new Array();
	for (var i=0; i<obj.length; i++) {
		if (obj[i].selected == true) {
			sel[sel.length] = i;
		}
	}
	for (i in sel) {
		if (sel[i] != 0 && !obj[sel[i]-1].selected) {
			var tmp = new Array(obj[sel[i]-1].text, obj[sel[i]-1].value, obj[sel[i]-1].style.color, obj[sel[i]-1].style.backgroundColor, obj[sel[i]-1].className, obj[sel[i]-1].id);
			obj[sel[i]-1].text = obj[sel[i]].text;
			obj[sel[i]-1].value = obj[sel[i]].value;
			obj[sel[i]-1].style.color = obj[sel[i]].style.color;
			obj[sel[i]-1].style.backgroundColor = obj[sel[i]].style.backgroundColor;
			obj[sel[i]-1].className = obj[sel[i]].className;
			obj[sel[i]-1].id = obj[sel[i]].id;
			obj[sel[i]].text = tmp[0];
			obj[sel[i]].value = tmp[1];
			obj[sel[i]].style.color = tmp[2];
			obj[sel[i]].style.backgroundColor = tmp[3];
			obj[sel[i]].className = tmp[4];
			obj[sel[i]].id = tmp[5];
			obj[sel[i]-1].selected = true;
			obj[sel[i]].selected = false;
		}
	}
}
//http://www.codeproject.com/jscript/iliasorter.asp
function down(obj) {
	obj = (typeof obj == 'string') ? document.getElementById(obj) : obj;
	if (obj.tagName.toLowerCase() != 'select' && obj.length < 2)
		return false;
	var sel = new Array();
	for (var i=obj.length-1; i>-1; i--) {
		if (obj[i].selected == true) {
			sel[sel.length] = i;
		}
	}
	for (i in sel) {
		if (sel[i] != obj.length-1 && !obj[sel[i]+1].selected) {
			var tmp = new Array(obj[sel[i]+1].text, obj[sel[i]+1].value, obj[sel[i]+1].style.color, obj[sel[i]+1].style.backgroundColor, obj[sel[i]+1].className, obj[sel[i]+1].id);
			obj[sel[i]+1].text = obj[sel[i]].text;
			obj[sel[i]+1].value = obj[sel[i]].value;
			obj[sel[i]+1].style.color = obj[sel[i]].style.color;
			obj[sel[i]+1].style.backgroundColor = obj[sel[i]].style.backgroundColor;
			obj[sel[i]+1].className = obj[sel[i]].className;
			obj[sel[i]+1].id = obj[sel[i]].id;
			obj[sel[i]].text = tmp[0];
			obj[sel[i]].value = tmp[1];
			obj[sel[i]].style.color = tmp[2];
			obj[sel[i]].style.backgroundColor = tmp[3];
			obj[sel[i]].className = tmp[4];
			obj[sel[i]].id = tmp[5];
			obj[sel[i]+1].selected = true;
			obj[sel[i]].selected = false;
		}
	}
}
// ------------------------------------------------------------------
function getSelectedValues(parrLeftListBox,pstrLeftItems,parrRightListBox,pstrRightItems)
{
	form = globalForm
	
	DoSelectionList(parrLeftListBox, pstrLeftItems);
	// Now the other listbox
	DoSelectionList(parrRightListBox, pstrRightItems);
}

// ------------------------------------------------------------------
function moveSelected(pstrSelListBoxName,pstrNotSelListBoxName, bCopyLeft, bCopyRight)
{

	form = document.forms[0]//." + FormID + @";
	to_element = form.elements[pstrSelListBoxName];
	from_select = document.getElementById(pstrNotSelListBoxName);
	to_select =  document.getElementById(pstrSelListBoxName);

	option_count_from = from_select.length;

	// Has something been selected?
	if(from_select.selectedIndex > -1)
	{
		index = 0;
		selected_from_options = new Array();

		// Which options are selected within the 'from'-selectionlist.
		for(i = option_count_from-1; i > -1; i--)
		{
			// Option selected?
			if(from_select.options[i].selected && from_select.options[i].title != "disabled")
			{
				// Calculate the number of (to do) selectable options within the 'to'-selectionlist.
				option_count_to = to_select.length;
				// Make a new 'OPTION'-object
			if (!bCopyRight)
			{
				new_option = document.createElement("OPTION");
				// Add this 'OPTION'-object to the 'to'-selectionlist.
				to_element.options.add(new_option, option_count_to);
				// Add the selected option from the 'from'-selectionlist to the 'to'-selectionlist.
				to_select.options[option_count_to].text = from_select.options[i].text;
				to_select.options[option_count_to].value = from_select.options[i].value;
				// Add it to the list of selected options.
			}
				selected_from_options[index++] = i;
			}
		
		}
		// Solution for Internet Explorer, When the number of selected options is bigger than what can be shown on screen!
		if(index > from_select.size)
			from_select.click();
		if (!bCopyLeft || bCopyRight)
		{
			// Delete the selected option(s) from the 'from'-selectionlist.
			for(i = 0; i < index; i++)
			{
				from_select.remove(selected_from_options[i]);
			}
		}
}
}

function moveAll(pstrSelListBoxName,pstrNotSelListBoxName, bCopyLeft, bCopyRight)
{
	form = globalForm;	
	to_element = form.elements[pstrSelListBoxName];
	from_select = document.getElementById(pstrNotSelListBoxName);
	to_select = document.getElementById(pstrSelListBoxName);
	option_count_from = from_select.length;				
	// Calculate the number of (to do) to be selected options within the 'from'-selectionlist.
	var inx=0;
	for(i=0; i < option_count_from; i++)
	{
		if(from_select.options[0].title != "disabled")
		{

			if (!bCopyRight)
			{
			// Make a new 'OPTION'-object
			new_option = document.createElement("OPTION");
			// Bepaal waarin de 'to'-selectielijst de opties van de 'from'-selectielijst moeten worden toegevoegd.
			option_count_to = to_select.length;
			// Add this 'OPTION'-object to the 'to'-selectionlist.
			to_element.options.add(new_option, option_count_to);
			// Add the first option from the 'from'-selectionlist to the 'to'-selectionlist.
			to_select.options[option_count_to].text = from_select.options[inx].text;
			to_select.options[option_count_to].value = from_select.options[inx].value;
			}

			if (!bCopyLeft)
			{
			// delete the option from the 'from'-selectionlist.
			from_select.remove(0);
			}
			else
			{

				inx++;
			}
		}
	} 
}
// sort function for the multiselect boxes
function sortMover(mover)
{
	// Temporary array for the sorting of the mover.
	temp = new Array();
	// When there is nothing in the mover, do nothing.
	if(mover.options != null)
	{
		// Copy the options from the mover to the temporary array.
		for(i = 0; i < mover.options.length; i++)
		temp[temp.length] =  new Option(mover.options[i].text, mover.options[i].value, mover.options[i].defaultSelected, mover.options[i].selected);
		// Sort temporary array.
		if(temp.length != 0)
		temp.sort(function(a,b)
					{
					if((a.text+"").toUpperCase() < (b.text+"").toUpperCase())
						return -1;
					if((a.text+"").toUpperCase() > (b.text+"").toUpperCase())
						return 1;
					return 0;
					})
		// Copy temporary array to the mover.
		for(i = 0; i < temp.length; i++)
		mover.options[i] = new Option(temp[i].text, temp[i].value, temp[i].defaultSeleted, temp[i].selected);
	}

function moveOptionUp(obj) {
	if (!hasOptions(obj)) { return; }
	for (i=0; i<obj.options.length; i++) {
		if (obj.options[i].selected) {
			if (i != 0 && !obj.options[i-1].selected) {
				swapOptions(obj,i,i-1);
				obj.options[i-1].selected = true;
				}
			}
		}
	}
function moveOptionDown(obj) {
	if (!hasOptions(obj)) { return; }
	for (i=obj.options.length-1; i>=0; i--) {
		if (obj.options[i].selected) {
			if (i != (obj.options.length-1) && ! obj.options[i+1].selected) {
				swapOptions(obj,i,i+1);
				obj.options[i+1].selected = true;
				}
			}
		}
	}

}
