<?php
	session_start();
	include "correlations/includes.php";
	$ME = "contactus.php";
	
// list of all fields to pick up using $_POST
$allfields = array(	"Name","StreetAddress","City","State","ZipCode","PhoneNumber","email","comments","submit", "bfield");

// list of all required fields on the form
$required  = array(	"Name","StreetAddress","City","State","ZipCode","email","comments","Submit");

$_SESSION['errors'] = "";

// check if form has been submitted
if (isset($_POST['Submit']))
{
	// capture the posted values in Session variables
	foreach($allfields as $field) {
		$_SESSION[$field] = @$_POST[$field];
	}

	// check the invisible robot discovery field
	if ($_SESSION['bfield'] <> "")
		exit;
		
	// check for required fields
	$_SESSION['fieldErrors'] = "";
	foreach($required as $field) {
		if (!$_POST[$field])
		{
			$_SESSION['fieldErrors'] .= "	- $field -<br>";
		}
	}

	// check for valid email address
	if (!isValidEmail(@$_SESSION['email']))
	{
		$_SESSION['fieldErrors'] .= "- Invalid email address <br>";
	}
	
	// check for bot
	if (!strstr(@$_SESSION['comments'], "<a href") === FALSE or !strstr($_SESSION['comments'], "http://") === FALSE)
	{
		// create an entry in the search log file
		$Line = date('m/d/y H:i:s') . '  ' . $ME . ' comments field has "<a href" or "http://"';
		$logfile = "../logs/bots.txt";
		$fp = fopen($logfile, "a");
		fwrite($fp, $Line . "\r\n");
		fclose($fp);
			
		// get out now
		exit;
	}
	
	// if everything OK
	if (!isset($_SESSION['fieldErrors']) || $_SESSION['fieldErrors'] == "" )
	{
        $name     = isset($_SESSION['Name'         ]) ? $_SESSION['Name'         ] : ' -*- ';
        $address  = isset($_SESSION['StreetAddress']) ? $_SESSION['StreetAddress'] : ' -*- ';
        $city     = isset($_SESSION['City'         ]) ? $_SESSION['City'         ] : ' -*- ';
        $state    = isset($_SESSION['State'        ]) ? $_SESSION['State'        ] : ' -*- ';
        $zip      = isset($_SESSION['ZipCode'      ]) ? $_SESSION['ZipCode'      ] : ' -*- ';
        $phone    = isset($_SESSION['PhoneNumber'  ]) ? $_SESSION['PhoneNumber'  ] : ' -*- ';
        $email    = isset($_SESSION['email'        ]) ? $_SESSION['email'        ] : ' -*- ';
        $comments = isset($_SESSION['comments'     ]) ? $_SESSION['comments'     ] : ' -*- ';


		$Message = "*******************************************************************\n";

		$Message .= "Date:      " . date("F j, Y, g:i a") . "\n";
		$Message .= "NAME:      " . $name       . "\n";
		$Message .= "ADDRESS:   " . $address    . "\n";
		$Message .= "CITY:      " . $city       . "\n";
		$Message .= "STATE:     " . $state      . "\n";
		$Message .= "ZIP:       " . $zip        . "\n";
		$Message .= "PHONE:	    " . $phone      . "\n";
		$Message .= "EMAIL:	    " . $email      . "\n";
		$Message .= "COMMENTS:\n" . $comments   . "\n";
	

//		$Message .= "Date:		" . date("F j, Y, g:i a") . "\n";
//		$Message .= "NAME:		" . $_SESSION['Name'] . "\n";
//		$Message .= "ADDRESS:	" . $_SESSION['StreetAddress'] . "\n";
//		$Message .= "CITY:		" . $_SESSION['City'] . "\n";
//		$Message .= "STATE:	" . $_SESSION['State'] . "\n";
//		$Message .= "ZIP:		" . $_SESSION['ZipCode'] . "\n";
//		$Message .= "PHONE:	" . $_SESSION['PhoneNumber'] . "\n";
//		$Message .= "EMAIL:	" . $_SESSION['email'] . "\n";
//		$Message .= "COMMENTS:\n" . $_SESSION['comments'] . "\n";
		
		sendEmail("sales@harmonicvision.com", $_SESSION['email'], "Harmonic Vision Inquiry", $Message);
		header("Location: contactus_confirm.php");

        //////////////////////////////////////////////////
        // Log the email.
        $logfile = "../logs/contactus.txt";

        $fp = fopen($logfile, "a");

        if ($fp){

            $line = "-----------------------------------\r\n";
            fwrite($fp, $line);
            fwrite($fp, $Message);
            
            fclose($fp);
        }

		exit;
	}
}
else
{
	// first time through - form has not been submitted yet
	// clear all the input fields on the form
	$_SESSION['fieldErrors'] = "";
	//foreach($allfields as $field) {
	//	$_SESSION[$field] = "";
	//}
}
?>

<!DOCTYPE html>
<html>

<head>

<title>Contact Us form</title>

<meta name="description" content="Harmonic Vision is the developer and publisher of the Music Ace series of music education software.">
<meta name="keywords" content="music education, piano lessons, music education software, music theory, learning music, music lessons, beginning music, music software, Music Ace, Music Doodle Pad, Music Ace 2, Music Ace Deluxe, Music Ace Maestro">

<link rel="stylesheet" href="css/styles.css" type="text/css">

<style type="text/css">
.style11 {color: #FF0000}
.style17 {font-size: 9px}
.style18 {	font-family: Arial, Helvetica, sans-serif;
	font-weight: bold;
}
.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.style19 {color: #FF0033}
.styleRED {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
	color: #FF0000;
	background-color: #dddddd;
}
</style>
</head>

<body OnLoad="document.F1.Name.focus();">
<br>  <!--  <br> to push the whole page down 1 line from the browser top  -->

<!-- ===============================  start page container table (entire page is enclosed by this table) ===== -->
<table border="1" cellpadding="0" cellspacing="0" width="800" align="center" bgcolor="#fffffe"><tr><td valign="top">

<!-- =================================== start Logo Header ======================================= --><!-- #BeginLibraryItem "/Library/header.lbi" -->
<table width="788" border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#FFFFFF">
  <tr><td><img src="images/spacer.gif" alt="" width="784"  height="5"></td></tr>
  <tr><td><img src="images/insidetop.gif" alt="" width="784"  height="57"></td></tr>
</table>
<!-- #EndLibraryItem --><!-- =================================== end Logo Header ======================================= -->

<!-- =================================== start Navigation Buttons ======================================= --><!-- #BeginLibraryItem "/Library/navbuttons.lbi" --><table width="771" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td>
  <div class="navBar"" align="left">
    <ul id="nav">
	<li><a href="#">Products</a>
		<ul>
			<li><a href="madfact.htm">Music Ace Deluxe</a></li>
			<li><a href="mamfact.htm">Music Ace Maestro</a></li>
			<li><a href="mafact.htm">Music Ace</a></li>
			<li><a href="ma2fact.htm">Music Ace 2</a></li>
			<li><a href="pafact.htm">Piano Ace</a></li>
			<li><a href="mampupg.htm">Product Upgrades</a></li>
		</ul>
	</li>
	
	<li><a href="#">At Home</a>
		<ul>
			<li><a href="hs/index.htm">Homeschool</a></li>
			<li><a href="products_home.htm">Individual or family</a></li>
			<li><a href="pianostudent/index.htm">Piano Student</a></li>
		</ul>
	</li>
    	
	<li><a href="#">School</a>
		<ul>
			<li><a href="products_edu.htm">Products</a></li>
			<li><a href="educatorresources.htm">Resources</a></li>
		</ul>
	</li>	
	
	<li><a href="#">Studio</a>
       <ul>
            <li><a href="pianoteacher/index.htm">Studio Teachers</a></li>
			<li><a href="educatorresources.htm">Resources</a></li>
       </ul>
	</li>
			
	<li><a href="mampupg.htm">Upgrades</a></li>	
    
	<li><a href="#">Support</a>
      <ul>
            <li><a href="techsupport/index.htm">Technical Support</a></li>
            <li><a href="forms/registerform.php">Register Product</a></li>
            <li><a href="dealer.htm">Dealer support</a></li>
            <li><a href="news.htm">Press/media</a></li>
            <li><a href="contactus.php">Contact Us</a></li>
       </ul>
    </li>	
    
	<li><a href="forms/demoform.php">Free Demo</a></li>
  </ul>
  </div>
</td></tr></table>
<!-- #EndLibraryItem --><!-- =================================== end Navigation Buttons ======================================= -->

<!-- ========================== start Breadcrumb - update this for each page  ============ -->
<table width="771" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td>
<div id="breadcrumb"><a href="index.htm">Home</a>&gt; Contact Us</div>
    </td>
  </tr>
</table>
<!-- ================================= end Breadcrumb ==================================== -->

<!-- ================================= Start Content container table ================================== -->
  <div><table border="0" cellpadding="0" cellspacing="0" width="784" bgcolor="#FFFFFF" align="center"><tr><td>
	 
<!-- ============================== START CONTENT - put page content here =============================== -->	 
		 
<table width="620" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td>
	<table width="640" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="76%"><p align="center" class="style18">Contact Harmonic Vision</p>
              <table width="100%" border="1" cellspacing="0" cellpadding="5">
                <tr>
                  <td width="31%"><span class="verdana-12"><strong>Mail</strong></span></td>
                  <td width="39%"><strong class="verdana-12">Telephone</strong></td>
                  <td width="30%"><strong class="verdana-12">E-mail</strong></td>
                </tr>
                <tr>
                  <td class="verdana-11">Harmonic Vision<br>
                  310 Robin Pkwy
                  <br>
                  Madison, WI 53705</td>
                  <td class="verdana-11">Phone: 608-422-2283 <br>
                    Toll-Free (U.S. only): 800-474-0903<br>
                    Fax: 866-422-6686</td>
                  <td class="verdana-11">&nbsp;<a href="/redirect-mail.php?u=sales&d=harmonicvision.com" target=rm>Sales</a><br>
                    <iframe name=rm width=1 height=1 frameborder=0 scrolling=no style=\"visibility:hidden;\"></iframe>
                    <a href="forms/techsupportform.php">Technical Support</a> </td>
                </tr>
              </table>
</td>
      </tr>
    </table>
	
    <ul class="verdana-11">
          <!-- <li>If you need a <strong>replacement product registration number</strong>, or other <strong>technical 
            support</strong>, <a href="techsupport/index.htm">click here</a></li>
          <br> -->
          <li></span>If you are a <strong>member of the media </strong> and would like more information please <a href="news.htm">click here</a>.</li><br>
          <li>If you would like more information about Harmonic Vision products or would like to submit comments or  suggestions, or for any other contact need please fill out the form below. (<span class="style19">* - required field</span>)</li>
        </ul>
     
	  <table width="468" border="1" align="center" cellpadding="10" cellspacing="0" bgcolor="#dddddd">
          <tr>
            <td width="499" align="left" valign="top" ><?php
// if missing fields were detected, display a table with all the missing fields
if (isset($_SESSION['fieldErrors']) && $_SESSION['fieldErrors'] != "") {
    echo '<table border="0" >
	        <tr>
            <td>
			<div align="center"><span class="styleRED">The following required fields are missing or invalid. 
			Please correct the fields and Submit again<br>' . $_SESSION['fieldErrors'] . '</span></div><br>
			</td>
            </tr>
          </table>';
}
?>
                <FORM Name ="F1" METHOD="POST" action="<?php echo $ME; ?>" >
                  <table width="441" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td width="243" class="verdana-11 style17">Name: <span class="style11">*</span></td>
                      <td width="9">&nbsp;</td>
                      <td width="91">&nbsp;</td>
                      <td width="12">&nbsp;</td>
                      <td width="127">&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="style5">
                        <input name="Name" type="text" value="<?php echo @$_SESSION['Name'];?>" class="verdana-11" id="Name" size="40">                      </td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="verdana-11 style17">Street Address: <span class="style11">*</span></td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="verdana-11">
                        <input name="StreetAddress" type="text" value="<?php echo @$_SESSION['StreetAddress'];?>" class="verdana-11" id="Street Address" size="40">                      </td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="verdana-11 style17">City: <span class="style11">*</span></td>
                      <td>&nbsp;</td>
                      <td class="verdana-11 style17">State: <span class="style11">*</span></td>
                      <td>&nbsp;</td>
                      <td class="verdana-11 style17">Zip Code: <span class="style11">*</span></td>
                    </tr>
                    <tr>
                      <td class="verdana-11">
                        <input name="City" type="text" value="<?php echo @$_SESSION['City'];?>" class="verdana-11" id="City" size="40">                      </td>
                      <td>&nbsp;</td>
                      <td class="verdana-11">
                        <input name="State" type="text" value="<?php echo @$_SESSION['State'];?>" class="verdana-11" id="State" size="12">                      </td>
                      <td>&nbsp;</td>
                      <td class="verdana-11">
                        <input name="ZipCode" type="text" value="<?php echo @$_SESSION['ZipCode'];?>" class="verdana-11" id="Zip Code" size="12">                      </td>
                    </tr>
                    <tr>
                      <td class="verdana-11 style17">E-mail Address: <span class="style11">*</span></td>
                      <td>&nbsp;</td>
                      <td class="verdana-11 style17">Phone Number:</td>
                      <td>&nbsp;</td>
                      <td>&nbsp;</td>
                    </tr>
                    <tr>
                      <td class="verdana-11">
                        <input name="email" type="text" class="verdana-11" value="<?php echo @$_SESSION['email'];?>" size="40" maxlength="60">                      </td>
                      <td>&nbsp;</td>
                      <td class="verdana-11">
                        <input name="PhoneNumber" type="text" value="<?php echo @$_SESSION['PhoneNumber'];?>" class="verdana-11" id="Phone Number" size="14">                      </td>
                      <td>
		 <!-- The following code is invisible to humans and contains some trap text fields                -->
		<div style="display: none">
		If you can read this, don't touch the following text fields.<br>
		<input type="text" name="bfield" size="10" value="<?php echo @$_SESSION['bfield'];?>"><br>
		</div>
					</td>
                      <td>&nbsp;</td>
                    </tr>
                  </table>
                  <span class="verdana-11 style17">Comment, question or suggestion: <span class="style11">*</span></span> <br>
                      <textarea name="comments" cols="70" rows="6" class="verdana-11"><?php echo @$_SESSION['comments'];?></textarea>
                      <br>
                  <div align="center">
                    <input name="Submit" type="submit" class="verdana-11" id="Submit" style="font-family: Arial" value="Submit">
                  </div>
              </form></td>
          </tr>
        </table><br>
  </tr>
</table>

<!-- ==============================   END CONTENT ====================================================== -->

<!-- ================================= End Content container table ================================== -->
  </td></tr></table></div>
  
<!-- ================================= start Footer ============================================ --><!-- #BeginLibraryItem "/Library/footer.lbi" --><table width="771" border="0" cellspacing="0" cellpadding="0" align="center" class="footer">
  <tr>
    <td>
       <div id="footernav">
          <a href="index.htm" target="_parent">Home</a>
          <a href="privacy.htm" target="_parent">Privacy Policy</a>
          <a href="contactus.php" target="_parent">Contact Us</a></div>
       <div align="center">Copyright &copy; 2013 Harmonic Vision Inc.<br><br></div>
	</td>
  </tr>
</table>
<!-- #EndLibraryItem --><!-- ===============================  end Footer =============================================== -->

<br>

<!-- ==============================  close container table ======================== -->
</tr></td></table>

</body>
</html>
