
$(document).ready(
	function (){
		/*$.ajax({
	        url: 'http://violeng.demo1/index.php?id=25&method=list&state=4&tstamp=1287322397&hash=3bc0d63f64794fcdbb197de0f5c9073b',
	        type: 'PUT',
	        data: 'val1=10&val2=20', // or $('#myform').serializeArray()
	        success: function(data) { alert(data);var result = JSON2.parse(data); alert(result); }
	});*/

		recalc();
		 // bind the recalc function to the quantity fields
		$("select[name^=tx_wekeytags_pi1[quantity]]").bind("change", recalc);
		$("select[name^=tx_wekeytags_pi1[price]]").bind("change", recalc);
		 // run the calculation function now
		//recalc();
		//alert('called');
	}
);

function recalc(){
	//alert($("select[name^=tx_wekeytags_pi1[quantity]]").val());
	var qty = $("select[name^=tx_wekeytags_pi1[quantity]]").val();
	var price = $("select[name^=tx_wekeytags_pi1[price]]").val();
	var total = qty * price;
	total = "Fr. " + total + ".-";
	$("[id^=total_price]").html(total);
}

/*function recalc(){
	$("[id^=total_price]").calc(
	// the equation to use for the calculation
	"qty * price",
	// define the variables used in the equation, these can be a jQuery object
	{
		qty: $("select[name^=tx_wekeytags_pi1[quantity]]"),
		price: $("select[name^=tx_wekeytags_pi1[price]]")
	},
	// define the formatting callback, the results of the calculation are passed to this function
	function (s){
		// return the number as a CHF amount
		return "Fr. " + s.toFixed(0) + ".-";
	},
	// 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();
	
	}
	);
} */
