function kaufen(id)
{
	var el = $('produkt_'+id);
	if(!el.getElement('.txtanzahl').get('value'))
	{
		el.getElement('.txtanzahl').set('value',1);
	}

	var json = new Request.JSON({url:'index.php',method:'post',onComplete: function(obj){
		updateWk(obj);
	}}).get({'shopAjax':'add','produkt':id,'anzahl':el.getElement('.txtanzahl').get('value')});
	
	
}

function refreshWk()
{
	var hash = new Hash();
	$$('.produktanzahl').each(function(el,i){ 
		hash.set(el.get('id'),el.get('value'));
	});
	var json = new Request.JSON({url:'index.php',method:'post',onComplete: function(obj){
		top.location.reload();
		
	}}).get({'shopAjax':'updatewk',produkte:hash.toQueryString()});
}

function updateWk(obj)
{
	$('warenkorb').getElement('.anzahl').set('html',obj.artikel_total);
	$('warenkorb').getElement('.preis').set('html',obj.preis_ges + " CHF");
	$('warenkorb').getElement('ul').empty();
	obj.produkte.each(function(el,i){
		var li = new Element('li');
		var div = new Element('div');
		div.set('html',el.anzahl + " x "+ el.titel);
		li.appendChild(div);
		$('warenkorb').getElement('ul').appendChild(li);
	});
}

