$(document).ready(function() {
if ($("input[name^=qty_item_]")) {
			$("input[name^=qty_item_]").bind("keyup", recalc);
			recalc();}
      });

	  

	function recalc(){

		$("[id^=total_item]").calc(

			// the equation to use for the calculation
			"qty * price",
			// define the variables used in the equation, these can be a jQuery object
			{
				qty: $("input[name^=qty_item_]"),
				price: $("[id^=price_item_]"),
				oncalc:	$('#res'+ $(this).attr('id')).attr('value',$(this).val())
			},
			// define the formatting callback, the results of the calculation are passed to this function
			function (s){
				// return the number as a dollar amount
				return "$" + s.toFixed(2);
			},
			// define the finish callback, this runs after the calculation has been complete
			function ($this){
				// sum the total of the $("[id^=total_item]") selector
				var sum = $this.sum();

				$("#grandTotal").text(
					// round the results to 2 digits
					sum.toFixed(2)
				);
				$("#inputTotal").attr('value',
					// round the results to 2 digits
					 sum.toFixed(2)
				);

			}
		);
	}
