		function toCurrency(num) {
	  num = Math.floor(num * 100 + 0.50000000001);
	  cents = num % 100;
	  num = Math.floor(num / 100).toString();
	  if (cents < 10) cents = '0' + cents;

	  for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) {
	    num = num.substring(0, num.length - (4 * i + 3)) + '.' + num.substring(num.length - (4 * i + 3))
	  }

	  return num + ',' + cents;
	}

			function calculate() {

				$.ajax({
					type: "POST",
					url: "index.php?c=ajax_rechner",
					data: 
						"amount=" + $("#input_amount").val() +
						"&duration=" + $("#input_duration").val(),
					success:
						function(response) {
							
							var json = jQuery.parseJSON(response); 
//							if(json.state==200) {
								$('#price').html(json.werte.rate);
								$('#effectiveInterest').html(json.werte.effektivZins);
								$('#nominalInterest').html(json.werte.nominalZins);
								$('#rateInfo').html(json.werte.rateInfo);
//							}
						}
				});
			}

