<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Modified by GSMR -->

sortitems = 0;  // 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;
   tbox.options[tbox.options.length] = no;
   fbox.options[i].value = "";
   fbox.options[i].text = "";
  }
 }
 BumpUp(fbox);
 if (sortitems) SortD(tbox);
}

//Added DRS 02/27/06
function dump(fbox,tbox) 
{
 for(var i=0; i<fbox.options.length; i++) 
 {
   var no = new Option();
   no.value = fbox.options[i].value;
   no.text = fbox.options[i].text;
   tbox.options[tbox.options.length] = no;
 }
 fbox.options.length = 0;
 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)  //Sort ascending
{
 var temp_opts = new Array();
 var temp = new Object(); //Holder so that values may be swapped
 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) //If the value of the item before is larger than the item after, swap their positions in the list.
   {
    temp = temp_opts[x].text;
    temp_opts[x].text = temp_opts[y].text;  //Swap text
    temp_opts[y].text = temp;

    temp = temp_opts[x].value;
    temp_opts[x].value = temp_opts[y].value;  //Swap value
    temp_opts[y].value = temp;
   }
  }
 }
 for(var i=0; i < box.options.length; i++)  //Assign the now sorted values back to the original list box
 {
  box.options[i].value = temp_opts[i].value;
  box.options[i].text = temp_opts[i].text;
 }
}

function SortA(box)  //Sort descending
{
 var temp_opts = new Array();
 var temp = new Object(); //Holder so that values may be swapped
 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) //If the value of the item before is smaller than the item after, swap their positions in the list.
   {
    temp = temp_opts[x].text;
    temp_opts[x].text = temp_opts[y].text;  //Swap text position
    temp_opts[y].text = temp;

    temp = temp_opts[x].value;
    temp_opts[x].value = temp_opts[y].value;  //Swap value position
    temp_opts[y].value = temp;
   }
  }
 }
 for(var i=0; i < box.options.length; i++)  //Assign the now sorted values back to the original list box
 {
  box.options[i].value = temp_opts[i].value;
  box.options[i].text = temp_opts[i].text;
 }
}

function SelectAll(box)
{
 for(var i=0; i<box.options.length; i++) 
 {
  box.options[i].selected = true;
 }
}

<!-- simple counter for limiting input to textarea
function charcnt(len, Targetobj, Cntobj) 
{
	if (Targetobj.value.length > len)
	  Targetobj.value = Targetobj.value.substring(0, len);
	else
	  Cntobj.value = len - Targetobj.value.length;
}
// End -->