$(document).ready(function() {
		var sk_key = document.getElementById("sk_key").innerText;
		//alert(sk_key);
		var handler = StripeCheckout.configure({
		  key: sk_key,
		  image: 'images/logo.PNG',
		  token: function(token) {
			$("#stripeToken").val(token.id);
			$("#stripeEmail").val(token.email);
			$("#total").val();
			$("#payment-form").submit();
		  }
		});

		$('#customButton').on('click', function(e) {
			e.preventDefault();
			var name = $("#name").val();
			var phone = $("#phone").val();
			var email = $("#email").val();
			var email = $("#email").val();
			var state = $("#state").val();
			var city = $("#city").val();
			var code = $("#code").val();
			var message = $("#message").val();
			if(name != '' && phone != '' && email != '' && state != '' && city != '' && code != '' && message != ''){
				$("#name").css('border','1px solid #e4e4e4');
				$("#phone").css('border','1px solid #e4e4e4');
				$("#email").css('border','1px solid #e4e4e4');
				$("#state").css('border','1px solid #e4e4e4');
				$("#city").css('border','1px solid #e4e4e4');
				$("#code").css('border','1px solid #e4e4e4');
				$("#message").css('border','1px solid #e4e4e4');
				var candidate = $("#total").val() * 100;
				handler.open({
					name: 'Candy Cleanse',
					amount: candidate,
				});
			}else{
				if(name == ''){
					$("#name").css('border','1px solid red');
					$("#name").focus();
				}else{
					$("#name").css('border','1px solid #e4e4e4');
				}
				if(phone == ''){
					$("#phone").css('border','1px solid red');
					$("#phone").focus();
				}else{
					$("#phone").css('border','1px solid #e4e4e4');
				}
				if(email == ''){
					$("#email").css('border','1px solid red');
					$("#email").focus();
				}
				if(state == ''){
					$("#state").css('border','1px solid red');
					$("#state").focus();
				}
				if(city == ''){
					$("#city").css('border','1px solid red');
					$("#city").focus();
				}
				if(code == ''){
					$("#code").css('border','1px solid red');
					$("#code").focus();
				}
				if(message == ''){
					$("#message").css('border','1px solid red');
					$("#message").focus();
				}else{
					$("#email").css('border','1px solid #e4e4e4');
					//$("#state").focus();
				}
			}
		});

		// Close Checkout on page navigation
		$(window).on('popstate', function() {
		  handler.close();
		});
		});