$(document).ready(function () {
	$("#deposit_btn").click(function (event) {
		event.preventDefault();

		$("#errorPrompt").hide();
		$("#errorPrompt").html("");

		$("#deposit_btn").attr("disabled", "");

		$(".button_spinner").show();

		$("#payment_method").prop("disabled", true);

		var form_data =
			"payment_method=" + $("#payment_method option:selected").val();

		$.ajax({
			url: "../helpers/trade",
			type: "POST",
			data: form_data,
		}).done(function (response) {
			$(".button_spinner").hide();

			if (response == "success") {
				window.location.href = "process-deposit";
			} else {
				$("#payment_method").prop("disabled", false);
				$("#deposit_btn").removeAttr("disabled");
				$("#errorPrompt").show();
				$("#errorPrompt").html(response);
			}
		});

		return false;
	});
});
