$(document).ready(function(){

	var disableAmount = function() {
		
		if($('#amount').val()!="")
		{
			$('#otherAmount').attr("disabled","disabled");
		}
		else
		{
			$('#otherAmount').removeAttr("disabled");
		}
	
		if($('#otherAmount').val()!="" && $('#otherAmount').val()!="0")
		{
			$('#amount').attr("disabled","disabled");
		}
		else
		{
			$('#amount').removeAttr("disabled");
		}
	}  

	var setText = function(strType, strWhere)
	{
		var strType = strType;
		var strWhere = strWhere;

		if(strType == 'ideal')
		{
			$("#donation-text").html('Ik wil graag het volgende bedrag overmaken');
			$("#accountnr").hide();

		}
		if(strType == 'machtiging')
		{
			$("#donation-text").html('Ik machtig Proefdiervrij om het eenmalig het volgende bedrag af te schrijven');
			$("#accountnr").show();
		}
	}
	
	$('#amount').change(function () {
		disableAmount();
	});
	
	$('#otherAmount').keypress(function()
			{
				$(this).numeric();

			});
	
	$('#otherAmount').keyup(function () {
		disableAmount();
	});
	
	if ($("input[name=paymenttype]:checked").val() == 'ideal') {
		setText("ideal");
    }
	else
	{
		setText("machtiging");
	}
	
	
	$("input[name=paymenttype]").click(
		function()
		{
			if ($("input[name=paymenttype]:checked").val()) {
	                var strType = $("input[name=paymenttype]:checked").val();
	                setText(strType, 'donation-text');
	            }
		}
	);

	
	disableAmount(); 

});
