<style type="text/css">
	.darkfields {
		background: #ddd;
		color: #000;
		font-size: 15px;
		-webkit-appearance: textfield;
		-webkit-border-radius: 3px;
		-moz-border-radius: 3px;
		border-radius: 3px;
		border: 0px !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;		
	}
	button.contactbtn {
		background:#eee !important;
		color:#111;
		padding:15px 35px;
		background-color: #eee !important;
		border:1px solid #ddd;
		box-sizing: border-box;
		text-shadow:0px 1px 0px rgba(255,255,255,.3);
		border-color: buttonface;	
	}	
  .label{
    text-align:right;
  }
  #submit{
    text-align:center;
  }
  td { padding-top:10px; padding-bottom:10px; }	
</style>

<div>
	<h1 style="line-height:38px;">Inquire about this Event</h1>

<?php
  //$to='sillystats@gmail.com';
  $to = $project['user']['email'];
  
  $messageSubject='New Message Notification from Continual!';
  $confirmationSubject='Email Receipt Confirmation!';
  $confirmationBody="Your message was submitted successfully and a copy was emailed directly to the Organizer or Poster of the Event.\r\n
  Thanks,\r\n
  Continual Team!\r\n
  \r\n";
  $email='';
  $name='';
  $phone='';
  $body='';
  $displayForm=true;
  if ($_POST){
    $email=stripslashes($_POST['email']);
	$name=stripslashes($_POST['name']);
	$phone=stripslashes($_POST['phone']);	
	$body = "From ContinualEvents.com: \r\n\r\n";
    $body .=stripslashes($_POST['body']);
	$body .= "\r\n\r\nEmail: " .$email;
	$body .= "\r\nName: " .$name;
	$body .= "\r\nPhone: " .$phone;
	
    // validate e-mail address
   	$valid=eregi('^([0-9a-z]+[-._+&])*[0-9a-z]+@([-0-9a-z]+[.])+[a-z]{2,6}$',$email);
    $crack=eregi("(\r|\n)(to:|from:|cc:|bcc:)",$body);
	if ($email && $body && $valid && !$crack){
		
		if ($email && $body){
			// EMAIL TO THE OWNER OF THE EVENT
			if (mail($to,$messageSubject,$body,'From:'. $name . '<'. $email .'>')
			//if (mail($to,$messageSubject,$body,'From: '.$email."\r\n")
			// EMAIL TO THE SENDER (Confirmation)
			  && mail($email,$confirmationSubject,$confirmationBody,'From: Continual <noreply@continualevents.com>')){
			$displayForm=false;
	}
?>
<p>
  Your message was successfully sent.
  In addition, a confirmation copy was sent to your e-mail address.
  Your message is shown below.
</p>
<?php
        echo '<p><strong>'.htmlspecialchars($body).'</strong></p>';
        echo '<br /><br />';
        echo '<a href="" style="font-weight:bold; color:#0000ff;">Show the Contact Form again &raquo;</a>';
      }else{ // the messages could not be sent
?>
<p>
  Something went wrong when the server tried to send your message.
  This is usually due to a server error, and is probably not your fault.
  We apologise for any inconvenience.
</p>
<?php
      }
    }else if ($crack){ // cracking attempt
?>
<p><strong>
  Your message contained e-mail headers within the message body.
  This seems to be a cracking attempt and the message has not been sent.
</strong></p>
<?php
    }else{ // form not complete
?>
<p><strong>
  Your message could not be sent.
  You must include both a valid e-mail address and a message.
</strong></p>
<?php
    }
  }
  if ($displayForm){
?>

<form action="" method="post">
  <table class="contactform">
     <tr>
      <td class="label" style="padding-right:5px;"><label for="name">Name: </label></td>
      <td style="width:100%; text-align:left">
        <input class="darkfields" type="text" name="name" id="name" value="<?php echo htmlspecialchars($name); ?>" size="30" 
        style="width:90%; max-width:350px; padding:7px;">
      </td>
    </tr> 
    <tr>
      <td class="label" style="padding-right:5px;"><label for="email">E-mail: </label></td>
      <td style="width:100%; text-align:left">
        <input class="darkfields" type="text" name="email" id="email" value="<?php echo htmlspecialchars($email); ?>" size="30" 
        style="width:90%; max-width:350px; padding:7px;">
      </td>
    </tr>
    <tr>
      <td class="label" style="padding-right:5px;"><label for="phone">Phone: </label></td>
      <td style="width:100%; text-align:left">
        <input class="darkfields" type="text" name="phone" id="phone" value="<?php echo htmlspecialchars($phone); ?>" size="30" 
        style="width:90%; max-width:350px; padding:7px;">
      </td>
    </tr>
    <tr>
      <td class="label" style="padding-right:5px;"><label for="body">Message: </label></td>
      <td style="width:100%; text-align:left">
		<textarea class="darkfields" name="body" id="body" rows="5" 
			style="width:90%; max-width:350px; margin-right:20px; padding:7px; background:#f7f7f7;">Hi. I&rsquo;m interested in this Event... <?php echo htmlspecialchars($body); ?></textarea>
	  </td>
    </tr>
    <tr><td></td><td id="submit" style="text-align:left;"><button class="contactbtn" type="submit">Send message</button></td></tr>
    <tr>
      <td class="label"><label for="email"></label></td>
	  <td style="color:#aaa; text-shadow:0px 1px 0px rgba(255,255,255,.7); font-size:12px; 
		  text-align:left; line-height:17px;">
            Note: a confirmation e-mail will be sent to your email address.
            <br /><br />
      </td>
    </tr>    
  </table>
</form>
<?php
  }
?>		
        
</div><!-- end -->
