$(document).ready(function() {
	$('.select_all').click(function() {
		
		var box = $(this).attr('value');
		
		if ($(this).attr('checked') == '') {
			$('input[class=boxes'+box+']').removeAttr('checked');
		} else {
			$('input[class=boxes'+box+']').attr('checked', 'checked');
		}
		
		CountNumber(box);
					  
	});
	
	$('input[class=boxesA]').click(function() {
		CountNumber('A');
	});
	$('input[class=boxesB]').click(function() {
		CountNumber('B');
	});
	$('input[class=boxesC]').click(function() {
		CountNumber('C');
	});
	
});



function CountNumber(box) {
	
	var total = 0;
	
	$('input[class=boxes'+box+']').each(function() {
		//alert(parseFloat($(this).val()));
		var id = $(this).attr('id');
		
		if ($(this).is(':checked')) {
			total += parseFloat($('.' + id).html());
		}
	});
	
	$('#totalblok' + box).html(total);
	$('#total' + box).val(total);

}
