
	function ItemInList(selList,sItem, sValueOrText)
	{
		var bMatch = false;    
		var iPositionOfFoundItem = -1;

		// Loop for each item
		for (var iCounter=0; iCounter < selList.options.length; iCounter++)
		{

			if (sValueOrText == "value")
			{
				if( selList.options[iCounter].value == sItem )
					bMatch = true;
			}
			else if (sValueOrText == "text")
			{
				//Used for selecting a Region in World Airfields
				if (sItem.length == 1 && selList.options[iCounter].text.substr(0,1) == sItem )
					bMatch = true;
				//Used for selecting a counrty in world Airfields
				else if (sItem.length == 2 && selList.options[iCounter].text.substr(0,2) == sItem )
					bMatch = true;
				//Used for selecting an airfield out of multiple List in World Airfields
				else if (sItem.length == 4 && selList.options[iCounter].text.substr(0,4) == sItem )
					bMatch = true;
				else if( selList.options[iCounter].text == sItem )
					bMatch = true;
			}

			if (bMatch == true)
			{
				iPositionOfFoundItem = iCounter;
				iCounter = selList.options.length;
			}
		}

		return iPositionOfFoundItem;
	}

	function getSelectedItems(selList, sValueOrText,  sDelimeter)
	{
		var sSelectedString;

		sSelectedString = "";

		// Loop for each item
		for (var iCounter=0; iCounter < selList.options.length; iCounter++)
		{

			if (sValueOrText == "value")
			{
				if( iCounter == 0)
				{
					sSelectedString = sSelectedString + selList.options[iCounter].value;
				}
				else
				{
					sSelectedString = sSelectedString + sDelimeter + selList.options[iCounter].value;
				}
			}
			else if (sValueOrText == "text")
			{
				if( iCounter == 0)
				{
					sSelectedString = sSelectedString + selList.options[iCounter].text;
				}
				else
				{
					sSelectedString = sSelectedString + sDelimeter + selList.options[iCounter].text;
				}
			}
		}

		return sSelectedString;
	}

	function RemoveSelectedItems(selList)
	{
		var iCounter = 0;

// Loop for each item
		while (iCounter < selList.options.length)
		{

// Item Selected?
			if (selList.options[iCounter].selected)
			{
				RemoveItem(selList,iCounter);
			}
			else
			{
					iCounter++;
            }

        }
	}

	function Clear(selList)
	{
		var iCounter = 0;

		// Loop for each item
		while (iCounter < selList.options.length)
		{
			RemoveItem(selList,iCounter);
        }
	}

	function RemoveItem(selList, iItemToRemove)
	{
		selList.options[iItemToRemove] = null;
	}

	function AddItem(selList,sName, sValue)
	{
		selList.options[selList.options.length] = new Option(sName,sValue);
	}

	function SwitchLists(selFromList,selToList)
	{
		var iCounter = 0;
    
		// Loop for each item
		while (iCounter < selFromList.options.length)
		{

			// Item Selected?
			if (selFromList.options[iCounter].selected)
			{
				AddItem(selToList,
					selFromList.options[iCounter].text,
					selFromList.options[iCounter].value);
				
				RemoveItem(selFromList,iCounter);

			}
			else
			{
					iCounter++;
            }
		}
	}

	function CopyLists(selFromList,selToList)
	{
		var iCounter = 0;
    
		// Loop for each item
		while (iCounter < selFromList.options.length)
		{
			AddItem(selToList,
				selFromList.options[iCounter].text,
				selFromList.options[iCounter].value);
		
			iCounter++; 
		}
		
		//Selected the selected one
		selToList.selectedIndex = selFromList.selectedIndex;
	}
	
	function MoveItemUp(selList)
	{
		var iIndex = selList.selectedIndex;
		var iAbove = -1;
		var iBelow = -1;
		
		if ( iIndex == -1)		
			alert("Please select an item");
		else if ( iIndex == 0)
			alert("Item already at the top of the list");
		else
		{
		
			// Allow the item to be moved
            iAbove = new Option(selList.options[iIndex].text,selList.options[iIndex].value);
            iAbove.id = selList.options[iIndex].id;
            iBelow = new Option(selList.options[iIndex-1].text,selList.options[iIndex-1].value);
            iBelow.id = selList.options[iIndex-1].id;
            selList.options[iIndex] = iBelow;
            selList.options[iIndex-1] = iAbove;
            selList.selectedIndex = iIndex - 1;
        }
		
	}
	
	function MoveItemDown(selList)
	{
		var iIndex = selList.selectedIndex;
		var iListLength = selList.length;
		
		var iAbove = -1;
		var iBelow = -1;
		
		if ( iIndex == -1)		
			alert("Please select an item");
		else if ( iIndex + 1 == iListLength)
			alert("Item already at the bottom of the list");
		else
		{
			// Allow the item to be moved
            iBelow = new Option(selList.options[iIndex+1].text,selList.options[iIndex+1].value);
            iBelow.id = selList.options[iIndex+1].id;
            iAbove = new Option(selList.options[iIndex].text,selList.options[iIndex].value);
            iAbove.id = selList.options[iIndex].id;
            selList.options[iIndex] = iBelow;
            selList.options[iIndex+1] = iAbove;
            selList.selectedIndex = iIndex + 1;
        }			
	}
	
	function MoveItemTop(selList)
	{
		var iIndex = selList.selectedIndex;
		
		var iAbove = -1;
		var iBelow = -1;
		
		if ( iIndex == -1)		
			alert("Please select an item");
		else if ( iIndex  == 0)
			alert("Item already at the top of the list");
		else
		{
		
			// Allow the item to be moved
            iBelow = new Option(selList.options[0].text,selList.options[0].value);
            iBelow.id = selList.options[0].id;
            iAbove = new Option(selList.options[iIndex].text,selList.options[iIndex].value);
            iAbove.id = selList.options[iIndex].id;
            selList.options[iIndex] = iBelow;
            selList.options[0] = iAbove;
            selList.selectedIndex = 0;
        }			
	}	
	
	function MoveItemBottom(selList)
	{
		var iIndex = selList.selectedIndex;
		var iListLength = selList.length;
		
		var iAbove = -1;
		var iBelow = -1;
		
		if ( iIndex == -1)		
			alert("Please select an item");
		else if ( iIndex + 1 == iListLength)
			alert("Item already at the bottom of the list");
		else
		{
		
// Allow the item to be moved
            iBelow = new Option(selList.options[iListLength -1].text,selList.options[iListLength-1].value);
            iBelow.id = selList.options[iListLength-1].id;
            iAbove = new Option(selList.options[iIndex].text,selList.options[iIndex].value);
            iAbove.id = selList.options[iIndex].id;
            selList.options[iIndex] = iBelow;
            selList.options[iListLength-1] = iAbove;
            selList.selectedIndex = iListLength-1;
        }			
	}		

	function SelectAll(frmName,selID,bSelectAll)
	{
		/*
			Function allows you select all check boxes
			Just pass in the form name and the name of 
			the checkbox, oh and if you want to select
			or deselect the babies
		*/
		
		var iCounter = 0;
		
		// Loop for each item
		while (iCounter < frmName.length)
		{
			e=frmName.elements[iCounter];
			
			if(e.type=='checkbox' && e.name.indexOf(selID) != -1)
				e.checked = bSelectAll;
				
			iCounter++;
		}
	} 
