$(document).ready(function() {
	
	$("input[name='clientType']").click(
		function () {
			clientType = $(this).val();
			if (clientType == 1) {
				$('#details-pj').hide('fast');
				$('#details-pf').show('fast');
			} else {
				$('#details-pf').hide('fast');
				$('#details-pj').show('fast');
			}
		}								   
	);
	
	$("#invDelivInvAddressSame").click(
		function () {
			deliveryT = $(this).is(':checked');
			if (deliveryT) {
				$('#deliveryData').hide('fast');
			} else {
				$('#deliveryData').show('fast');
			}
		}								   
	);
	
	$("#new_delivery_address_radio").click(
		function () {
			$('#delivery_address_fields').show('fast');
		}								   
	);
	
});

	
function recalculate_insertcart_total()
	{
	total = 0;
	totalWeight = 0;

	if ($('#qty').val()>0)
		{
		quantity=$('#qty').val();
		price=$('#unit_price').val();
		weight=1;
		totalWeight += quantity*weight;
		total += quantity*price;
		}
	else
		$('.variants_line').each(function (i){
			//alert($(this).contents().find('.variant_price').val());
			is_selected=$(this).contents().find('.variant_checkbox').is(':checked');
			quantity=$(this).contents().find('.regSelect').val();
			price=$(this).contents().find('.variant_price').val();
			weight=$(this).contents().find('.variant_weight').val();
			totalWeight += quantity*weight;
			total += quantity*price;
		});
	//alert(price);

	//foreachvariant: total += (checked)*quantity*price
	$('#addCartWeight').html(totalWeight.toFixed(2));
	$('#addCartPrice').html(total.toFixed(2));
	}