<?php
session_name("s".base64_decode($_COOKIE[register]));
session_start ();
$sesspass = "base64_decode($_COOKIE[register])";
if (session_id() == "" and $_SESSION[$sesspass] != session_id()) 
{
	session_unset ();
	session_destroy ();
	header ("location: ../index.php?n=503");
}
if (!session_is_registered("s".base64_decode($_COOKIE[register]))) 
{
	session_unset ();
	session_destroy ();
	header ("location: ../index.php?n=503");
}

if ($_POST[submit]){
	require "engine/actions.php";
	$pageimages = pimages($_POST[image1],$_POST[image2],$_POST[image3],$_POST[image4],$_POST[image5],$_POST[image6]);
	$_POST[actions]($_POST[pagetitle],$_POST[pageid],$_POST[pagetype],$_POST[pageorder],$_POST[pageparent],$_POST[pagekeywords],$_POST[pagedescription],$_POST[pagecontent],$pageimages,$_POST[pagelog]);
	rss();
	sitemap();
}
?>
<script type="text/javascript">
function MM_setTextOfTextfield(objId,x,newText) { //v9.0
  with (document){ if (getElementById){
    var obj = getElementById(objId);} if (obj) obj.value = newText;
  }
}
</script>


<h1><?php echo $l[newpage];?> </h1>
<form action="<?php echo $_SERVER['PHP_SELF']."?a=".$_GET[a];?>" method="post" name="newpage" id="newpage" class="form">

 			  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
 			    <tr>
 			      <td colspan="2">
				<?php echo $l[pagetitle];?>: 
                  <abbr title="<?php echo $l[pagetitlenote];?>">[?]</abbr></td>
		        </tr>
 			    <tr>
 			      <td colspan="2"><input id="pagetitle" name="pagetitle" class="validate[required,length[2,256]] field"  style="width:99%; font-size:1.3em"/></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><?php echo $l[pageid];?>: <abbr title="<?php echo $l[pageidnote];?>">[?] </abbr></td>
 			      <td align="left"><?php echo $l[pagetype];?>: <abbr title="<?php echo $l[pagetypenote];?>">[?]</abbr></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><input name="pageid" class="validate[required,custom[pageID],length[1,256],ajax[ajaxID]] field" id="pageid" style="width:99%;" value="<?php pageid();?>"/></td>
 			      <td align="left"><select name="pagetype" class="field" id="pagetype" onchange="swapPreview();">
 			        <optgroup label="Mixed">
 			          <option value="mixed|left"><?php echo $l[mixedleft];?></option>
 			          <option value="mixed|right"><?php echo $l[mixedright];?></option>
		            </optgroup>
 			        <optgroup label="Gallery">
 			          <option value="gallery|top"><?php echo $l[gallerytop];?></option>
 			          <option value="gallery|bottom"><?php echo $l[gallerybottom];?></option>
		            </optgroup>
 			        <optgroup label="List">
 			          <option value="list|none"><?php echo $l[listtop];?></option>
		            </optgroup>
		          </select></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><?php echo $l[pageorder];?>: <abbr title="<?php echo $l[pageordernote];?>">[?]</abbr>
                    <select name="pageorder" id="pageorder" class="field">
                      <option value="0" selected>0</option>
                      <option value="1">1</option>
                      <option value="2">2</option>
                      <option value="3">3</option>
                      <option value="4">4</option>
                      <option value="5">5</option>
                      <option value="6">6</option>
                      <option value="7">7</option>
                      <option value="8">8</option>
                      <option value="9">9</option>
                    </select>
<?php echo $l[parentpage];?>: <abbr title="<?php echo $l[parentpagenote];?>">[?]</abbr>
<select name="pageparent" id="pageparent" class="field">
  <option value=""><?php echo $l[none];?></option>
  <?php
                              $parents = glob("../data/*.page.php");
                              sort ($parents);
                              foreach ($parents as $parent){
                                  require $parent;
                                  echo "<option value=\"".$page[id]."\">".$page[title]."</option>";
                              }
                              ?>
</select></td>
 			      <td align="left"><?php echo $l[preview];?></td>
		        </tr>
 			    
 			    <tr>
 			      <td width="70%" align="left"><?php echo $l[keywords]; ?> <em>(<?php echo $l[commaseparated];?>)</em>: <abbr title="<?php echo $l[keywordsnote];?>">[?]</abbr></td>
 			      <td rowspan="4" align="left" valign="top"><img id="preview" src="style/mixed_left.png" width="296" height="176" />
                  
                  </td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><input type="text" name="pagekeywords" id="pagekeywords" class="field" style="width:99%;"/></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left"><?php echo $l[description];?>: <abbr title="<?php echo $l[descriptionnote];?>">[?]</abbr></td>
		        </tr>
 			    <tr>
 			      <td width="70%" align="left" valign="top"><textarea name="pagedescription" id="pagedescription" rows="5" style="width:99%;" class="field"></textarea></td>
		        </tr>
 			    <tr>
 			      <td colspan="2"><?php echo $l[content];?>: <abbr title="<?php echo $l[contentnote];?>">[?]</abbr></td>
		        </tr>
 			    <tr>
 			      <td colspan="2" align="left"><textarea name="pagecontent" id="pagecontent" style="width:99%; height:250px;" class="tinymce"></textarea></td>
		        </tr>
 			    <tr>
 			      <td colspan="2">&nbsp;</td>
		        </tr>
 			    <tr>
 			      <td colspan="2"><?php echo $l[images];?> <abbr title="<?php echo $l[imagesnote];?>">[?]</abbr>
</td>
		        </tr>
 			    <tr>
 			      <td colspan="2"><table width="100%" border="0" cellspacing="2" cellpadding="0">
 			        <tr>
 			          <td align="left" valign="middle"><input name="image1" type="text" class="fieldimage" id="image1" onclick="browse('inc/gallerybrowser.php?f=1&amp;d=newpage','Gallery browser','800','600')" readonly="readonly" />
 			            <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image1','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
 			          <td align="left" valign="middle"><input name="image2" type="text" class="fieldimage" id="image2" onclick="browse('inc/gallerybrowser.php?f=2&amp;d=newpage','Gallery browser','800','600')" readonly="readonly" />
 			            <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image2','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
 			          <td align="left" valign="middle"><input name="image3" type="text" class="fieldimage" id="image3" onclick="browse('inc/gallerybrowser.php?f=3&amp;d=newpage','Gallery browser','800','600')" readonly="readonly" />
 			            <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image3','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
		            </tr>
 			        <tr>
 			          <td align="left" valign="middle"><input name="image4" type="text" class="fieldimage" id="image4" onclick="browse('inc/gallerybrowser.php?f=4&amp;d=newpage','Gallery browser','800','600')" readonly="readonly" />
 			            <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image4','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
 			          <td align="left" valign="middle"><input name="image5" type="text" class="fieldimage" id="image5" onclick="browse('inc/gallerybrowser.php?f=5&amp;d=newpage','Gallery browser','800','600')" readonly="readonly" />
 			            <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image5','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
 			          <td align="left" valign="middle"><input name="image6" type="text" class="fieldimage" id="image6" onclick="browse('inc/gallerybrowser.php?f=6&amp;d=newpage','Gallery browser','800','600')" readonly="readonly" />
 			            <a href="javascript:void(0);" onclick="MM_setTextOfTextfield('image6','','')"><img src="style/remove.png" width="24" height="24" border="0" align="texttop" /></a></td>
		            </tr>
		          </table></td>
		        </tr>
 			    <tr>
 			      <td colspan="2" align="left"><input name="submit" type="hidden" id="submit" value="true" />
 			        <input name="pagelog" type="hidden" id="pagelog" value="<?php echo date("r");?>" />
		          <input name="actions" type="hidden" id="actions" value="newpage" /></td>
		        </tr>
 			    <tr>
 			      <td colspan="2" align="center"><input type="reset" name="button2" id="button2" value="<?php echo $l[cancelandreset];?>" onclick="$.validationEngine.closePrompt('.formError',true)" class="cancel"/> 			        <input type="submit" name="button" id="button" value="<?php echo $l[save];?>" class="save" /></td>
		        </tr>
 			    <tr>
 			      <td colspan="2" align="center">&nbsp;</td>
		        </tr>

  </table>
</form>

