<?php
/************************************************************************
 * This file is part of Windows Image Gallery.				*
 *									*
 * Windows Image Gallery is free software:				*
 * you can redistribute it and/or modify				*
 * it under the terms of the GNU General Public License as published by	*
 * the Free Software Foundation, either version 3 of the License, or	*
 * (at your option) any later version.					*
 *									*
 * Windows Image Gallery is distributed in the hope that it will be	*
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty	*
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	*
 * GNU General Public License for more details.				*
 *									*
 * You should have received a copy of the GNU General Public License	*
 * along with Windows Image Gallery.					*
 * If not, see <http://www.gnu.org/licenses>.				*
 ************************************************************************/
?>
<script>
 function goBack()
   {
     window.history.back()
   }
 </script>
</head>

<body>

<?php
if (isset($_REQUEST['email'])) {
	require('config.php');
	//send email
	$email = $_REQUEST['email'] ;
	$subject = $_REQUEST['subject'] ;
	$message = $_REQUEST['message'] ;

	echo "<table class='table' width='50%'>
		<tr class='table_header'>
			<td></td>
		</tr>
		<tr class='row1'>
			<td>";
				if ($email == "") {
					echo "ERROR: you have to fill in a E-mail adress<br>";
					echo "<input type='button' value='Back' onclick='goBack()' />";
					exit;
				}
				if ($subject == "") {
					echo "ERROR: you have to fill in a subject<br>";
					echo "<input type='button' value='Back' onclick='goBack()' />";
					exit;
				}
				if ($message == "") {
					echo "ERROR: you have to fill in a message<br>";
					echo "<input type='button' value='Back' onclick='goBack()' />";
					exit;
				}

			mail($my_email, $subject, "This is a message from the contact form at: " . $sitename . " --- " .
			$message, "From:" . $email);
			echo "Your message has been send.<br>We will reply as soon as possible.
			</td>
		</tr>
	</table>";
 
} else {






	echo "<form method='post' onClick='ajaxwin.load('ajax', 'contact_form.php', 'New Ajax Page')' action='contact_form.php'>
		<table class='table' width='40%'>
			<tr class='table_header'>
				<td colspan='2'></td>
			</tr>
			<tr class='row1'>
				<td>Email:</td>
				<td>
					<input name='email' type='text' />
				</td>
			</tr>
			<tr class='row1'>
				<td>Subject:</td>
				<td>
					<input name='subject' type='text' />
				</td>
			</tr>
			<tr class='row1'>
				<td valign='top'>Message:</td>
				<td>
					<textarea name='message' rows='8' cols='40'></textarea>
				</td>
			</tr>
			<tr class='row1'>
				<td>&nbsp;</td>
				<td>
					<input type='submit' value='Send Message' />
				</td>
			</tr>
		</table>
	</form>";
}
?>

</body>
</html>
