/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


$(document).ready(function(){


	var params = {
		totalPriceWithoutIva :parseFloat(mySumNetto),
		totalPrice :parseFloat(mySum)
		}
	$.post(
		'ajax/shop/computeMissingSum.php',
		params,
		function(data){
			try{
				$("#free_shipping").html( data.message);
			}catch(e){
			}
		}, "json"
		);

});
function removeItem(itemID,msg){
	var answer = confirm(msg);
	if (answer){
		document.getElementById('ck_'+itemID).value = itemID;
		document.forms[0].submit();
	}
}

function checkField(id){
	wzorzec = /[^1-9\.]/;
	form = document.getElementById('fcart');
	if(id.value.search(wzorzec)!=-1 || id.value==''){
		alert("quenatity_error");
		id.value = 1;
		form.submit();
	} else {
		form.submit();
	}
}

function checkout(msg) {
	if( (parseFloat($('#subtotal').val()) >= 0.0) && ($('input[name=delivery]:checked').val() > 0) ) {
		$('#delivery_form').submit();
	}
	else {
		alert(msg);
	}
}

function updateDelivePrice(price){
	if(parseFloat($('#subtotal').val()) < 360.0 && parseFloat($('#isDownload').val())!=1){

		$('#priceDelivery').html(price)
		var total = (parseFloat($('#subtotal').val())+parseFloat(price));
		$('#Totalprice').html(total.toFixed(2))
	}
	else{
		$('#priceDelivery').html('0.0')
		var total = parseFloat($('#subtotal').val());
		$('#Totalprice').html(total.toFixed(2))
	}
}
