var doc = document, win = window, price, quantity = 0, total = 0, value, p_total;
jQuery(doc).ready(function(){
	jQuery('.quantity').keyup(function(){
		$input = jQuery(this);
		$current_tr = $input.parent().parent('tr');
		
		var price = $input.parents('tr').find('.price').text();
		price = parseFloat(price.replace(',','.'));
		
		
		p_total = ((price)*$input.val()).toFixed(2);
		$current_tr.children('td.product_total').html(p_total + ' €');
		
		quantity = 0; total = 0;
		
		jQuery('.quantity').each(function(index, element) {
			$this = jQuery(element);
			value = parseInt($this.val());
			quantity += (!isNaN(value)?value:0);
			
			var price = $this.parents('tr').find('.price').text();
			price = parseFloat(price.replace(',','.'));
			

			p_total = ((price)*$this.val());
			
			if(!isNaN(value)) {
				total += parseFloat(p_total);
			};
		});
		jQuery('#price_total').html(total.toFixed(2));
	});
});

function checkOrder() {
	if(quantity<1) { alert('Mindestbestellmenge noch nicht erreicht.'); return false; };
};
