<?php include('views/_header_m.tpl.php'); ?>

<?php

	function captchaTokenVerify($token){
		// call curl to POST request
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,"https://www.google.com/recaptcha/api/siteverify");
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('secret' => '6LcfnVopAAAAAO9N92-T-OTPo24n8Nd7Y_R31Gcv', 'response' => $token)));
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$response = curl_exec($ch);
		curl_close($ch);
		$arrResponse = json_decode($response, true);

		// verify the response
		if($arrResponse["success"] == '1' && $arrResponse["score"] >= 0.5) {
			return true;
		} else {
			return false;
		}
	}
	  
	if($_POST && isset($_POST['g-recaptcha-response']) && captchaTokenVerify($_POST['g-recaptcha-response'])) {

	    $visitor_name = "";
	    $visitor_email = "";
	    $concerned_department = "";
	    $visitor_message = "";
	    $email_body = "<div>";
	      
	    if(isset($_POST['visitor_name'])) {
	        $visitor_name = filter_var($_POST['visitor_name'], FILTER_SANITIZE_STRING);
	        $email_body .= "<div>
	                           <label><b>Visitor Name:</b></label>&nbsp;<span>".$visitor_name."</span>
	                        </div>";
	    }
	 
	    if(isset($_POST['visitor_email'])) {
	        $visitor_email = str_replace(array("\r", "\n", "%0a", "%0d"), '', $_POST['visitor_email']);
	        $visitor_email = filter_var($visitor_email, FILTER_VALIDATE_EMAIL);
	        $email_body .= "<div>
	                           <label><b>Visitor Email:</b></label>&nbsp;<span>".$visitor_email."</span>
	                        </div>";
	    }
	      
	    if(isset($_POST['concerned_department'])) {
	        $concerned_department = filter_var($_POST['concerned_department'], FILTER_SANITIZE_STRING);
	        $email_body .= "<div>
	                           <label><b>Concerned Department:</b></label>&nbsp;<span>".$concerned_department."</span>
	                        </div>";
	    }
	      
	    if(isset($_POST['visitor_message'])) {
	        $visitor_message = htmlspecialchars($_POST['visitor_message']);
	        $email_body .= "<div>
	                           <label><b>Visitor Message:</b></label>
	                           <div>".$visitor_message."</div>
	                        </div>";
	    }
	      
	    if($concerned_department == "General Inquiry") {
	        $recipient = "contact@basepages.com";
	    }
		else if ($concerned_department == "Sales") {
			$recipient = "contact@basepages.com";
	    }
		else if ($concerned_department == "Call Back") {
			$recipient = "contact@basepages.com";
		}
		else if ($concerned_department == "Live Demo") {
			$recipient = "contact@basepages.com";
		}
		else if ($concerned_department == "Tech Support") {
			$recipient = "support@basepages.com";
	    }
		else if ($concerned_department == "Partnerships") {
			$recipient = "contact@basepages.com";
	    }
		else if ($concerned_department == "Investors") {
			$recipient = "investors@basepages.com";
		}
		else if ($concerned_department == "Delete Account") {
			$recipient = "support@basepages.com";
		}
		else {
			$recipient = "contact@basepages.com";
	    }
	      
	    $email_body .= "</div>";
	    
		$email_title = "New Message from your Contact Form";
	 
	    $headers  = 'MIME-Version: 1.0' . "\r\n"
	    .'Content-type: text/html; charset=utf-8' . "\r\n"
	    .'From: ' . $visitor_email . "\r\n";
	      
		if (@mail($recipient, $email_title, $email_body, $headers)) {
			echo "<script>window.location.href='https://basepages.com/thx';</script>";
	        // echo "<p>Thank you for contacting us, $visitor_name. If your message requires a response, someone from our team will reach out within the next couple of hours - up to 24 hours.</p>";
	    } else {
	        echo '<p>We are sorry, but your message did not go through. <a href="/contact">Go Back</a></p>';
	    }
	      
	} else {
	    //echo '<p>Ooooops! Something went wrong. Please try again or contact us directly at contact@getpreorder.com - Thanks!</p>';
	}
?>
 
<style type="text/css">
/*	html {
		background: url('/static/images/lbstartup.jpg') no-repeat center center !important;
		background-size: 500px !important;
		background-color: #000 !important;
		overflow:auto !important;
	}
	body { height:100%; overflow:auto; background-color: #000 !important; }*/
	.spacer {
		padding-top: 51px;
	}
  	.label{
    	text-align:right;
  	}

  	#submit{
   	 text-align:center;
  	}
  	td { padding-top:10px; padding-bottom:10px; }
  	button { border:1px solid rgba(255,255,255,.1); padding:15px 0; width:200px; margin:0; 
	font-family: 'Open Sans', Montserrat,Arial,sans-serif; background: #42B54C; font-size:18px; text-align:center; color:#fff; text-shadow:0px -1px 1px rgba(0,0,0,.3); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; }
  	button:hover { background:red; }
	div.elem-group { margin-bottom:15px; }
	/*a#btn-toogle-menu.btn-toogle-menu { display:none; }*/
	/**
	* 
	* CONTACT FORM STYLES HERE
	*
	*/
	label { font-size:12px; letter-spacing:2px; font-weight:300; text-transform:uppercase; }
	input[type="text"], input[type="password"] {
	    height: 30px;
		width:95%;
		/*background: rgba(0,0,0,.4);*/
		background: #eee;
	    color: #000;
	    font-size: 17px;
	    -webkit-appearance: textfield;
	    -webkit-border-radius: 3px;
	    -moz-border-radius: 3px;
	    border-radius: 3px;
	    border: 0px solid rgba(255,255,255,.3) !important;
	    padding: 10px;
	    border-image-source: initial;
	    border-image-slice: initial;
	    border-image-width: initial;
	    border-image-outset: initial;
	    border-image-repeat: initial;
	    -webkit-rtl-ordering: logical;
	    -webkit-user-select: text;
	    cursor: auto;
	    
	}
	select, textarea { 
		/*background: rgba(0,0,0,.4);*/
		background: #eee !important;
		border:0px;
		color: #000;
		font-weight:300;
		padding:10px; 
		width:95%; 	   
		 -webkit-border-radius: 3px;
		 -moz-border-radius: 3px;
		border-radius: 3px;
	}
	/* ///////////////////////////////////////////////////////// */
	/*                        MOBILE STYLES                      */
	/* ///////////////////////////////////////////////////////// */

	@media (min-width: 980px) and (max-width: 1024px) {

	}

	/* Portrait tablet to landscape and desktop */
	@media (min-width: 768px) and (max-width: 979px) {

	}

	/* Landscape phone to portrait tablet */
	@media (max-width: 767px) {

	}

	/* Landscape phones and down */
	@media (max-width: 586px) {
		.newhdrlogo {
			/*margin-top: 5px !important;*/
			/*bottom: 3px !important;*/
		}
	}

	/* Landscape phones and down */
	@media (max-width: 480px) {

	}
	@media (max-width: 375px) {

	}
</style>

<img src="<?php if (!empty($website_options['mobile_background'])) : ?>/<?= $website_options['mobile_background'] ?><?php else : ?>/static/images/mobbg.jpg<?php endif; ?>" 
style="position:absolute; background:contain; object-fit:cover; top:0;
left:0; bottom:0; right:0; min-height:100%; width: auto; z-index:-999;" alt="BG" />

<div class="home-feature-category" style="background:#fff; border:none;">
    <div class="container_12 clearfix">
		<div class="grid_12 marked-category" style="text-align:left; font-size:17px; line-height:28px;
			font-family:'Open Sans', Montserrat,Helvetica, sans-serif; font-weight:300;">
			
			<div style="position:absolute; left: 17px; margin-top:10px;">
				<a href="/" style="color:#000; float:left; font-size:22px;"><i 
				class="fa fa-angle-left" aria-hidden="true"></i></a>
			</div>
			
			<div style="padding:20px 10px 0">
				<center><a href="/"><img src="/<?= $website_options['footer_logo'] ?>" 
				alt="Home" onerror="this.src='/static/system/base_pages_logo.png'"
				style="max-width:400px; width:80%; padding:0 10px; margin-bottom:10px"></a></center>
			
			<h1 style="text-align:center;">Contact</h1>
			
			If you&rsquo;d like to get in touch with us, please use the form below or call 
			<a href="tel:1-312-555-5555" style="color:#82ADCC; font-weight:400">1-312-555-5555</a> 
			between the hours of 9am - 9pm CST. Or, email contact@basepages.com
			
			<br /><br />
			
			<strong>Account Deletion</strong>: For Account Deletion please include:<br />
			&nbsp;&nbsp;&nbsp; 1) Your registered email<br />
			&nbsp;&nbsp;&nbsp; 2) The name of the Mobile App or Website you would like your account deleted from 
				<br /><br />
			We&rsquo;ll then send you a message to that email confirming 
			you would like to delete your account and upon your confirmation, we&rsquo;ll promptly delete
			your entire Account.
			<br /><br />

			<!-- ############################################################ -->
			<!-- ###############    CONTACT FORM STARTS HERE   ############### -->
			<!-- ############################################################ -->

			<form class="contact-form" action="" method="post" enctype="multipart/form-data" 
				style="max-width:500px; width:100%; -webkit-box-sizing: border-box;
				-moz-box-sizing: border-box; box-sizing: border-box;">
			  <div class="elem-group">
			    <label for="name">Your Name</label><br />
				<input type="text" id="name" name="visitor_name" style=""
			    placeholder="Your Name" pattern=[A-Z\sa-z]{3,20} required>
			  </div>
			  <div class="elem-group">
			    <label for="email">Your E-mail</label><br />
			    <input type="text" id="email" name="visitor_email" placeholder="Your Email" required>
			  </div>
			  <div class="elem-group">
			    <label for="department-selection">Choose a Department</label><br />
			    <select id="department-selection" name="concerned_department" required>
			        <option value="">Select a Department</option>
			        <option value="General Inquiry">General Inquiry</option>
			        <option value="Sales">Sales</option>
					<option value="Call Back">Request a Call Back</option>
					<option value="Live Demo">Request Live Demo</option>
			        <option value="Tech Support">Tech Support</option>
					<option value="Partnerships">Partnerships</option>
					<option value="Delete Account">Account Deletion</option>
			    </select>
			  </div>
			  <div class="elem-group">
			    <label for="message">Your message</label><br />
				<textarea id="message" name="visitor_message" style="min-height:100px;"
			    placeholder="Type your message here..." required></textarea>
			  </div>
			  <input type="hidden" name="g-recaptcha-response" id="g-recaptcha-response">
			  <button type="submit" id="contact-submit">Send Message</button>
			</form>

			<!-- ############################################################# -->
			<!-- ###############    CONTACT FORM STARTS HERE   ############### -->
			<!-- ############################################################# -->

  			<br /><br /><br />
  		
		 	<center> <a href="/" title="Back to Home"><i class="fa fa-angle-left"
				 aria-hidden="true"></i> back to Home</a> |
				 <a href="javascript:top.frames.location.reload();" class="refresh">
				 	<i class="fa fa-refresh"></i></a>
						<!-- |
		 	 <a href="/messages" title="View My Inbox"><span style="">My Inbox</span>
		  	<i class="fa fa-angle-right" aria-hidden="true"></i></a>-->
			  </center>
			</div><!-- INNER PADDING DIV -->
			<div class="clear"></div>
		</div><!-- GRID 12 -->
	</div>
</div>

<script src="https://www.google.com/recaptcha/api.js"></script>
<script src="https://www.google.com/recaptcha/api.js?render=6LcfnVopAAAAAEjY6-b673GY9luGHx3S_HPbaLJR"> </script>

<script>
	window.onload = function() {
		$('#contact-submit').click(function ($event) {
			// getElementById
			if (!document.getElementsByClassName('contact-form').checkValidity()) {
				return;
			}

			$event.preventDefault();

			grecaptcha.ready(function() {
				grecaptcha.execute('6LcfnVopAAAAAEjY6-b673GY9luGHx3S_HPbaLJR', {action: 'submit'}).then(function(token) {
					$('#g-recaptcha-response').val(token);
					$('.contact-form').submit();
				});
			});
		});
	}
 </script>

<?php include('views/_footer_m.tpl.php'); ?>