//<script language="javascript">
/*<!-- This routine allows moving items from one select box to the other. -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin */
sortitems = false;  // Automatically sort items within lists? (1 or 0)

function move(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;
no.selected = true;
tbox.options[tbox.options.length] = no;
fbox.options[i].selected=false;
BumpUp(fbox);
BumpSpaceDown(fbox);
BumpSpaceDown(tbox);
if (sortitems) SortD(tbox);
		}
	}
}

function Remove(fbox)
	{
	var selopt=new Array();
	var j=0;
	for(var i=0; i<fbox.options.length; i++)
		{
		if(fbox.options[i].selected)
			{
			selopt[j]=i;
			j++;
			}
		}
	for(i=0; i < selopt.length; i++)
		{
		for(var j=selopt[i]; j<fbox.length-1; j++)
			{
			fbox.options[j].text=fbox.options[j+1].text;
			fbox.options[j].value=fbox.options[j+1].value;
			if(fbox.options[j].style){
				fbox.options[j].style.color=fbox.options[j+1].style.color;
				fbox.options[j].style.backgroundColor=fbox.options[j+1].style.backgroundColor;
				}
			}
		fbox.length=fbox.length-1;
		for(j=i+1; j<selopt.length; j++)
			{
			selopt[j]=selopt[j]-1;
			}
	    }
	DeselectAll(fbox);
	}


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;
box.options[j].selected = box.options[j+1].selected;
}
var ln = i;
break;
   }
}
if(ln < box.options.length)  {
box.options.length -= 1;
BumpUp(box);
   }
}

function SortD(box, pattern)  {
if(pattern==""){pattern=/.*/;}
var temp_opts = new Array();
var temp = new Object();
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.match(pattern)[1] > temp_opts[y].text.match(pattern)[1])  {
temp = temp_opts[x].text;
temp_opts[x].text = temp_opts[y].text;
temp_opts[y].text = temp;
temp = temp_opts[x].value;
temp_opts[x].value = temp_opts[y].value;
temp_opts[y].value = temp;
temp = temp_opts[x].selected;
temp_opts[x].selected = temp_opts[y].selected;
temp_opts[y].selected = temp;
      }
   }
}
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;
   }
}

function BumpSpaceDown(selcontrol)
	{
	for(i=0; i < selcontrol.length; i++)
		{
		if(selcontrol.options[i].value=="blankline")
			{
			break;
			}
		}
	if(i < selcontrol.length - 1)
		{
		var blank=selcontrol.options[i].text;
		for(var j=i; j<selcontrol.length-1; j++)
			{
			selcontrol.options[j].text=selcontrol.options[j+1].text;
			selcontrol.options[j].value=selcontrol.options[j+1].value;
			if(selcontrol.options[j+1].selected)
				{selcontrol.options[j].selected=true;}
			else
				{selcontrol.options[j].selected=false;}
			}
		selcontrol.options[j].text=blank;
		selcontrol.options[j].value="blankline";
		selcontrol.options[j].selected=false;
		}
	}

function DeselectAll(selcontrol)
	{
	if(selcontrol.length > 0)
	for(var i=0; i < selcontrol.length; i++)
		{
		selcontrol.options[i].selected = false;
		}
	if(selcontrol.name=="seladdoption")
		{selcontrol=selcontrol.form.selremoveoption;}
	else 
		{if(selcontrol.name=="selremoveoption"){selcontrol=selcontrol.form.seladdoption;}}
	for(var i=0; i < selcontrol.length; i++)
		{
		if(selcontrol.options[i].value=="blankline") {selcontrol.options[i].selected=false;}
		}
	}

//</script>
// End -->	