$(function() {
	calculatePrice($('div.shippingMethod input[type=radio]:checked'));
	
	if ($.browser.msie) {
		$('div.shippingMethod input[type=radio]').click(function() {
			this.blur();
			this.focus();
		});
	}
	
	$('div.shippingMethod input[type=radio]').change(function() {
		calculatePrice($(this));
	});
});

function calculatePrice($selectedRadio) {
	var label = $('label[for=' + $selectedRadio.attr('id') + ']').text();

	var shipping = 0;
	var regex = new RegExp('.*?\\((\\d+)\\s+.*',['i']);
	var matches = regex.exec(label);
	if(matches) {
		shipping = parseInt(matches[1]);
	}

	var totalSum = parseInt($('span#totalSum').text());

	$('span.totalSumShipping').text(totalSum+shipping + ',- Kč');
}
