/*var payPalItemCount = 0;
$(document).ready(function() {
	$(".paypalItem").click(function() {
	
			var checkboxState = $(this).attr("checked");
			if(checkboxState == true)
				payPalItemCount++;
			var itemPrice = parseFloat($(this).val());
			var currentTotalPrice = parseFloat($("#totalPrice span").text());
			var itemId = $(this).attr("id");
			if(checkboxState == true)
				var newTotalPrice = parseFloat(currentTotalPrice + itemPrice).toFixed(2);
			if(checkboxState != true)
				var newTotalPrice = parseFloat(currentTotalPrice - itemPrice).toFixed(2);
			var newItemName = $("label[id='"+itemId+"']").text();
			var newItemPrice = parseFloat(itemPrice).toFixed(2);
			$("#totalPrice span").text(newTotalPrice);

			if(checkboxState == true) {
				$("#payPalPaymentForm").prepend("<input type=\"hidden\" name=\"item_name_"+payPalItemCount+"\" value=\""+newItemName+"\">");
				$("#payPalPaymentForm").prepend("<input type=\"hidden\" name=\"amount_"+payPalItemCount+"\" value=\""+newItemPrice+"\">")
			}

			if(checkboxState != true) {
				$("input[name='item_name_"+payPalItemCount+"']").remove();
				$("input[name='amount_"+payPalItemCount+"']").remove();
			}

			if(checkboxState != true)
				payPalItemCount--;

		});
});*/

$(document).ready(function() {
	$(".paypalItem").click(function() {
		
		var _total = 0;
		var _currVal = 0;
		var _itemIndex = 0;
		var _itemName = '';
		var _itemId = '';
		
		$("#payPalPaymentForm .shopItem").remove();
		
		$(".paypalItem:checked").each(function(){
			
			_itemIndex++;
			
			_currVal = parseFloat($(this).val());
			_total += _currVal;
			_itemId = $(this).attr('id');
			$('label[for="' + _itemId + '"]').each(function(){ _itemName = $(this).html(); });
			
			$("#payPalPaymentForm").prepend("<input class=\"shopItem\" type=\"hidden\" name=\"item_name_"+_itemIndex+"\" value=\""+_itemName+"\">");
			$("#payPalPaymentForm").prepend("<input class=\"shopItem\" type=\"hidden\" name=\"amount_"+_itemIndex+"\" value=\""+_currVal+"\">")
			
		});
		
		$("#totalPrice").html('Total Price: <strong>&pound;'+_total+'</strong>');
					
	});
});