<?PHP
	require_once('db.php');

	$edit_mode = false;
	// if this document was referred to with an id, import the correct newsletter to show from the database
	if($_GET[id] != "")
	{
		$query = "select * from newsletters where id='$_GET[id]'";
		$result = mysql_query($query);
		$line = mysql_fetch_array($result);
		$title = $line[title];
		$permalink = $line[id];
		$date = $line[date];
		$headline = $line[headline];
		$ingress = $line[ingress];
		$message_body = $line[body];
	}
	// otherwise, if the document was called with standalone parameters, insert these and activate editing mode
	elseif($_POST[title] != "")
	{
		if($_POST[id] != "")
			$id = $_POST[id];
		$title = $_POST[title];
		$permalink = "";
		if($_POST[date] == "")
			$date = date("Y-m-d");
		else
			$date = $_POST[date];
		$headline = $_POST[headline];
		$ingress = $_POST[ingress];
		$message_body = $_POST[message_body];
		$edit_mode = true;
	}
	// and in all other cases just show a blank version of the document
	else
	{
		$title = "";
		$permalink = "";
		$date = "";
		$headline = ""; 
		$ingress = "";
		$message_body = "";
	}
PHP?>

<html>
<head>
<title><?PHP echo $title; PHP?></title>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
	background-color: #FFFFFF;
}
#Layer1 {
	position:absolute;
	width:589px;
	height:632px;
	z-index:1;
	left: 101px;
	top: 316px;
}
#Layer2 {
	position:absolute;
	width:581px;
	height:999px;
	z-index:1;
	left: 98px;
	top: 361px;
}
.style1 {
	font-family: Arial, Helvetica, sans-serif;
	color: #000000;
}
#Layer3 {
	position:absolute;
	height:115px;
	z-index:2;
	left: 83px;
	top: 30px;
}
.style4 {
	color: #362605;
	font-family: Arial, Helvetica, sans-serif;
}
-->
</style></head>

<?PHP
	if($edit_mode)
	{
		echo "Om sidan ser ut som den ska nedan, klicka på \"spara\" annars klickar du på \"ändra\"<br>\n";
		PHP?>
<form action="newsletter.php" method="post">
<input type="hidden" name="id" value="<?PHP echo $id; PHP?>">
<input type="hidden" name="title" value="<?PHP echo $title; PHP?>">
<input type="hidden" name="headline" value="<?PHP echo $headline; PHP?>">
<input type="hidden" name="date" value="<?PHP echo $date; PHP?>">
<input type="hidden" name="ingress" value="<?PHP echo $ingress; PHP?>">
<input type="hidden" name="message_body" value="<?PHP echo $message_body; PHP?>">
<input type="hidden" name="action" value="save">
<input type="submit" value="spara">
</form>

<form action="newsletter.php" method="post">
<input type="hidden" name="id" value="<?PHP echo $id; PHP?>">
<input type="hidden" name="title" value="<?PHP echo $title; PHP?>">
<input type="hidden" name="headline" value="<?PHP echo $headline; PHP?>">
<input type="hidden" name="date" value="<?PHP echo $date; PHP?>">
<input type="hidden" name="ingress" value="<?PHP echo $ingress; PHP?>">
<input type="hidden" name="message_body" value="<?PHP echo $message_body; PHP?>">
<input type="hidden" name="action" value="edit">
<input type="submit" value="ändra">
</form><br><p>
		<?PHP
	}
PHP?>

<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">
<div id="Layer3">
<p>&nbsp;</p>
<center> <table id="Table_01" border="0" cellpadding="0" cellspacing="0" width="795">
	<tbody><tr>
		<td rowspan="3">
			<img src="mall-filer/nyhetsbrev_01.gif" alt="" height="293" width="35"></td>
		<td colspan="4" rowspan="2">
			<img src="mall-filer/nyhetsbrev_logo.gif" alt="" height="255" width="510"></td>
		<td colspan="2">
			<img src="mall-filer/nyhetsbrev_palm.gif" alt="" height="102" width="198"></td>
		<td rowspan="3">
			<img src="mall-filer/nyhetsbrev_04.gif" alt="" height="293" width="52"></td>
	</tr>
	<tr>
		<td colspan="2">
			<img src="mall-filer/nyhetsbrev_sign.gif" alt="" height="153" width="198"></td>
	</tr>
	<tr>
		<td colspan="3">
			<img src="mall-filer/nyhetsbrev_datum070327.gif" alt="" height="38" width="306"></td>
		<td colspan="3">
			<img src="mall-filer/nyhetsbrev_07.gif" alt="" height="38" width="402"></td>
	</tr>
	<tr>
		<td colspan="8"><img src="mall-filer/nyhetsbrev_top.gif" alt="" height="49" width="795"></td>
	</tr>
	<tr>
		<td colspan="2">
			<img src="mall-filer/nyhetsbrev_vansterhorn.gif" alt="" height="102" width="91"></td>
		<td colspan="4" rowspan="2" bgcolor="#f5e48c" valign="top"><p>&nbsp;</p>      </td>
		<td colspan="2">
			<img src="mall-filer/nyhetsbrev_hogerhorn.gif" alt="" height="102" width="116"></td>
	</tr>
	<tr>
		<td colspan="2">
			<img src="mall-filer/nyhetsbrev_vanster.gif" alt="" height="402" width="91"><br>
			<img src="mall-filer/nyhetsbrev_vanster.gif" alt="s" height="402" width="91"></td>
		<td colspan="2"><img src="mall-filer/nyhetsbrev_hoger.gif" alt="" height="402" width="116"><br>
	    <img src="mall-filer/nyhetsbrev_hoger.gif" alt="" height="402" width="116"></td>
	</tr>
	<tr>
		<td colspan="3" rowspan="2">
			<img src="mall-filer/nyhetsbrev_nervanster.gif" alt="" height="153" width="181"></td>
		<td colspan="3">
		<img src="mall-filer/nyhetsbrev_15.gif" alt="" height="98" width="498"></td>
		<td colspan="2" rowspan="2">
			<img src="mall-filer/nyhetsbrev_nerhoger.gif" alt="" height="153" width="116"></td>
	</tr>
	<tr>
		<td colspan="3">
			<img src="mall-filer/nyhetsbrev_ner.gif" alt="" height="55" width="498"></td>
	</tr>
	<tr>
		<td>
			<img src="mall-filer/spacer.gif" alt="" height="1" width="35"></td>
		<td>
			<img src="mall-filer/spacer.gif" alt="" height="1" width="56"></td>
		<td>
			<img src="mall-filer/spacer.gif" alt="" height="1" width="90"></td>
		<td>
			<img src="mall-filer/spacer.gif" alt="" height="1" width="160"></td>
		<td>
			<img src="mall-filer/spacer.gif" alt="" height="1" width="204"></td>
		<td>
			<img src="mall-filer/spacer.gif" alt="" height="1" width="134"></td>
		<td>
			<img src="mall-filer/spacer.gif" alt="" height="1" width="64"></td>
		<td>
			<img src="mall-filer/spacer.gif" alt="" height="1" width="52"></td>
	</tr>
</tbody></table>
</center>

 <div id="Layer2">
   <h1 class="style4"><?PHP echo $headline; PHP?></h1>
   <h3 class="style4"><?PHP echo $ingress; PHP?></h3>
   <p class="style4"><?PHP echo $message_body; PHP?></p>
 </div>
</div>
 <!-- sluta Skriv här -->
</body></html>
