<!--
// Function HitAll
//
// Copies selected items from 1 select element to another
//
// IN: [lbFrom]			- Name of select element to move items from
//	   [lbTo]			- Name of select element to move items to
//	   [bCheckExisting]	- True if item should be copied if it doesn't exist in the destination,
//						- False to just remove the item.
//	   [iMode]			- Operation mode.
//						- 0 Basic mode.  The undelying value of the destination box contains just the source boxes value.
//						- 1 Advanced mode. The undelying value of the destination box 
//						-   contains a comma separated list containing the source list box value, the specified text and the source description  i.e 1,Europe,UK
//		[sText]			- Text to add to destination boxes value (only used with mode 1)
//
function HitAll(lbFrom,lbTo,bCheckExisting,iMode,sText)
{
	var jLoop;
	var NewOption;
	var sValue;
	
	for (jloop = lbFrom.length-1; jloop != -1 ; jloop--){
		// Check mode to see what values should be saved
		if (iMode==1){
			sValue = lbFrom[jloop].value + "," + sText + "," + lbFrom[jloop].text 
		} else {
			sValue = lbFrom[jloop].value
		}	
		if (!IsItemInBox(lbTo, sValue) && bCheckExisting) {
			NewOption = new Option(lbFrom[jloop].text, sValue);
			lbTo[lbTo.length] = NewOption;
			lbFrom[jloop] = null;	// Remove option from box
		}
		else{
			if (!bCheckExisting){
				lbFrom[jloop] = null;	// Remove option from box
				jloop--
			}
		}
	}                       
}

// Function HitMe
//
// Copies selected items from 1 select element to another
//
// IN: [lbFrom]			- Name of select element to move items from
//	   [lbTo]			- Name of select element to move items to
//	   [bCheckExisting]	- True if item should be copied only if it doesn't exist in the destination box,
//						- False to just remove the item.
//	   [iMode]			- Operation mode.
//						- 0 Basic mode.  The undelying value of the destination box contains just the source boxes value.
//						- 1 Advanced mode. The undelying value of the destination box 
//						-   contains a comma separated list containing the source list box value, the specified text and the source description  i.e 1,Europe,UK
//		[sText]			- Text to add to destination boxes value (only used with mode 1)
function HitMe(lbFrom,lbTo,bCheckExisting,iMode,sText) 
{
	var jLoop;
	var NewOption;
	var sValue;

	for (jloop = 0; jloop < lbFrom.length; jloop++){
		if (lbFrom[jloop].selected)	{
			// Check mode to see what values should be saved
			if (iMode==1){
				sValue = lbFrom[jloop].value + "," + sText + "," + lbFrom[jloop].text 
			}
			else{
				sValue = lbFrom[jloop].value
			}
			if (!IsItemInBox(lbTo, sValue) && bCheckExisting) {
				NewOption = new Option(lbFrom[jloop].text, sValue);
				lbTo[lbTo.length] = NewOption;
				lbFrom[jloop] = null;	// Remove option from box
			} else {
				if (!bCheckExisting){
					lbFrom[jloop] = null;	// Remove option from box
				}
			}
		}
	}                       
}

// Function IsItemInBox
//
// Checks if an item is in a listbox using the value property
//
// Author: Dan Gibbons
// Created: 04/07/01
//
// IN: [lbName]		- Name of select element to check
//	   [CheckValue]	- Value to search for
//
// Returns: True if value found in list box, false otherwise
//
function IsItemInBox(lbName,CheckValue)
{
	var iloop;

	iloop = lbName.length;

	for (iloop = 0; iloop < lbName.length; iloop++) {
		if (lbName[iloop].value == CheckValue) 
		{
			return true;
		}
	}
	return false;                       
}
//-->
