$(function(){
	$('input#price').keyup(function() { 
		var P,C,T, dec;	
		P = parseInt($("#price").val());
		C = parseFloat((P/100)*5);
		var resC = Math.round(C*100)/100;
		T = parseFloat(P+resC);
		
		if(!isNaN(resC) && !isNaN(T)) {
			$("#commission").val(resC);
			$("#totalPrice").val(T);
			$("span.error").html(""); 
		} else {
			$("#commission").val();
			$("#totalPrice").val();
			$("span.error").html("Vul een getal in"); 
		}
		return false;
	});
	
	$('input#totalPrice').keyup(function() { 
		var P,C,T, dec;	
		P = parseInt($("#totalPrice").val());
		C = parseFloat((P/105)*100);
		var resC = Math.round(C*100)/100;
		T = parseFloat(P-resC);
		
		if(!isNaN(resC) && !isNaN(T)) {
			$("#commission").val(T);
			$("#price").val(resC);
			$("span.error").html(""); 
		} else {
			$("#commission").val();
			$("#price").val();
			$("span.error").html("Vul een getal in"); 
		}
		return false;
	});
	
	
});
