<!--

/* This Function Moves rows from one list box to another */
function Activate_MoverBox(active_box,dest_box)
{ for(var i=0; i<active_box.options.length; i++) 
	{if(active_box.options[i].selected && active_box.options[i].value != "" && active_box.options[i].value != "#")
		{  
			var luo_option = new Option();
			luo_option.value = active_box.options[i].value;
			luo_option.text  = active_box.options[i].text;
			dest_box.options[dest_box.options.length] = luo_option;
			active_box.options[i].value = "";
			active_box.options[i].text  = "";
   		}
	}
	Remove_Empty_Rows(active_box);
	Remove_Empty_Rows(dest_box);
	Sort_ListBox(dest_box);
	dest_box.selectedIndex = -1;
	active_box.selectedIndex = -1;
}

/* This Function Sorts a List box */
function Sort_ListBox(box)
{	var temp      = new Object();
	var li_count  = box.options.length;
	for(var x=0; x < li_count; x++)
	{
		for(var y=(x+1); y<li_count; y++)
		{   
			if(box.options[x].text > box.options[y].text)
			{
				temp.text = box.options[x].text;
				temp.value = box.options[x].value;
				box.options[x].text  = box.options[y].text;
				box.options[x].value = box.options[y].value;
				box.options[y].text  = temp.text;
				box.options[y].value = temp.value;
      		}
   		}
	}
}

/* This Function removes empty lines from the list box */
function Remove_Empty_Rows(box)
{   var li_count = box.options.length ;
	var li_offset= 0;
    var li_total = 0;
	for(var li_next  = 0; (li_next + li_offset) < (li_count); li_next++) 
	{ while(box.options[li_next + li_offset].value == "")
		{   li_offset++;
			if ((li_next + li_offset) >= li_count) break;
	    }
	  if ((li_next + li_offset) >= li_count) break;
	  box.options[li_total].value = box.options[li_next + li_offset].value;
	  box.options[li_total].text  = box.options[li_next + li_offset].text;
	  li_total++	  
	}	
	box.options.length = (li_count - li_offset);  
}	

/* This Function determines what a user typed in a text box
   and then moves all the entries in a source list box the 
   that match the patterns to the destination box. */
function f_MoverFastEntry(atxt_data, alb_FromBox, alb_ToBox, auo_next_focus)
{   
	var ls_data = atxt_data.value;

	if (ls_data.length > 0)
	{
		var ls_match = /(\b\w+\b)+/;
		var lobj_results = ls_match.exec(ls_data);
		
		while (lobj_results != null)		
		{	ls_data = ls_data.slice(lobj_results[0].length + 1);
 			var lreg_pattern = new RegExp(("^" + lobj_results[0]) ,"i");
 			for(var i=0; i<alb_FromBox.options.length; i++) 
 			{if(lreg_pattern.test(alb_FromBox.options[i].text))
 				{alb_FromBox.options[i].selected = true;}
  			}
			lobj_results = ls_match.exec(ls_data);
		}
	Activate_MoverBox(alb_FromBox,alb_ToBox);
	atxt_data.value = "";
	}
	if (auo_next_focus.toString() == "[object]") auo_next_focus.focus();
}

function f_SelectAll(alb_Selected)
{   for(var i=0; i<alb_Selected.options.length; i++) 
 	{ alb_Selected.options[i].selected = true;
 	}
}

function f_DeSelectAll(alb_Selected)
{   for(var i=0; i<alb_Selected.options.length; i++) 
 	{ alb_Selected.options[i].selected = false;
 	}
}

-->


