function pretty_money(money) {
	txt = money.toFixed(2);
	if (txt.substr(txt.length-3) == '.00') txt = txt.substr(0, txt.length-3);
	else txt = txt.replace('.', ',');
	return txt + '&nbsp;zł';
}

function update_cost(pobranie) {
	// pobranie: shipment => czy pobranie legalne

	shipment_raw = radio_value(document.basket.shipment);
	payment_raw = radio_value(document.basket.payment);
	shipment = parseInt(shipment_raw);
	payment = parseInt(payment_raw);

	if (document.basket.payment[0]) {
		if (shipment_raw!='' && !pobranie[shipment]) {
			document.basket.payment[0].checked = false;
			document.basket.payment[0].disabled = true;
			payment_raw='';
		}
		else document.basket.payment[0].disabled = false;
	
		if (shipment_raw=='' || payment_raw=='') {
			document.getElementById('add_cost').innerHTML = '';
			document.getElementById('total').innerHTML = '';
			return;
		}
	}

	weight = parseFloat(document.basket.weight.value);
	
	cost = add_cost[10*shipment+payment];
	
	price = parseFloat(document.basket.price.value);
	
	document.getElementById('add_cost').innerHTML = pretty_money(cost);
	document.getElementById('total').innerHTML = pretty_money(cost+price);
}


function check_basket() {
	// sprawdza, czy formularz w koszyku prawidłowo wypełniony
	good = true;
	if (!check_radio(document.basket.shipment, 'err_shipment', 'Proszę wybrać sposób dostawy.'))
		good = false;
	if (!check_radio(document.basket.payment, 'err_payment', 'Proszę wybrać formę płatności.'))
		good = false;
	return good;
}


