function recalc_cos(skip_auto_correct_value) {
	$('.text_cantitate')
	.each(function() {
		good_value = this.value;
		good_value = parseInt(good_value);
		if (isNaN(good_value)) good_value = 0;
		if (good_value < 0) good_value = -good_value;
		if (good_value > 1000) good_value = 1000;
		
		pret = parseFloat($(this).attr('pret_unitar')) * good_value;
		pret = Math.round(pret * 100) / 100;
		
		$('#valoare_total_pt_' + $(this).attr('produs_id'))
		.html(pret);
		
		if (!skip_auto_correct_value) {
			this.value = good_value;
		}
	})
	
	t = 0;
	
	$('.valoare_total_pt_produs')
	.each(function() {
		tt = parseFloat($(this).html());
		if (!isNaN(tt)) t += tt;
	})
	
	discount_prag = 0;
	discount_valoare = 0;
	
	//discount
	for (i = 0; i < discount_values.length; i++) {
		if (t >= discount_values[i][0] / valuta_rata_schimb) {
			discount_prag = discount_values[i][0];
			discount_valoare = discount_values[i][1];
		}
	}
	
	
	if (discount_valoare > 0) {
		$('#div_magazin_discount').show();
		
		$('#span_magazin_total_before_discount').html(Math.round(t * 100) / 100);
		$('#span_magazin_discount_suma').html(Math.round(100 * discount_prag / valuta_rata_schimb) / 100);
		$('#span_magazin_discount_procent').html(discount_valoare);
		$('#span_magazin_discount_minus').html(Math.round(t * discount_valoare) / 100);
		
		t -= t * discount_valoare / 100;
	} else {
		$('#div_magazin_discount').hide();
	}
	
	//donatia
	tt = Math.abs(parseFloat($('#donatie_valoare').val()));
	if (!isNaN(tt)) t += tt;
	
	$('#total_magazin_cos')
	.html(Math.round(t * 100) / 100);
}
function pop_open(what, width, height) {
	if (!width) width = 320;
	if (!height) height = 240;
	tmpwin = window.open(root_address + 'pop.' + what, 'pop' + what.replace(/[^a-z0-9]/ig, ''), 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1,top=50,left=150,width=' + width + ',height=' + height);
	
	if (tmpwin) {
		tmpwin.focus();
	} else {
		nexthref = root_address + 'pop.' + what;
		legator = '?';
		if (nexthref.match(/\?/)) legator = '&';
		document.location.href = nexthref + legator + 'popup_blocker=override';
	}
	
	return false;
}

