function createNewSection(name) {
	var name = $F('sectionName');
	if (name != '') {
		var newDiv = Builder.node('div', {id: 'listdecor' + (sections.length + 1), className: 'section', style: 'display:none;' }, [
			Builder.node('span', {className: 'regroupement'}, name)
		]);

		sections.push(newDiv.id);
		$('page').appendChild(newDiv);
		Effect.Appear(newDiv.id);
		destroyLineItemSortables();
		createLineItemSortables();
	}
}

function createLineItemSortables() {
	for(var i = 0; i < sections.length; i++) {
		Sortable.create(sections[i],{tag:'a',overlap:'horizontal',containment: sections,constraint:false});
	}
}

function destroyLineItemSortables() {
	for(var i = 0; i < sections.length; i++) { Sortable.destroy(sections[i]); }
}

function createGroupSortable() { Sortable.create('page',{tag:'div',handle:'regroupement'}); }

function getGroupOrder() {
	var sections = document.getElementsByClassName('section');
	//alert(sections);
	var alerttext = '';
	sections.each(function(section) {
		var sectionID = section.id;
		//alert(sectionID);
		var order = Sortable.serialize(sectionID);
		//alert(order);
		alerttext += sectionID + '=' + Sortable.sequence(section) + '&';
	});
	//alert(alerttext);
	return alerttext;
}
			
function sendDecorOrder(url, action2)
{
	var ordre = getGroupOrder() ;
	var action = "action="+action2 ;
	parameters2 = action + "&" + ordre;
	
	var options = { method: 'post', postBody: parameters2, onSuccess: function (xhr){alert("Ordre sauvegardé") ; }  } ;
	var myAjax = new Ajax.Request(url, options);
	
	return false; 
}			