
window.addEvent('domready', function() 
{
	var thisSortables = new Sortables($('navigation'), 
	{
		constrain: true,
		clone: true,
		revert: true,
		onStart: function() 
		{
			$('confirm').set('html', '<img src="gfx/loading.gif" width="32" height="32" />');
		},
		onComplete: function() 
		{
			this.serialize(function(el, index) 
			{
			  	var updateOrderRequest = new Request.HTML({
				url: 'sortlist.php',
				method: 'post',
				data: {'itemID': el.id.replace("item_",""), 'option': 'navigation', 'new_pos':(index++)}
				}).send();
			});
			$('confirm').set('html', '');
			//updateNavigation();
		}
	});
});




function makesortable(s,element) 
{
	var sortStructure = s;
	//delete thisSortables;
	document.getElementById(element).style.cursor = "move";
	var thisSortables = new Sortables($(sortStructure), 
	{
		
		
		constrain: false,
		clone: false,
		revert: true,
		onStart: function() 
		{
			$('confirm').set('html', '<img src="gfx/loading.gif" width="32" height="32" />');
		},
		
		onComplete: function() 
		{
			this.serialize(function(el, index) 
			{
				var thisID = el.id.split("_");
				var updateOrderRequest = new Request.HTML({
				url: 'sortlist.php',
				method: 'post',
				data: {'itemID': thisID[1], 'option': 'sitestructure', 'new_pos':(index++)}
				}).send();
			});
			$('confirm').set('html', '');
			setTimeout("location.reload(true);",50);
		}

	});
	
	
		
}

