<?php

/*************************************************

    PHP email - Formular

    Enrico Sturm

    mail: oribi@abados.de
    url: http://www.oribi.de

    date: 04.05.2006
		
		last edit: 14.05.2006

*************************************************/

include('classes/formular.class.php');
include('classes/email.class.php');

/* setting up some initial values as constants */
/* schema -> ('CONSTANT', 'value')*/

//the address where to send the email, please change the value to your needs
define('EMAIL_DESTINATION_ADDRESS', 'oribi@abados.de');

//the Realname of the receiver please change the value to your needs
define('EMAIL_DESTINATION_NAME', 'Vom Webseiten-Formular oribi.de');


$showFormular = FALSE;
$ready        = FALSE;
$errors				= FALSE;
$pageMessage;
$errorMessages;
$checkAttributes = array('-8' => 'email', '-2' => 'subject', '-1' => 'message');
global $errorAttributes;

//we will show the formular if it was not yet sent
if(!isset($_POST['sent']))
{
	$pageMessage = "Bitte gib Deine Nachricht ein!";
	
	$showFormular = TRUE;
}


//the formular was sent by the user
if(isset($_POST['sent']))
{
	//setup an email-Object
	$email = new Email(EMAIL_DESTINATION_ADDRESS, EMAIL_DESTINATION_NAME, $_POST['email'], $_POST['name'], $_POST['subject'], $_POST['message']);
	$sendResult = $email->sendMail();
	
	$pageMessage = $email->getErrorMessage($sendResult);
	
	if($sendResult < 1)
	{
		$errors = TRUE;
		$mailErrors = $email->getAllErrorMessageNumbers();
		
		foreach($mailErrors as $errNr)
		{
			$errorMessage[] =  $email->getErrorMessage($errNr);
			$errorAttributes[$checkAttributes[$errNr]] = 1;
		}
		$showFormular = TRUE;
	}
}

//creating a Formular
$formular = new Formular($_SERVER['PHP_SELF']);
$formular->addInputFieldFor('name', 70, 50);
$formular->addInputFieldFor('email', 70, 50);
$formular->addInputFieldFor('subject', 70, 50);
$formular->addTextAreaFor('message', 53, 11);
$formular->setSubmitButton('Senden', 'sent');
$formular->setResetButton('Zurücksetzen');


//We start all output here!
?>

<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
	<title>emailformular.php</title>
	<style type="text/css" media="screen">
		.errorField { border: 1px solid red; padding: 4px; }
		.errorMessage { border: 1px dotted red; margin-bottom: 1em; background-color: #b89a74; }
.dsR1 /*agl rulekind: base;*/ { top: 8px; left: 13px; width: 784px; height: 232px; }
.dsR3 /*agl rulekind: base;*/ { top: 345px; left: 5px; width: 800px; height: 92px; }
.dsR4 /*agl rulekind: base;*/ { top: 475px; left: 368px; width: 74px; height: 37px; }
.dsR18 /*agl rulekind: base;*/ { width: 32px; height: 32px; }
#email2 { width: 170px; height: 26px; }
.dsR21 /*agl rulekind: base;*/ { top: 272px; left: 285px; width: 240px; height: 32px; }
</style>
		<csscriptdict import="import">
			<script type="text/javascript" src="file:///C:/Dokumente%20und%20Einstellungen/ES.STURM/Anwendungsdaten/Adobe/Adobe%20GoLive/Settings9/JScripts/GlobalScripts/CSScriptLib.js"></script>
		</csscriptdict>
		<csactiondict>
			<script type="text/javascript"><!--
var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		pre_email3 = newImage('http://oribi-bilder.de/Bilder/Graphiken/email3.gif');
		preloadFlag = true;
	}
}

// --></script>
		</csactiondict>
	</head>
<body onload="preloadImages();" background="http://oribi-bilder.de/Bilder/Hintergrund/Hintergrundfarbe.gif">
		<table width="812" border="0" cellspacing="0" cellpadding="0" cool gridx="16" gridy="16" height="70" showgridx showgridy usegridx usegridy>
			<tr height="23">
				<td width="336" height="69" rowspan="2"></td>
				<td width="475" height="23"></td>
				<td width="1" height="23"><spacer type="block" width="1" height="23"></td>
			</tr>
			<tr height="46">
				<td width="475" height="46" valign="top" align="left" xpos="336"><img src="http://oribi-bilder.de/Bilder/Ueberschriften/Kontakt.jpg" alt="" height="32" width="146" border="0"></td>
				<td width="1" height="46"><spacer type="block" width="1" height="46"></td>
			</tr>
			<tr height="1" cntrlrow>
				<td width="336" height="1"><spacer type="block" width="336" height="1"></td>
				<td width="475" height="1"><spacer type="block" width="475" height="1"></td>
				<td width="1" height="1"></td>
			</tr>
		</table>
		<table width="812" border="0" cellspacing="0" cellpadding="0" cool="cool" gridx="16" gridy="16" height="513" showgridx="showgridx" showgridy="showgridy" usegridx="usegridx" usegridy="usegridy">
			<tr height="8">
				<td width="5" height="512" rowspan="7"></td>
				<td width="8" height="345" rowspan="4"></td>
				<td width="784" height="8" colspan="3"></td>
				<td width="8" height="345" rowspan="4"></td>
				<td width="6" height="512" rowspan="7"></td>
				<td width="1" height="8"><spacer type="block" width="1" height="8"></td>
			</tr>
			<tr height="232">
				<td class="dsR1" cslocked content="content" csheight="232" width="784" height="232" colspan="3" valign="top" xpos="13"><? printf("<center><font color=\"#111111\"face=\"verdana,arial,helvetica\"><h4>%s</h4></font></center>\n", $pageMessage); ?><? if($errors): /*are there some errors to display?*/ ?>
					<div class="errorMessage">
						<ul>
							<? foreach($errorMessage as $msg): ?>
							<li><font size="3"><font color="#111111" face="verdana,arial,helvetica"><? printf("%s", $msg); ?></font></font><? endforeach; ?>
						</ul>
					</div>
					<? endif; /*errors*/?><? //begin showing the formular
if($showFormular): ?><? $formular->createStartTag(); ?>
					<table>
						<tr>
							<td><font size="3"><font color="#111111" face="verdana,arial,helvetica">Dein Name:</font></font></td>
							<td colspan="2"><? $formular->createFieldFor('name'); ?></td>
						</tr>
						<tr>
							<td><font size="3"><font color="#111111" face="verdana,arial,helvetica">Deine E-Mail-Adresse:</font></font></td>
							<td colspan="2"><? $formular->createFieldFor('email'); ?></td>
						</tr>
						<tr>
							<td><font size="3"><font color="#111111" face="verdana,arial,helvetica">Betreff:</font></font></td>
							<td colspan="2"><? $formular->createFieldFor('subject'); ?></td>
						</tr>
						<tr>
							<td><font size="3"><font color="#111111" face="verdana,arial,helvetica">Mitteilung:</font></font></td>
							<td colspan="2"><? $formular->createFieldFor('message'); ?></td>
						</tr>
						<tr>
							<td></td>
							<td><? $formular->createResetButton(); ?></td>
							<td>
								<div align="right">
									<? $formular->createSubmitButton(); ?></div>
							</td>
						</tr>
					</table>
					<? $formular->createEndTag(); ?><? endif; /*end of showing the formular*/ ?></td>
				<td width="1" height="232"><spacer type="block" width="1" height="232"></td>
			</tr>
			<tr height="32">
				<td width="272" height="105" rowspan="2"></td>
				<td width="512" height="32" colspan="2"></td>
				<td width="1" height="32"><spacer type="block" width="1" height="32"></td>
			</tr>
			<tr height="73">
				<td width="512" height="73" colspan="2" valign="top" align="left" xpos="285">
					<table class="dsR21" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td>
								<div align="left">
									<a onmouseover="changeImages('email2','http://oribi-bilder.de/Bilder/Graphiken/email3.gif');return true" onmouseout="changeImages('email2','http://oribi-bilder.de/Bilder/Graphiken/email2.gif');return true" href="mailto:info@oribi.de"><font size="+4" color="#0070ec"><img class="dsR18" src="http://oribi-bilder.de/Bilder/Graphiken/email.gif" alt="" border="0"><img id="email2" src="http://oribi-bilder.de/Bilder/Graphiken/email2.gif" alt="" name="email2" border="0" hspace="15" vspace="3"></font></a></div>
							</td>
						</tr>
					</table>
				</td>
				<td width="1" height="73"><spacer type="block" width="1" height="73"></td>
			</tr>
			<tr height="92">
				<td class="dsR3" cslocked content="content" csheight="92" width="800" height="92" colspan="5" valign="top" xpos="5">
					<div align="center">
						<p>
							<script type="text/javascript"><!--

google_ad_client = "pub-6347946751796321";

google_ad_width = 728;

google_ad_height = 90;

google_ad_format = "728x90_as";

google_ad_type = "text_image";

google_ad_channel = "";

google_color_border = "553c1b";

google_color_bg = "b89a74";

google_color_link = "265586";

google_color_text = "111111";

google_color_url = "265586";

//--></script>
							<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">

</script>
						</p>
					</div>
				</td>
				<td width="1" height="92"><spacer type="block" width="1" height="92"></td>
			</tr>
			<tr height="38">
				<td width="363" height="75" colspan="3" rowspan="2"></td>
				<td width="429" height="38"></td>
				<td width="8" height="75" rowspan="2"></td>
				<td width="1" height="38"><spacer type="block" width="1" height="38"></td>
			</tr>
			<tr height="37">
				<td width="429" height="37" valign="top" align="left" xpos="368"><a href="../index.html" target="_parent"><img class="dsR4" src="http://oribi-bilder.de/Bilder/Graphiken/home-hood.gif" alt="" height="37" width="74" border="0"></a></td>
				<td width="1" height="37"><spacer type="block" width="1" height="37"></td>
			</tr>
			<tr height="1" cntrlrow="cntrlrow">
				<td width="5" height="1"><spacer type="block" width="5" height="1"></td>
				<td width="8" height="1"><spacer type="block" width="8" height="1"></td>
				<td width="272" height="1"><spacer type="block" width="272" height="1"></td>
				<td width="83" height="1"><spacer type="block" width="83" height="1"></td>
				<td width="429" height="1"><spacer type="block" width="429" height="1"></td>
				<td width="8" height="1"><spacer type="block" width="8" height="1"></td>
				<td width="6" height="1"><spacer type="block" width="6" height="1"></td>
				<td width="1" height="1"></td>
			</tr>
		</table>
	</body>
</html>
