<?php
  include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/inc/sessionStartGeneral.php");
?>
<?php
  $pageTitle = "Contact Us";
  $pageDescription = "We care about your thoughts. Let us know what we are doing right, or wrong.";
  $pageKeywords = "contact us, feedback";
  
  $action = "contact";
  $subject = "Contact Form";
  
  if(isset($_GET['a'])){
	switch($_GET['a']){
	  case "special":
		$action = "special";
		$subject = "Special Order Form";
		break;
	  default:
		break;
	}
  }
?>
<?php include_once($_SERVER['DOCUMENT_ROOT'] . "/common/header.php") ?>
<script src="/Kickstrap/js/jquery.h5validate.js" type="text/javascript"></script>
<?php include_once($_SERVER['DOCUMENT_ROOT'] . "/common/mainNav.php")?>
    
    
    
    <section class="container">
      <div id="blankBuffer" class="carousel-buffer"></div>
      
      <section class="container" id="mainContent">
        <article class="row">
          <div class="span12" id="contactContainer">
            <?php
			  if($action == "special"){
			?>
			  <h1>Special Order Form</h1>
			  <p>Can't find what you are looking for in our store. Let us know what it is by filling out the form below and we will do everything we can to get it for you.</p><br><br>
			<?php
			  }else{
			?>
			  <h1>Tell us your thoughts</h1>
			  <p>Do you have a question about where to find your favorite food, how to prepare a delicious Salmon fillet or how you can order a specialty item?  Please feel free to send us an email or give us a call at the store.  Your satisfaction is our primary concern and number one goal.  We will respond quickly to any and all questions or comments.  We love to hear from our customers.</p><br><br>
			<?php
			  }
			?>
            
			<div class="offsetPadLeft">
              <form action="/formmail.php" name="contactForm" method="post">
                <input type="hidden" name="env_report" value="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT,AUTH_TYPE,REMOTE_USER" />
                <input type="hidden" name="recipients" value="contactThayne@afsshareportal.com" />
                <input type="hidden" name="required" value="email:Your email address,name:Your name" />
                <input type="hidden" name="subject" value="<?php echo $subject; ?> Submission From <?php echo WEB_URL; ?>" />
                <input type="hidden" name="good_url" value="<?php echo DOC_ROOT; ?>thanks.php">
                <input type="hidden" name="conditions1" value=":#
 #TEST#email ~ /^[a-z0-9_.]+@[a-z0-9_]+\.([a-z0-9_.]+)*[a-z0-9_.]$/i ##
  Please enter a valid email address.#">
				<input type="hidden" name="conditions2" value=":##IF#phone#phone~ /^\D?(\d{3})?\D?\D?(\d{3})\D?(\d{4})$/##Please enter a valid phone number xxx-xxx-xxxx#:"/>
				
				<?php
				  if($action == "special"){
				?>
				  <!-- put in the right fields for the special order form -->
				  <div class="textInput">
					  <label for="description">Item Description</label>
					  <input type="text" value="" name="description" id="description">
				  </div>
				  
				  <div class="textInput">
					  <label for="size">Item Size</label>
					  <input type="text" value="" name="size" id="size">
				  </div>
				  
				  <div class="textInput">
					  <label for="flavor">Flavor / Color</label>
					  <input type="text" value="" name="flavor" id="flavor">
				  </div>
				  
				  <div class="textInput">
					  <label for="upc">Item UPC</label>
					  <input type="text" value="" name="upc" id="upc">
				  </div>
				<?php
				  }
				?>
				
                <?php include("https://afsshareportal.com/common/contactForm.php"); ?>
				
				<?php
				  if($action == "special"){
				?>
				  <script>
					$("#comments").parents(".textAreaInput").remove();
				  </script>
				<?php
				  }
				?>
              </form>
            </div>
          </div>
        </article>
        
      </section>
    </section>
      
    
    
    
    <?php include_once($_SERVER['DOCUMENT_ROOT'] . "/common/footer.php"); ?>
  <script>
   
    function getStoreLocations(){
        $.ajax({
            type: "POST",
            url: "/admin/lookUp.php",
            data: "action=getStoreLocations",
            dataType: "json",
            success: function(theResponse){
                var theHTML = "";
                //console.log("num locations: " + theResponse.length);
                if(theResponse.length > 1){
                  $.each(theResponse, function(){
                    theHTML += "<option>" + this.store_name + "</option>";
                  });
                  
                  $("#location").append(theHTML);
                }else{
                  $("#location").closest("div").remove();
                }
            }
        });
    }
    
    getStoreLocations();
   
    $('#contactForm').h5Validate();
			
    $("#contactForm").submit(function(event){
        event.preventDefault();
        
        var myResult = validateForm("contactForm");
        
        var theLocation = $("#location").val();
        
        if(myResult == true)
        {
            var self = $(this);	
            self.unbind('submit').submit()
        }
    });
   
   ks.ready(function() {
      // JavaScript placed here will run only once Kickstrap has loaded successfully.
      
      
   });
  </script>
  
  
</body>
</html>
