<style type="text/css">
	.input_sub {
		width:38%; display:inline-block; margin-right:1%;
	}
	.input_subb {
		width:20%; display:inline-block;
	}	
	/** USE THESE TO OVER-RIDE THE SUBSCRIBE BUTTON COLOR. **/
	input#subscribe.btn-black {
		/*background:rgba(0,0,0,.3);*/
		/*background:rgba(0,186,73,.3) !important;*/
		/*background: rgba(40,176,255,1) !important;*/
		height: 59px !important;
	}
	input#subscribe.btn-black:hover {
		/*background:rgba(0,0,0,.3);*/
		/*background: rgba(0,186,73,.5) !important;*/
		/*background: rgba(40,176,255,1) !important;*/
	}
	
	/* /////////////////////////////////////////////////////////// */
	/* ////////////////////   MOBILE STYLES   //////////////////// */
	/* /////////////////////////////////////////////////////////// */
	
	@media (max-width: 586px) {
		.input_sub {
			margin-left: 5%;
			margin-right: 5%;
			margin-bottom: 15px;
			width: 90%;
		}
		.input_subb {
			margin-left: 5%;
			margin-right: 5%;
			margin-bottom: 15px;
			width: 90%;
		}		
	}
</style>

<div class="" style="text-align:center; height:auto; font-size:17px; padding:30px 0 0;
	margin-bottom:0px; line-height:25px; text-align:left;">

	<form id="subscribeform" class="" target="_self" action="/auth/subscribe" method="post" 
		style="max-width:900px; with:90%; margin:0 auto; text-align:center;">

		<div class="input_sub blockit" style="">
			<input id="subemail" name="subemail" placeholder="Your Email*" style="width:100%;
			background: #eee !important; color:#000; font-size:17px; 
			/*border:3px solid rgba(255,255,255,.3); */ border:3px solid #ececec;
			padding:15px; border-radius: 50px; -moz-border-radius:50px; -webkit-border-radius:50px;
			-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">				
		</div>
		<div class="input_sub blockit" style="">
			<input id="phone" name="phone" placeholder="Ph: ###-###-####" style="width:100%;
			background: #eee !important; color:#000; font-size:17px;
			/*border:3px solid rgba(255,255,255,.3); */ border:3px solid #ececec;
			padding:15px; border-radius: 50px; -moz-border-radius:50px; -webkit-border-radius:50px;
			-webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;">
		</div>
		<div class="input_subb blockit" style="">
			<!--<div class="btn-black" style="">
				<a href="#rsvp" style="">RSVP
					<i class="fa fa-angle-right" aria-hidden="true"></i></a>
			</div>-->
			
			<input id="subscribe" type="submit" value="RSVP &rtrif;" class="btn-black"
			style="margin-top:8px !important; width:200px; display:inline; height:90px;
			border:3px solid rgba(255,255,255,.3);">
			
			<input type="hidden" id="interestedin" name="interestedin" 
			placeholder="rsvp" value="rsvp">
		</div>
		
		<br /><br />
		
		<div style="color:#777; font-size:22px; line-height:32px;">
			<span style="/*text-shadow:0px -1px 0px rgba(0,0,0,.4);*/">
			&nbsp;&nbsp;<span id="totalsubs"
			style="color:#00E21A; background:none; font-weight:600"><?= $total_subscribers ?></span>
			<span style="color:#777;">reserved</span> -
			<span id="totalspots" style="font-weight:600; 
			color:#00E21A;"><?= $total_spotsleft ?></span> spots left&nbsp;&nbsp;
				
			<span id="result" style="display:none; color:#00E21A; 
			font-weight:600;">You&rsquo;re RSVP&rsquo;d. 
			We&rsquo;ll send you an email just before we launch the BETA version.</span>
		</span>
		</div>
	</form>
</div>

<script type="text/javascript">
	$(document).ready(function() {

		/* Refresh the page */
		setTimeout(function() {
			getSubscribers();
		},7000); // milliseconds

		$('#subscribeform').submit(function (e) {
			e.preventDefault();
			var subemail = $('#subemail').val().toLowerCase();
			var frm = this;
			$.ajax({
				type: 'POST',
				url: '/auth/checkEmail',
				data: {
					email: subemail
				},
				success: function (result) {
					//alert(subemail);
					//alert(result);
					if (result == 0) {
						//$('#subscribeform').submit();
						submitForm();
					} else {
						alert('The e-mail address entered is not valid or has already been registered.');
					}
				}
			});
		});
	});
	// DOC READY ENDS HERE, REGULAR JQUERY/JAVASCRIPT FUNCTIONS START

	function submitForm(){
		// Initiate Variables With Form Content
		var email = $("#subemail").val().toLowerCase();
		var interestedin = $("#interestedin").val();

		$.ajax({
			type: "POST",
			url: "/auth/subscribe",
			//data: "email=" + email,
			//data: "data1="+myindex+"&data2="+selValue,
			data: { email: email, interestedin: interestedin },
			success : function(result) {
				$("#result").show();
				$("#totalsubs").load(" #totalsubs");
				$("#totalspots").load(" #totalspots");
				$("#subemail").val("");
			}
		});
	}

	function getSubscribers(){
		$.ajax({
			url: "/plans/checkCount",
			type: "POST",
			data: data,
			success: function(d) {
				if (d) {
					var result = $.parseJSON(d);
					var referrer = result.referrer;
					//alert(d);
					$("#totalsubs").html(d);
					$("#totalsubs").css("background", "#29CE29");
					$("#reserr").hide();
					$("#result").show();
					$("#referrer_id").val(d);
					//alert(d);
				} else {
					$("#entercode").css("background", "#ff0000");
					$("#result").hide();
					$("#reserr").show();
				}
				//return false;
			},
			error: console.log("it did not work"),
		});
	}
</script>
		