function getSortableOrderIds(elementId,hiddenId){
	var sortableListData = Sortable.serialize(elementId);		
	if($(hiddenId))	{
		$(hiddenId).value = sortableListData;					
	}
}

// check all form elements
function checkAll(form,tmatch) {
	for(i=0;i<form.length;i++){
		if(form.elements[i].name.match(tmatch)){
			form.elements[i].checked=true;
		}
	}
}
// uncheck all formelements
function uncheckAll(form,tmatch) {
	for(i=0;i<form.length;i++){
		if(form.elements[i].name.match(tmatch)){
			form.elements[i].checked=false;
		}
	}
}
// AJAX: send data to php script in background
// vars -> query string
// action -> action for switch in ajax.php
// message_container -> id of html element
function sendRequest(vars,action,message_container,strFunction){
	//URL = '/trinknahrungv2/ajax.php?ajax-action='+action+'&'+vars;
	URL = '/ajax.php?ajax-action='+action+'&'+vars;
	new Ajax.Request(
		URL,
		{
			method: 'post',
			//encoding: 'ISO-8859-1',			
			onLoading: function()
			{
				document.getElementById(message_container).innerHTML = '<img src="/images/ajax-loader.gif" alt="Wird geladen" align="right" />';				
			},									
			onSuccess: function(transport) 
			{
				if(document.getElementById(message_container))
				{
					document.getElementById(message_container).innerHTML = transport.responseText;
					if(strFunction)
					{
						eval(strFunction);
					}
				}
				else
				{
					alert(transport.responseText);
				}				
			},			
			onFailure: function(){ alert('Something went wrong...'); },
			onException: function(){ alert('Something went wrong...'); }
		}
	);
}


// fuegt artikel dem warenkorb hinzu
function addBasket(id)
{	
	sendRequest('id='+id,'add','order-'+id,'refreshBasket();');				
}
// entfernt artikel aus dem warenkorb
function removeBasket(id){	
	sendRequest('id='+id,'remove','basket','refreshBasket();');	
}
// laed warenkorb neu
function refreshBasket(){
	sendRequest('','refresh','basket');	
}



