$(document).ready(function() {
	$('input#ctl00_Content_akkoord').click(function () {
		if ($('input#ctl00_Content_akkoord').attr('checked')) {
			$("#btnbetaal").removeAttr("disabled");
		} else {
			$("#btnbetaal").attr("disabled","disabled");
		};
	});
	
	$('#big_winkelwagen input').change(function () {
		if (!(isNaN(this.value))) {
			var sArtikelId = new String(this.id).replace('total[','').replace('_0]','');
			var nArtikelAmount = new Number(this.value);
			var nArtikelPrice = new Number($("#pPrice_" + sArtikelId + "_0").html().replace('&euro ','').replace('\u20ac ','').replace(',','.'));
			var sArtikelSubPrice = new String(Math.round(nArtikelAmount * nArtikelPrice * 100));
			$.getJSON("/webshop/json.aspx", { id: sArtikelId, amount: nArtikelAmount}, function(json){
				$("#subTotal").html(json.subtotal);
				$("#korting").html(json.korting);
				$("#sendCosts").html(json.shippingprice);
				$("#toPay").html(json.total);
				$("#btw").html(json.btw);
				$("#pTPrice_" + sArtikelId + "_0").html('&euro; ' + sArtikelSubPrice.substring(0, sArtikelSubPrice.length-2) + ',' + sArtikelSubPrice.substring(sArtikelSubPrice.length-2));
			});
		};
 	});
	
	$('#frmBestellen #pay').change(function () {

		$("#frmBestellen #pay option:selected").each(function () {
				var nPay = new Number(this.value);
				$.getJSON("/webshop/json.aspx", { a: 'changePayment', pay: nPay}, function(json){
					$("#subTotal").html(json.subtotal);
					$("#korting").html(json.korting);
					$("#sendCosts").html(json.shippingprice);
					$("#toPay").html(json.total);
					$("#btw").html(json.btw);
				});
              });
 	});
	
	$('ul.products li').fitted();
	$('ul.news li.newsitem').fitted();
});

