<script language="JavaScript" type="text/javascript" src="{JS_LOCATION}/core.js"></script>
<script language="JavaScript" type="text/javascript" src="{JS_LOCATION}/events.js"></script>
<script language="JavaScript" type="text/javascript" src="{JS_LOCATION}/css.js"></script>
<script language="JavaScript" type="text/javascript" src="{JS_LOCATION}/coordinates.js"></script>
<script language="JavaScript" type="text/javascript" src="{JS_LOCATION}/drag.js"></script>
<script language="JavaScript" type="text/javascript" src="{JS_LOCATION}/dragsort.js"></script>
<script language="JavaScript" type="text/javascript" src="{JS_LOCATION}/cookies.js"></script>

<script language="JavaScript" type="text/javascript">
<!--
	var dragsort = ToolMan.dragsort();
	var helpers = ToolMan.helpers();
	var initialorder = new Array();

	window.onload = function() {

		dragsort.makeListSortable(document.getElementById("orderlist"),
				verticalOnly);
		saveInitialOrder();
	}
	
	function saveInitialOrder()
	{
		var ul = document.getElementById("orderlist");
		var listelements = ul.getElementsByTagName("li");
		for (var i = 0; i < listelements.length; i++)
		{
			initialorder.push(listelements[i].id);
		}
	}
	
	function restoreInitialOrder()
	{
		for (var i = initialorder.length-1; i > 0; i--)
		{
			var list_a = document.getElementById(initialorder[i]);
			var list_b = document.getElementById(initialorder[i-1]);
			helpers.moveBefore(list_b, list_a);
		}
	}

	function verticalOnly(item) {
		item.toolManDragGroup.verticalOnly()
	}

	function saveOrder(listID) 
	{
		var list = document.getElementById(listID);
		var items = list.getElementsByTagName("li");
		var itemsString = "";
		for (var i = 0; i < items.length; i++) 
		{
			if (itemsString.length > 0) itemsString += ":";
			itemsString += items[i].id;
		}
		document.test_output.orderresult.value = itemsString;
	}

	//-->
</script>
