//  Function to process/submit the form
//  This function will create a comma-delimited list of all of the items
//  in the select box to be passed on to the action page.  The value passed
//  will be the id of the value.
function ProcessForm()
{
	document.SelectMenu.Id_List.value = "";
	for (i = 0; i <= (document.SelectMenu.SortList.length - 1); i++)
	{
		if (i != 0)
		{
			document.SelectMenu.Id_List.value += ",";
		};
		document.SelectMenu.Id_List.value += document.SelectMenu.SortList[i].value;
	}
	document.SelectMenu.submit();
}

//  Create an array to hold info to change sequence
//  This type of function is called a Constructor Function
function sequencehold(Value, Text)
{
	this.Value = Value;
	this.Text = Text;
}

//  Move the selected value higher in sequence
//  This function will take the selected item and move it one record higher.
function MoveUp(Position)
{
	var Position
	Position = document.SelectMenu.SortList.selectedIndex;
	if (Position != 0)
	{
		var HoldingPlace
		HoldingPlace = new Array(2);
		var SequenceNumber, PreviousFolder;
		PreviousFolder = Position - 1;
		HoldingPlace[0] = new sequencehold(document.SelectMenu.SortList[PreviousFolder].value, document.SelectMenu.SortList[PreviousFolder].text);
		HoldingPlace[1] = new sequencehold(document.SelectMenu.SortList[Position].value, document.SelectMenu.SortList[Position].text);
		document.SelectMenu.SortList[PreviousFolder].value = HoldingPlace[1].Value;
		document.SelectMenu.SortList[PreviousFolder].text = HoldingPlace[1].Text;
		document.SelectMenu.SortList[Position].value = HoldingPlace[0].Value;
		document.SelectMenu.SortList[Position].text = HoldingPlace[0].Text;
		document.SelectMenu.SortList.selectedIndex = PreviousFolder;
	}
}

//  Move the selected value lower in sequence
function MoveDown(Position)
{
	var Position;
	var SelectLength;
	var LastPosition;
	SelectLength = document.SelectMenu.SortList.length;
	LastPosition = SelectLength - 1;
	Position = document.SelectMenu.SortList.selectedIndex;
	if (Position != LastPosition)
	{
		HoldingPlace = new Array(2);
		var SequenceNumber, NextFolder;
		NextFolder = Position + 1;
		HoldingPlace[0] = new sequencehold(document.SelectMenu.SortList[NextFolder].value, document.SelectMenu.SortList[NextFolder].text);
		HoldingPlace[1] = new sequencehold(document.SelectMenu.SortList[Position].value, document.SelectMenu.SortList[Position].text);
		document.SelectMenu.SortList[NextFolder].value = HoldingPlace[1].Value;
		document.SelectMenu.SortList[NextFolder].text = HoldingPlace[1].Text;
		document.SelectMenu.SortList[Position].value = HoldingPlace[0].Value;
		document.SelectMenu.SortList[Position].text = HoldingPlace[0].Text;
		document.SelectMenu.SortList.selectedIndex = NextFolder;
	}
}
