<?php

/*  Alternate WebKit
(C) 2011-2015 by Alternate Tools
-----------------------------------------------------

File:         edit_pages.php
Description:  Administrative module to edit pages or create new ones

*/

    include "../modules/class_page.php";
    include "../modules/class_pagelist.php";
    include "../modules/class_theme.php";
    include "../modules/mod_admin.php";

    $b_NotFinished = true;
    $b_ErrorOccured = false;
    $pageId = "";
    $errorString = "";

    // Check privileges
    check_login();
    if (user_is_customer() == true)
    {
        log_out();
        return;
    }
    if (user_is_reporter() == true)
    {
        header("location: " . $ADMIN_MAIN_SITE);
        return;
    }

    // Check action
    $pageEdtAction = "new";
    if (isset ($_POST['page_EdtAction']) == true)
    {
        if ($_POST['page_EdtAction'] == "edit")
            $pageEdtAction = "edit";
    }
    else if (isset ($_GET['action']) == true)
    {
        if ($_GET['action'] == "edit")
            $pageEdtAction = "edit";
    }

    $pagePage = new cPage;
    $pagePage->SetFolder($PAGES_FOLDER);
    $pagePreset = new cPage;
    $pagePreset->SetFolder($PAGES_FOLDER);
    $thmTheme = new cTheme;
    $thmTheme->SetFolder($THEME_FOLDER);
	$pageList = new cPageList;
	$pageList->SetFolder($PAGES_FOLDER);
    $pageList->LoadPageList(0);
    $pageList->SortPageList(4); // Sort by position
    $listOfPages = $pageList->GetPageList();

    if ($pageEdtAction == "edit")  // Edit -> load it
    {
        if (isset ($_POST['page_id']) == true)
            $pageId = $_POST['page_id'];
        else if (isset ($_GET['id']) == true)
            $pageId = $_GET['id'];
        if ($pagePage->LoadPageFromId($pageId) == false)
        {
            print_error_message(get_translation('admin_pageedt_errorload') . ', ID: ' . $pageId);
            return;
        }
    }

    // Page reset views?
    if (isset ($_POST['page_ResetViews']))
    {
        if ($pagePage->ResetViewCount() == false)
            $errorString = get_translation('admin_pageedt_errorsave') . '!';
        else
        {
            header('location: ' . $ADMIN_LIST_PAGES_SITE);
            return;
        }
    }
    // Page edit cancelled?
    if (isset ($_POST['page_Cancel']))
    {
        header('location: ' . $ADMIN_LIST_PAGES_SITE);
        return;
    }

    // Check for errors and if none, store the page values
    if (isset ($_POST['page_Save']))
    {
		if (isset($_POST['page_Type']) == false || $_POST['page_Type'] == "")
            $_POST['page_Type'] = PAGETYPE_PLAIN;
        if (isset($_POST['page_Title']) == false || $_POST['page_Title'] == "")
        {
            $errorString = get_translation('admin_pageedt_errorinput') . ': ' . get_translation('admin_page_title') . '!';
            $b_ErrorOccured = true;
        }
        else if (isset($_POST['page_NavTitle']) == false || $_POST['page_NavTitle'] == "")
        {
            $errorString = get_translation('admin_pageedt_errorinput') . ': ' . get_translation('admin_page_navtitle') . '!';
            $b_ErrorOccured = true;
        }
		if (isset($_POST['page_NavTitleNormal']) == false)
		    $_POST['page_NavTitleNormal'] = ""; // Not mandatory, can be empty
		if (isset($_POST['page_NavTitleActive']) == false)
		    $_POST['page_NavTitleActive'] = ""; // Not mandatory, can be empty
        if (isset($_POST['page_NavPosition']) == false || $_POST['page_NavPosition'] == "")
            $_POST['page_NavPosition'] = "0";
        if (isset($_POST['page_NavLevel']) == false || $_POST['page_NavLevel'] == "")
            $_POST['page_NavLevel'] = "0";
        if (isset($_POST['page_ShowNavLevel']) == false || $_POST['page_ShowNavLevel'] == "")
            $_POST['page_ShowNavLevel'] = "";

        if (isset($_POST['page_Type']) == false || $_POST['page_Type'] == "")
            $_POST['page_Type'] = PAGETYPE_PLAIN;
        if ($_POST['page_Type'] == PAGETYPE_LINK)
        {
            if (isset($_POST['page_Link']) == false || $_POST['page_Link'] == "")
            {
                $errorString = get_translation('admin_pageedt_errorinput') . ': ' . get_translation('admin_page_link') . '!';
                $b_ErrorOccured = true;
            }
        }
        

        if ($b_ErrorOccured == false)
        {
            // If done, fill the rest of the parameters
            if ($pageEdtAction == "new")    // New -> create Id first
            {
                $pagePage->SetFolder($PAGES_FOLDER);
                $pagePage->CreatePage(get_user_name(), $_POST['page_Type']);
                // Gallery?
                if ($_POST['page_Type'] == PAGETYPE_GALLERY)
                    $pagePage->AssignGallery($GALLERIES_FOLDER);
                // YouTube Gallery?
                if ($_POST['page_Type'] == PAGETYPE_YOUTUBEGALLERY)
                    $pagePage->AssignGallery($GALLERIES_FOLDER);
                // Link list?
                if ($_POST['page_Type'] == PAGETYPE_LINKS)
                    $pagePage->AssignGallery($GALLERIES_FOLDER);
                // Form?
                if ($_POST['page_Type'] == PAGETYPE_FORM)
                    $pagePage->AssignGallery($FORM_FOLDER);
                // Guestbook?
                if ($_POST['page_Type'] == PAGETYPE_GUESTBOOK)
                    $pagePage->SetAdditionalFolder($GUESTBOOK_FOLDER);
                $pagePage->SetType($_POST['page_Type']);  // Page type selectable for new pages
            }
            $pagePage->SetTitle($_POST['page_Title']);
            $pagePage->SetNavigationTitle($_POST['page_NavTitle']);
            $pagePage->SetNavigationTitleNormal($_POST['page_NavTitleNormal']);
            $pagePage->SetNavigationTitleActive($_POST['page_NavTitleActive']);
            $pagePage->SetAdditionalContent($_POST['page_AdditionalContent']);
            $pagePage->SetNavigationPosition($_POST['page_NavPosition']);
            $pagePage->SetNavigationLevel($_POST['page_NavLevel']);
            $pagePage->SetNavigationShowLevel($_POST['page_ShowNavLevel']);
            $pagePage->SetContentPosition($_POST['page_ContentPosition']);
            $pagePage->SetThemeFile($_POST['page_TemplateFile']);

            // Link?
            if ($_POST['page_Type'] == PAGETYPE_LINK)
                $pagePage->SetLink($_POST['page_Link']);
            // Form
            if ($_POST['page_Type'] == PAGETYPE_FORM)
            {
                if (isset($_POST['page_FormCount']) == false || $_POST['page_FormCount'] == "" || is_numeric($_POST['page_FormCount']) == false)  // default it
                    $_POST['page_FormCount'] = $FORM_DEFNUM;
                $pagePage->SetAdditionalRowCount($_POST['page_FormCount']);
                if ($pageEdtAction == "new")    // New?
                    $pagePage->m_cForm->SetMaxFields($_POST['page_FormCount']);
                else
                    $pagePage->m_cForm->ResizeMaxFields($_POST['page_FormCount']);
            }
            // Gallery?
            if ($_POST['page_Type'] == PAGETYPE_GALLERY)
            {
                if (isset($_POST['page_GalleryCols']) == false || $_POST['page_GalleryCols'] == "" || is_numeric($_POST['page_GalleryCols']) == false)  // default it
                    $_POST['page_GalleryCols'] = $GALLERYIMAGES_DEFCOLS;
                $pagePage->SetAdditionalColCount($_POST['page_GalleryCols']);
                if (isset($_POST['page_GalleryAlign']) == false || $_POST['page_GalleryAlign'] == "")  // default it
                    $_POST['page_GalleryAlign'] = $GALLERYIMAGES_DEFALIGN;
                $pagePage->SetAdditionalParameter($_POST['page_GalleryAlign']);
                if (isset($_POST['page_GalleryTextAlign']) == false || $_POST['page_GalleryTextAlign'] == "")  // default it
                    $_POST['page_GalleryTextAlign'] = $GALLERYIMAGES_DEFTEXTALIGN;
                $pagePage->SetAdditionalParameter2($_POST['page_GalleryTextAlign']);
                if (isset($_POST['page_GalleryAutoSize']) == false || $_POST['page_GalleryAutoSize'] == "")  // default it
                    $_POST['page_GalleryAutoSize'] = $GALLERYIMAGES_SIZE_AUTO;
                $pagePage->SetAdditionalParameter3($_POST['page_GalleryAutoSize']);
                if (isset($_POST['page_GalleryCount']) == false || $_POST['page_GalleryCount'] == "" || is_numeric($_POST['page_GalleryCount']) == false)  // default it
                    $_POST['page_GalleryCount'] = $GALLERYIMAGES_DEFNUM;
                $pagePage->SetAdditionalRowCount($_POST['page_GalleryCount']);
                if (isset($_POST['page_GalleryImgWidth']) == false || $_POST['page_GalleryImgWidth'] == "" || is_numeric($_POST['page_GalleryImgWidth']) == false)  // default it
                    $_POST['page_GalleryImgWidth'] = $GALLERYIMAGES_DEFWIDTH;
                $pagePage->SetAdditionalImgWidth($_POST['page_GalleryImgWidth']);
                if (isset($_POST['page_GalleryImgHeight']) == false || $_POST['page_GalleryImgHeight'] == "" || is_numeric($_POST['page_GalleryImgHeight']) == false)  // default it
                    $_POST['page_GalleryImgHeight'] = $GALLERYIMAGES_DEFHEIGHT;
                $pagePage->SetAdditionalImgHeight($_POST['page_GalleryImgHeight']);
                if (isset($_POST['page_GalleryThumbWidth']) == false || $_POST['page_GalleryThumbWidth'] == "" || is_numeric($_POST['page_GalleryThumbWidth']) == false)  // default it
                    $_POST['page_GalleryThumbWidth'] = $GALLERYIMAGES_THUMB_DEFWIDTH;
                $pagePage->SetAdditionalThumbWidth($_POST['page_GalleryThumbWidth']);
                if (isset($_POST['page_GalleryThumbHeight']) == false || $_POST['page_GalleryThumbHeight'] == "" || is_numeric($_POST['page_GalleryThumbHeight']) == false)  // default it
                    $_POST['page_GalleryThumbHeight'] = $GALLERYIMAGES_THUMB_DEFHEIGHT;
                $pagePage->SetAdditionalThumbHeight($_POST['page_GalleryThumbHeight']);
                if ($pageEdtAction == "new")    // New?
                    $pagePage->m_cGallery->SetMaxImages($_POST['page_GalleryCount']);
                else
                    $pagePage->m_cGallery->ResizeMaxImages($_POST['page_GalleryCount']);
            }
            // YouTube Gallery?
            if ($_POST['page_Type'] == PAGETYPE_YOUTUBEGALLERY)
            {
                if (isset($_POST['page_YouTubeGalleryCols']) == false || $_POST['page_YouTubeGalleryCols'] == "" || is_numeric($_POST['page_YouTubeGalleryCols']) == false)  // default it
                    $_POST['page_YouTubeGalleryCols'] = $YOUTUBEGALLERY_DEFCOLS;
                $pagePage->SetAdditionalColCount($_POST['page_YouTubeGalleryCols']);
                if (isset($_POST['page_YouTubeGalleryAlign']) == false || $_POST['page_YouTubeGalleryAlign'] == "")  // default it
                    $_POST['page_YouTubeGalleryAlign'] = $YOUTUBEGALLERY_DEFALIGN;
                $pagePage->SetAdditionalParameter($_POST['page_YouTubeGalleryAlign']);
                if (isset($_POST['page_YouTubeGalleryTextAlign']) == false || $_POST['page_YouTubeGalleryTextAlign'] == "")  // default it
                    $_POST['page_YouTubeGalleryTextAlign'] = $YOUTUBEGALLERY_DEFTEXTALIGN;
                $pagePage->SetAdditionalParameter2($_POST['page_YouTubeGalleryTextAlign']);
                if (isset($_POST['page_YouTubeGalleryCount']) == false || $_POST['page_YouTubeGalleryCount'] == "" || is_numeric($_POST['page_YouTubeGalleryCount']) == false)  // default it
                    $_POST['page_YouTubeGalleryCount'] = $YOUTUBEGALLERY_DEFNUM;
                $pagePage->SetAdditionalRowCount($_POST['page_YouTubeGalleryCount']);
                if (isset($_POST['page_YouTubeGalleryVideoWidth']) == false || $_POST['page_YouTubeGalleryVideoWidth'] == "" || is_numeric($_POST['page_YouTubeGalleryVideoWidth']) == false)  // default it
                    $_POST['page_YouTubeGalleryVideoWidth'] = $YOUTUBEGALLERY_DEFWIDTH;
                $pagePage->SetAdditionalImgWidth($_POST['page_YouTubeGalleryVideoWidth']);
                if (isset($_POST['page_YouTubeGalleryVideoHeight']) == false || $_POST['page_YouTubeGalleryVideoHeight'] == "" || is_numeric($_POST['page_YouTubeGalleryVideoHeight']) == false)  // default it
                    $_POST['page_YouTubeGalleryVideoHeight'] = $YOUTUBEGALLERY_DEFHEIGHT;
                $pagePage->SetAdditionalImgHeight($_POST['page_YouTubeGalleryVideoHeight']);
                if ($pageEdtAction == "new")    // New?
                    $pagePage->m_cYouTubeGallery->SetMaxYVideos($_POST['page_YouTubeGalleryCount']);
                else
                    $pagePage->m_cYouTubeGallery->ResizeMaxYVideos($_POST['page_YouTubeGalleryCount']);
            }
            // Link list?
            if ($_POST['page_Type'] == PAGETYPE_LINKS)
            {
                if (isset($_POST['page_LinkListCols']) == false || $_POST['page_LinkListCols'] == "" || is_numeric($_POST['page_LinkListCols']) == false)  // default it
                    $_POST['page_LinkListCols'] = $LINKLIST_DEFCOLS;
                $pagePage->SetAdditionalColCount($_POST['page_LinkListCols']);
                if (isset($_POST['page_LinkListAlign']) == false || $_POST['page_LinkListAlign'] == "")  // default it
                    $_POST['page_LinkListAlign'] = $LINKLIST_DEFALIGN;
                $pagePage->SetAdditionalParameter($_POST['page_LinkListAlign']);
                if (isset($_POST['page_LinkListTextAlign']) == false || $_POST['page_LinkListTextAlign'] == "")  // default it
                    $_POST['page_LinkListTextAlign'] = $LINKLIST_DEFTEXTALIGN;
                $pagePage->SetAdditionalParameter2($_POST['page_LinkListTextAlign']);
                if (isset($_POST['page_LinkListCount']) == false || $_POST['page_LinkListCount'] == "" || is_numeric($_POST['page_LinkListCount']) == false)  // default it
                    $_POST['page_LinkListCount'] = $LINKLIST_DEFNUM;
                $pagePage->SetAdditionalRowCount($_POST['page_LinkListCount']);
                if ($pageEdtAction == "new")    // New?
                    $pagePage->m_cLinkList->SetMaxLinks($_POST['page_LinkListCount']);
                else
                    $pagePage->m_cLinkList->ResizeMaxLinks($_POST['page_LinkListCount']);
            }
            // Text align for contact, guestbook, form, search
            if ($_POST['page_Type'] == PAGETYPE_CONTACT || $_POST['page_Type'] == PAGETYPE_FORM || $_POST['page_Type'] == PAGETYPE_SEARCH || $_POST['page_Type'] == PAGETYPE_GUESTBOOK || $_POST['page_Type'] == PAGETYPE_NEWSLETTER)
            {
                if (isset($_POST['page_FormTextAlign']) == false || $_POST['page_FormTextAlign'] == "")  // default it
                    $_POST['page_FormTextAlign'] = $FORM_DEFTEXTALIGN;
                $pagePage->SetAdditionalParameter2($_POST['page_FormTextAlign']);
            }
            $pagePage->SetShowInNavigation(isset($_POST['page_ShowInNavigation']));
            $pagePage->SetMainPage(isset($_POST['page_IsMainPage']));
            $pagePage->SetDeleteProtected(isset($_POST['page_DeleteProtected']));
            if ($pagePage->SavePage(get_user_name()) == false)
            {
                if ($pageEdtAction == "new")
                    $errorString = get_translation('admin_pageedt_errorcreate') . '!';
                else
                    $errorString = get_translation('admin_pageedt_errorsave') . '!';
                $b_ErrorOccured = true;
            }
            else
            {
                if ($pageEdtAction == "edit")
                {
                    // Page is saved.
                    log_message ('User ' . get_user_name() . ' saved page ' . $pagePage->GetId());
                    header ('Location: ' . $ADMIN_LIST_PAGES_SITE);
                    return;
                }
                else
                    log_message ('User ' . get_user_name() . ' created page ' . $pagePage->GetId());

                $b_NotFinished = false;
            }
        }
    }

    // Display the input dialog for edit page
    $titleString = get_translation('admin_pageedt_newhead');
    if ($pageEdtAction == "edit")  // Edit
        $titleString = get_translation('admin_pageedt_edithead');
    print_admin_header($titleString, true, get_translation('admin_login_logout'), "", true, get_translation('admin_backtomain'),
                       $ADMIN_LIST_PAGES_SITE, get_translation('admin_overview'), false);
    echo_r('<script language="JavaScript" type="Text/JavaScript">');
    echo_r('function changePageType(pageType)');
    echo_r('{');
    echo_r('  document.getElementById(\'pageLink\').style.display = \'none\';');
    echo_r('  if (pageType == ' . PAGETYPE_LINK .  ')');
    echo_r('    document.getElementById(\'pageLink\').style.display = \'\';');
    echo_r('  document.getElementById(\'pageGallery\').style.display = \'none\';');
    echo_r('  if (pageType == ' . PAGETYPE_GALLERY .  ')');
    echo_r('    document.getElementById(\'pageGallery\').style.display = \'\';');
    echo_r('  document.getElementById(\'pageYouTubeGallery\').style.display = \'none\';');
    echo_r('  if (pageType == ' . PAGETYPE_YOUTUBEGALLERY .  ')');
    echo_r('    document.getElementById(\'pageYouTubeGallery\').style.display = \'\';');
    echo_r('  document.getElementById(\'pageLinkList\').style.display = \'none\';');
    echo_r('  if (pageType == ' . PAGETYPE_LINKS .  ')');
    echo_r('    document.getElementById(\'pageLinkList\').style.display = \'\';');
    echo_r('  document.getElementById(\'pageForm\').style.display = \'none\';');
    echo_r('  if (pageType == ' . PAGETYPE_FORM .  ')');
    echo_r('    document.getElementById(\'pageForm\').style.display = \'\';');
    echo_r('  document.getElementById(\'pageFormTextAlign\').style.display = \'none\';');
    echo_r('  if (pageType == ' . PAGETYPE_CONTACT .  ' || pageType == ' . PAGETYPE_FORM . ' || pageType == ' . PAGETYPE_SEARCH . ' || pageType == ' . PAGETYPE_GUESTBOOK . ' || pageType == ' . PAGETYPE_NEWSLETTER . ')');
    echo_r('    document.getElementById(\'pageFormTextAlign\').style.display = \'\';');
    echo_r('}');
    echo_r('function changePageNavLevel(navLevel)');
    echo_r('{');
    echo_r('  if (navLevel != \'\') document.getElementById(\'pageNavLevel\').value = navLevel;');
    echo_r('}');
    echo_r('function changePageShowNavLevel(showNavLevel)');
    echo_r('{');
    echo_r('  document.getElementById(\'pageShowNavLevel\').value = showNavLevel;');
    echo_r('}');

    echo_r('</script>');
    finish_admin_header($titleString, true, get_translation('admin_login_logout'), "", true, get_translation('admin_backtomain'),
                       $ADMIN_LIST_PAGES_SITE, get_translation('admin_overview'));
    if ($errorString !="")
        print_error_message($errorString);

    if ($b_NotFinished == false)
    {
        // Page is created. Display form to create another or go back to page list
        echo_r('<p>' . get_translation('admin_pageedt_pagecreated') . ', ID : <a href="' . $ADMIN_EDIT_PAGECONTENTS_SITE . '?id=' . $pagePage->GetId() . '&action=edit">' . $pagePage->GetId() . '</a><br></p>');
        print_bottom_links("page_New", get_translation('admin_pageedt_createanother'),
                           "page_Cancel", get_translation('admin_ok'), true);
       return;
    }

    echo_r('<form action="' . $_SERVER['PHP_SELF'] . '" method="post" enctype="multipart/form-data">');
    if ($b_NotFinished == true)
    {
        echo_r('<table width="100%">');
        if ($pageEdtAction == "edit")  // Edit
        {
            echo_r('  <tr>');
            echo_r('    <td>' . get_translation('admin_page_id') . ':</td>');
            echo_r('    <td><b>' . $pagePage->GetId() . '</b>');
            echo_r('      <input type="hidden" value="' .  $pagePage->GetId() . '" name="page_id">  ');
            echo_r('    </td>');
            echo_r('  </tr>');
            echo_r('  <tr>');
            echo_r('    <td>' . get_translation('admin_page_created') . ':</td>');
            echo_r('    <td><b>' . $pagePage->GetDate() . ' (' . $pagePage->GetCreatedBy() . ')</b></td>');
            echo_r('  </tr>');
            echo_r('  <tr>');
            echo_r('    <td>' . get_translation('admin_page_modified') . ':</td>');
            echo_r('    <td><b>' . $pagePage->GetModified() . ' (' . $pagePage->GetAuthor() . ')</b></td>');
            echo_r('  </tr>');
            echo_r('  <tr>');
            echo_r('    <td>' . get_translation('admin_page_viewcount') . ':</td>');
            echo_r('    <td><b>' . $pagePage->GetViewCount() . '</b>');
            echo_r('    &nbsp;&nbsp;&nbsp;<input class="bottom_btn" type="submit" name="page_ResetViews" value="' . get_translation('admin_reset') . '">');
            echo_r('    </td>');
            echo_r('  </tr>');
        }
        echo_r('  <tr>');
        // Title
        echo_r('    <td width="30%">' . get_translation('admin_page_title') . ':</td>');
        if (isset($_POST['page_Title']))
            echo_r('    <td><input type="text" name="page_Title" size="60" value="' . $_POST['page_Title'] . '"></td>');
        else
            echo_r('    <td><input type="text" name="page_Title" size="60" value="' .  $pagePage->GetTitle() . '"></td>');
        echo_r('  </tr>');
        // Navigation title
        echo_r('  <tr>');
        echo_r('    <td width="30%">' . get_translation('admin_page_navtitle') . ':</td>');
        if (isset($_POST['page_NavTitle']))
            echo_r('    <td><input type="text" name="page_NavTitle" size="60" value="' . $_POST['page_NavTitle'] . '"></td>');
        else
            echo_r('    <td><input type="text" name="page_NavTitle" size="60" value="' .  $pagePage->GetNavigationTitle() . '"></td>');
        echo_r('  </tr>');
        if ($ADMIN_SPECIALNAVIGATION == true)
        {
        	// Navigation title normal value
        	echo_r('  <tr>');
        	echo_r('    <td width="30%">' . get_translation('admin_page_navtitlenormal') . ':</td>');
        	if (isset($_POST['page_NavTitleNormal']))
            	echo_r('    <td><input type="text" name="page_NavTitleNormal" size="5" value="' . $_POST['page_NavTitleNormal'] . '"></td>');
        	else
            	echo_r('    <td><input type="text" name="page_NavTitleNormal" size="5" value="' .  $pagePage->GetNavigationTitleNormal() . '"></td>');
        	echo_r('  </tr>');
        	// Navigation title active value
        	echo_r('  <tr>');
        	echo_r('    <td width="30%">' . get_translation('admin_page_navtitleactive') . ':</td>');
        	if (isset($_POST['page_NavTitleActive']))
            	echo_r('    <td><input type="text" name="page_NavTitleActive" size="5" value="' . $_POST['page_NavTitleActive'] . '"></td>');
        	else
            	echo_r('    <td><input type="text" name="page_NavTitleActive" size="5" value="' .  $pagePage->GetNavigationTitleActive() . '"></td>');
        	echo_r('  </tr>');
       	}
       	else
       	{
            echo_r('  <input type="hidden" name="page_NavTitleNormal" value="' .  $pagePage->GetNavigationTitleNormal() . '">');
            echo_r('  <input type="hidden" name="page_NavTitleActive" value="' .  $pagePage->GetNavigationTitleActive() . '">');
       	}
        // Additonal content
        if ($ADMIN_ADDITONALCONTENT == true)
        {
            echo_r('  <tr>');
            echo_r('    <td width="30%">' . get_translation('admin_page_additionalcontent') . ':</td>');
            if (isset($_POST['page_AdditionalContent']))
                echo_r('    <td><input type="text" name="page_AdditionalContent" size="80" value="' . $_POST['page_AdditionalContent'] . '"></td>');
            else
                echo_r('    <td><input type="text" name="page_AdditionalContent" size="80" value="' .  $pagePage->GetAdditionalContent() . '"></td>');
            echo_r('  </tr>');
        }
        else
        {
            echo_r('  <input type="hidden" name="page_AdditionalContent" value="' .  $pagePage->GetAdditionalContent() . '">');
        }
        // Navigation level
        echo_r('  <tr>');
        echo_r('    <td width="30%">' . get_translation('admin_page_navlevel') . ':</td>');
        if (isset($_POST['page_NavLevel']))
            echo_r('    <td><input type="text" name="page_NavLevel" id="pageNavLevel" size="5" value="' . $_POST['page_NavLevel'] . '">');
        else
            echo_r('    <td><input type="text" name="page_NavLevel" id="pageNavLevel" size="5" value="' .  $pagePage->GetNavigationLevel() . '">');
		echo_r('    ' . get_translation('admin_presets') . ': <select name="page_NavLevelPreset" id="pageNavLevelPreset" onChange="changePageNavLevel(document.getElementById(\'pageNavLevelPreset\').value)">');
		echo_r('    <option value=""></option>');
    	foreach ($listOfPages as $value)
		{
			if ($pagePreset->LoadPageFromId($value) == true)
			{
				$strPresetTitle = $pagePreset->GetNavigationTitle() . ' - ' . $pagePreset->GetTitle();
				if (strlen($strPresetTitle) > 50)
     				$strPresetTitle = substr($strPresetTitle, 0, 50) . "...";
				echo_r('    <option value="' . $pagePreset->GetNavigationLevel() . '">' . $pagePreset->GetNavigationLevel() . ' [ ' . $pagePreset->GetNavigationPosition() . '] (' . $strPresetTitle . ')</option>');
			}
		}
		echo_r('	</select>');
		echo_r('	</td>');
        echo_r('  </tr>');
        // Navigation position
        echo_r('  <tr>');
        echo_r('    <td width="30%">' . get_translation('admin_page_navposition') . ':</td>');
        if (isset($_POST['page_NavPosition']))
            echo_r('    <td><input type="text" name="page_NavPosition" size="5" value="' . $_POST['page_NavPosition'] . '"></td>');
        else
            echo_r('    <td><input type="text" name="page_NavPosition" size="5" value="' .  $pagePage->GetNavigationPosition() . '"></td>');
        echo_r('  </tr>');
        // Show navigation level
        echo_r('  <tr>');
        echo_r('    <td width="30%">' . get_translation('admin_page_shownavlevel') . ':</td>');
        if (isset($_POST['page_ShowNavLevel']))
            echo_r('    <td><input type="text" name="page_ShowNavLevel" id="pageShowNavLevel" size="10" value="' . $_POST['page_ShowNavLevel'] . '">');
        else
            echo_r('    <td><input type="text" name="page_ShowNavLevel" id="pageShowNavLevel" size="10" value="' .  $pagePage->GetNavigationShowLevel() . '">');
		echo_r('    ' . get_translation('admin_presets') . ': <select name="page_NavLevelPreset" id="pageShowNavLevelPreset" onChange="changePageShowNavLevel(document.getElementById(\'pageShowNavLevelPreset\').value)">');
		echo_r('    <option value=""></option>');
    	foreach ($listOfPages as $value)
		{
			if ($pagePreset->LoadPageFromId($value) == true)
			{
				$strPresetTitle = $pagePreset->GetNavigationTitle() . ' - ' . $pagePreset->GetTitle();
				if (strlen($strPresetTitle) > 50)
     				$strPresetTitle = substr($strPresetTitle, 0, 50) . "...";
				$strPresetLevel = $pagePreset->GetNavigationShowLevel();
				if ($strPresetLevel == "")
					$strPresetLevel = get_translation('admin_all');
				echo_r('    <option value="' . $pagePreset->GetNavigationShowLevel() . '">' . $strPresetLevel . ' (' . $strPresetTitle . ')</option>');
			}
		}
		echo_r('	</select>');
		echo_r('	</td>');
        echo_r('  </tr>');
        // Theme template file
        echo_r('  <tr>');
        echo_r('    <td width="30%">' . get_translation('admin_page_themefile') . ':</td>');
        $thmTheme->LoadThemeFromId($SITE_THEME);
        $templateFiles = $thmTheme->GetAdditionalMainFiles();
        $pageTemplateFile = $pagePage->GetThemeFile();
        if (isset($_POST['page_TemplateFile']) == true)
            $pageTemplateFile = $_POST['page_TemplateFile'];
        if (count($templateFiles) == 0 || $templateFiles[0] == "")  // Theme has no additonal main files?
        {
            if ($pageTemplateFile == "")
                echo_r('    <td><input type="text" name="" size="30" value="' .  get_translation('admin_page_themefile_default') . '" readonly>');
            else
                echo_r('    <td><input type="text" name="" size="30" value="' .  $pageTemplateFile . '" readonly>');
            echo_r('        <input type="hidden" name="page_TemplateFile" value="' . $pageTemplateFile . '"</td>');
        }
        else
        {
            echo_r ('    <td><select name="page_TemplateFile">');
            echo ('        <option value=""');
            if ($pageTemplateFile == "")
                echo (' selected');
            echo_r ('>' . get_translation('admin_page_themefile_default') . '</option>');
            for ($i = 0; $i < count($templateFiles); $i ++)
            {
                echo ('        <option value="' . $templateFiles[$i] . '"');
                if ($pageTemplateFile == $templateFiles[$i])
                    echo (' selected');
                echo_r ('>' . $templateFiles[$i] . '</option>');
            }
            echo_r ('    </select></td>');
        }
        echo_r('  </tr>');
        // Type
        echo_r('  <tr>');
        echo_r('    <td width="30%">' . get_translation('admin_page_type') . ':</td>');
        if (isset($_POST['page_Type']) == true)
            $pageType = $_POST['page_Type'];
        else
            $pageType = $pagePage->GetType();
        echo ('    <td><select name="page_Type" id="pageType" onChange="changePageType(document.getElementById(\'pageType\').value);"');
        if ($pageEdtAction == "edit")  // Do not allow to change this on existing pages!!
            echo (' disabled');
        echo_r ('>');
        echo ('    <option value="' . PAGETYPE_PLAIN . '"');
        if ($pageType == PAGETYPE_PLAIN)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typeplain') . '</option>');
        echo ('    <option value="' . PAGETYPE_LINK . '"');
        if ($pageType == PAGETYPE_LINK)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typelink') . '</option>');
        echo ('    <option value="' . PAGETYPE_CONTACT . '"');
        if ($pageType == PAGETYPE_CONTACT)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typecontact') . '</option>');
        echo ('    <option value="' . PAGETYPE_GALLERY . '"');
        if ($pageType == PAGETYPE_GALLERY)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typegallery') . '</option>');
        echo ('    <option value="' . PAGETYPE_LINKS . '"');
        if ($pageType == PAGETYPE_LINKS)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typelinklist') . '</option>');
        echo ('    <option value="' . PAGETYPE_GUESTBOOK . '"');
        if ($pageType == PAGETYPE_GUESTBOOK)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typeguestbook') . '</option>');
        echo ('    <option value="' . PAGETYPE_YOUTUBEGALLERY . '"');
        if ($pageType == PAGETYPE_YOUTUBEGALLERY)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typeyoutubegallery') . '</option>');
        echo ('    <option value="' . PAGETYPE_SITEMAP . '"');
        if ($pageType == PAGETYPE_SITEMAP)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typesitemap') . '</option>');
        echo ('    <option value="' . PAGETYPE_NEWSLETTER . '"');
        if ($pageType == PAGETYPE_NEWSLETTER)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typenewsletter') . '</option>');
        echo ('    <option value="' . PAGETYPE_SEARCH . '"');
        if ($pageType == PAGETYPE_SEARCH)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typesearch') . '</option>');
        echo ('    <option value="' . PAGETYPE_FORM . '"');
        if ($pageType == PAGETYPE_FORM)
            echo (' selected');
        echo_r('>' . get_translation('admin_page_typeform') . '</option>');
        echo_r('    </select></td>');
        if ($pageEdtAction == "edit")  // Do not allow to change this on existing pages!!
            echo_r('    <input type="hidden" name="page_Type" value="' . $pageType . '">');
        echo_r('  </tr>');
        // Content position
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_contentposition') . ':</td>');
        if (isset($_POST['page_ContentPosition']) == true)
            $pageContentPosition = $_POST['page_ContentPosition'];
        else
            $pageContentPosition = $pagePage->GetContentPosition();
        echo_r ('      <td><select name="page_ContentPosition">');
        echo ('      <option value="' . $ALIGN_TOP . '"');
        if ($pageContentPosition == $ALIGN_TOP || $pageContentPosition == "")
            echo (' selected');
        echo_r('>' . get_translation('admin_top') . '</option>');
        echo ('      <option value="' . $ALIGN_BOTTOM . '"');
        if ($pageContentPosition == $ALIGN_BOTTOM)
            echo (' selected');
        echo_r('>' . get_translation('admin_bottom') . '</option>');
        echo ('      <option value="' . $ALIGN_RIGHT. '"');
        if ($pageContentPosition == $ALIGN_RIGHT)
            echo (' selected');
        echo_r('>' . get_translation('admin_right') . '</option>');
        echo ('      <option value="' . $ALIGN_LEFT. '"');
        if ($pageContentPosition == $ALIGN_LEFT)
            echo (' selected');
        echo_r('>' . get_translation('admin_left') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        // Link
        echo  ('  <tr id="pageLink"');
        if ($pageType != PAGETYPE_LINK)
            echo (' style="display:none"');
        echo_r('>');
        echo_r('    <td width="30%">' . get_translation('admin_page_link') . ':</td>');
        if (isset($_POST['page_Link']))
            echo_r('    <td><input type="text" name="page_Link" size="60" value="' . $_POST['page_Link'] . '"></td>');
        else
            echo_r('    <td><input type="text" name="page_Link" size="60" value="' .  $pagePage->GetLink() . '"></td>');
        echo_r('  </tr>');
        // Form
        echo  ('  <tr id="pageForm"');
        if ($pageType != PAGETYPE_FORM)
            echo (' style="display:none"');
        echo_r('>');
        echo_r('    <td width="30%">' . get_translation('admin_page_formcount') . ':</td>');
        if (isset($_POST['page_Link']))
            echo_r('    <td><input type="text" name="page_FormCount" size="5" maxlength="4" value="' . $_POST['page_FormCount'] . '"></td>');
        else
            echo_r('    <td><input type="text" name="page_FormCount" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalRowCount() . '"></td>');
        echo_r('  </tr>');
        // Gallery
        echo  ('  <tr id="pageGallery"');
        if ($pageType != PAGETYPE_GALLERY)
            echo (' style="display:none"');
        echo_r('>');
        echo_r('    <td colspan="2">');
        echo_r('    <table width="100%">');
        // Gallery image count
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_gallerycount') . ':</td>');
        if (isset($_POST['page_GalleryCount']))
            echo_r('      <td><input type="text" name="page_GalleryCount" size="5" maxlength="4" value="' . $_POST['page_GalleryCount'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_GalleryCount" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalRowCount() . '"></td>');
        echo_r('    </tr>');
        // Gallery col count
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_gallerycols') . ':</td>');
        if (isset($_POST['page_GalleryCols']))
            echo_r('      <td><input type="text" name="page_GalleryCols" size="5" maxlength="4" value="' . $_POST['page_GalleryCols'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_GalleryCols" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalColCount() . '"></td>');
        echo_r('    </tr>');
        // Gallery alignment
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_galleryalign') . ':</td>');
        if (isset($_POST['page_GalleryAlign']) == true)
            $pageGalleryAlign = $_POST['page_GalleryAlign'];
        else
            $pageGalleryAlign = $pagePage->GetAdditionalParameter();
        echo_r ('      <td><select name="page_GalleryAlign">');
        echo ('      <option value="' . $ALIGN_LEFT . '"');
        if ($pageGalleryAlign == $ALIGN_LEFT)
            echo (' selected');
        echo_r('>' . get_translation('admin_left') . '</option>');
        echo ('      <option value="' . $ALIGN_CENTER . '"');
        if ($pageGalleryAlign == $ALIGN_CENTER)
            echo (' selected');
        echo_r('>' . get_translation('admin_center') . '</option>');
        echo ('      <option value="' . $ALIGN_RIGHT . '"');
        if ($pageGalleryAlign == $ALIGN_RIGHT)
            echo (' selected');
        echo_r('>' . get_translation('admin_right') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        // Gallery text align
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_gallerytextalign') . ':</td>');
        if (isset($_POST['page_GalleryTextAlign']) == true)
            $pageGalleryTextAlign = $_POST['page_GalleryTextAlign'];
        else
            $pageGalleryTextAlign = $pagePage->GetAdditionalParameter2();
        echo_r ('      <td><select name="page_GalleryTextAlign">');
        echo ('      <option value="' . $ALIGN_TOP . '"');
        if ($pageGalleryTextAlign == $ALIGN_TOP)
            echo (' selected');
        echo_r('>' . get_translation('admin_top') . '</option>');
        echo ('      <option value="' . $ALIGN_BOTTOM . '"');
        if ($pageGalleryTextAlign == $ALIGN_BOTTOM)
            echo (' selected');
        echo_r('>' . get_translation('admin_bottom') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        // Gallery image width
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_gallerywidth') . ':</td>');
        if (isset($_POST['page_GalleryImgWidth']))
            echo_r('      <td><input type="text" name="page_GalleryImgWidth" size="5" maxlength="4" value="' . $_POST['page_GalleryImgWidth'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_GalleryImgWidth" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalImgWidth() . '"></td>');
        echo_r('    </tr>');
        // Gallery image height
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_galleryheight') . ':</td>');
        if (isset($_POST['page_GalleryImgHeight']))
            echo_r('      <td><input type="text" name="page_GalleryImgHeight" size="5" maxlength="4" value="' . $_POST['page_GalleryImgHeight'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_GalleryImgHeight" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalImgHeight() . '"></td>');
        // Gallery thumb width
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_gallerythumbwidth') . ':</td>');
        if (isset($_POST['page_GalleryThumbWidth']))
            echo_r('      <td><input type="text" name="page_GalleryThumbWidth" size="5" maxlength="4" value="' . $_POST['page_GalleryThumbWidth'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_GalleryThumbWidth" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalThumbWidth() . '"></td>');
        echo_r('    </tr>');
        // Gallery thumb height
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_gallerythumbheight') . ':</td>');
        if (isset($_POST['page_GalleryThumbHeight']))
            echo_r('      <td><input type="text" name="page_GalleryThumbHeight" size="5" maxlength="4" value="' . $_POST['page_GalleryThumbHeight'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_GalleryThumbHeight" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalThumbHeight() . '"></td>');
        echo_r('    </tr>');
        // Gallery image autosize
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_galleryautosize') . ':</td>');
        if (isset($_POST['page_GalleryAutoSize']) == true)
            $pageGalleryAutoSize = $_POST['page_GalleryAutoSize'];
        else
            $pageGalleryAutoSize = $pagePage->GetAdditionalParameter3();
        echo_r ('      <td><select name="page_GalleryAutoSize">');
        echo ('      <option value="' . $GALLERYIMAGES_SIZE_AUTO . '"');
        if ($pageGalleryAutoSize == $GALLERYIMAGES_SIZE_AUTO)
            echo (' selected');
        echo_r('>' . get_translation('admin_imageautosize') . '</option>');
        echo ('      <option value="' . $GALLERYIMAGES_SIZE_PORTRAIT . '"');
        if ($pageGalleryAutoSize == $GALLERYIMAGES_SIZE_PORTRAIT)
            echo (' selected');
        echo_r('>' . get_translation('admin_imagesizeportrait') . '</option>');
        echo ('      <option value="' . $GALLERYIMAGES_SIZE_NOAUTO . '"');
        if ($pageGalleryAutoSize == $GALLERYIMAGES_SIZE_NOAUTO)
            echo (' selected');
        echo_r('>' . get_translation('admin_imagenosize') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        echo_r('    </table>');
        echo_r('    </td>');
        echo_r('  </tr>');
        // YouTube Gallery
        echo  ('  <tr id="pageYouTubeGallery"');
        if ($pageType != PAGETYPE_YOUTUBEGALLERY)
            echo (' style="display:none"');
        echo_r('>');
        echo_r('    <td colspan="2">');
        echo_r('    <table width="100%">');
        // YouTube gallery video count
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_youtubegallerycount') . ':</td>');
        if (isset($_POST['page_YouTubeGalleryCount']))
            echo_r('      <td><input type="text" name="page_YouTubeGalleryCount" size="5" maxlength="4" value="' . $_POST['page_YouTubeGalleryCount'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_YouTubeGalleryCount" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalRowCount() . '"></td>');
        echo_r('    </tr>');
        // YouTube gallery col count
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_youtubegallerycols') . ':</td>');
        if (isset($_POST['page_YouTubeGalleryCols']))
            echo_r('      <td><input type="text" name="page_YouTubeGalleryCols" size="5" maxlength="4" value="' . $_POST['page_YouTubeGalleryCols'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_YouTubeGalleryCols" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalColCount() . '"></td>');
        echo_r('    </tr>');
        // YouTube gallery alignment
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_youtubegalleryalign') . ':</td>');
        if (isset($_POST['page_YouTubeGalleryAlign']) == true)
            $pageYouTubeGalleryAlign = $_POST['page_YouTubeGalleryAlign'];
        else
            $pageYouTubeGalleryAlign = $pagePage->GetAdditionalParameter();
        echo_r ('      <td><select name="page_YouTubeGalleryAlign">');
        echo ('      <option value="' . $ALIGN_LEFT . '"');
        if ($pageYouTubeGalleryAlign == $ALIGN_LEFT)
            echo (' selected');
        echo_r('>' . get_translation('admin_left') . '</option>');
        echo ('      <option value="' . $ALIGN_CENTER . '"');
        if ($pageYouTubeGalleryAlign == $ALIGN_CENTER)
            echo (' selected');
        echo_r('>' . get_translation('admin_center') . '</option>');
        echo ('      <option value="' . $ALIGN_RIGHT . '"');
        if ($pageYouTubeGalleryAlign == $ALIGN_RIGHT)
            echo (' selected');
        echo_r('>' . get_translation('admin_right') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        // YouTube gallery text align
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_youtubegallerytextalign') . ':</td>');
        if (isset($_POST['page_YouTubeGalleryTextAlign']) == true)
            $pageYouTubeGalleryTextAlign = $_POST['page_YouTubeGalleryTextAlign'];
        else
            $pageYouTubeGalleryTextAlign = $pagePage->GetAdditionalParameter2();
        echo_r ('      <td><select name="page_YouTubeGalleryTextAlign">');
        echo ('      <option value="' . $ALIGN_TOP . '"');
        if ($pageYouTubeGalleryTextAlign == $ALIGN_TOP)
            echo (' selected');
        echo_r('>' . get_translation('admin_top') . '</option>');
        echo ('      <option value="' . $ALIGN_BOTTOM . '"');
        if ($pageYouTubeGalleryTextAlign == $ALIGN_BOTTOM)
            echo (' selected');
        echo_r('>' . get_translation('admin_bottom') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        // YouTube gallery video width
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_youtubegallerywidth') . ':</td>');
        if (isset($_POST['page_YouTubeGalleryVideoWidth']))
            echo_r('      <td><input type="text" name="page_YouTubeGalleryVideoWidth" size="5" maxlength="4" value="' . $_POST['page_YouTubeGalleryVideoWidth'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_YouTubeGalleryVideoWidth" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalImgWidth() . '"></td>');
        echo_r('    </tr>');
        // YouTube gallery video height
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_youtubegalleryheight') . ':</td>');
        if (isset($_POST['page_YouTubeGalleryVideoHeight']))
            echo_r('      <td><input type="text" name="page_YouTubeGalleryVideoHeight" size="5" maxlength="4" value="' . $_POST['page_YouTubeGalleryVideoHeight'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_YouTubeGalleryVideoHeight" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalImgHeight() . '"></td>');
        echo_r('    </tr>');
        echo_r('    </table>');
        echo_r('    </td>');
        echo_r('  </tr>');
        // Link list
        echo  ('  <tr id="pageLinkList"');
        if ($pageType != PAGETYPE_LINKS)
            echo (' style="display:none"');
        echo_r('>');
        echo_r('    <td colspan="2">');
        echo_r('    <table width="100%">');
        // Link list count
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_linklistcount') . ':</td>');
        if (isset($_POST['page_LinkListCount']))
            echo_r('      <td><input type="text" name="page_LinkListCount" size="5" maxlength="4" value="' . $_POST['page_LinkListCount'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_LinkListCount" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalRowCount() . '"></td>');
        echo_r('    </tr>');
        // Link list col count
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_linklistcols') . ':</td>');
        if (isset($_POST['page_LinkListCols']))
            echo_r('      <td><input type="text" name="page_LinkListCols" size="5" maxlength="4" value="' . $_POST['page_LinkListCols'] . '"></td>');
        else
            echo_r('      <td><input type="text" name="page_LinkListCols" size="5" maxlength="4" value="' .  $pagePage->GetAdditionalColCount() . '"></td>');
        echo_r('    </tr>');
        // Link list alignment
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_linklistalign') . ':</td>');
        if (isset($_POST['page_LinkListAlign']) == true)
            $pageLinkListAlign = $_POST['page_LinkListAlign'];
        else
            $pageLinkListAlign = $pagePage->GetAdditionalParameter();
        echo_r ('      <td><select name="page_LinkListAlign">');
        echo ('      <option value="' . $ALIGN_LEFT . '"');
        if ($pageLinkListAlign == $ALIGN_LEFT)
            echo (' selected');
        echo_r('>' . get_translation('admin_left') . '</option>');
        echo ('      <option value="' . $ALIGN_CENTER . '"');
        if ($pageLinkListAlign == $ALIGN_CENTER)
            echo (' selected');
        echo_r('>' . get_translation('admin_center') . '</option>');
        echo ('      <option value="' . $ALIGN_RIGHT . '"');
        if ($pageLinkListAlign == $ALIGN_RIGHT)
            echo (' selected');
        echo_r('>' . get_translation('admin_right') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        // Link list text align
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_linklisttextalign') . ':</td>');
        if (isset($_POST['page_LinkListTextAlign']) == true)
            $pageLinkListTextAlign = $_POST['page_LinkListTextAlign'];
        else
            $pageLinkListTextAlign = $pagePage->GetAdditionalParameter2();
        echo_r ('      <td><select name="page_LinkListTextAlign">');
        echo ('      <option value="' . $ALIGN_TOP . '"');
        if ($pageLinkListTextAlign == $ALIGN_TOP)
            echo (' selected');
        echo_r('>' . get_translation('admin_top') . '</option>');
        echo ('      <option value="' . $ALIGN_BOTTOM . '"');
        if ($pageLinkListTextAlign == $ALIGN_BOTTOM)
            echo (' selected');
        echo_r('>' . get_translation('admin_bottom') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        echo_r('    </table>');
        echo_r('    </td>');
        echo_r('  </tr>');
        // Contact / form / search / guestbook / newsletter text align
        echo  ('  <tr id="pageFormTextAlign"');
        if ($pageType != PAGETYPE_CONTACT && $pageType != PAGETYPE_FORM && $pageType != PAGETYPE_SEARCH && $pageType != PAGETYPE_GUESTBOOK && $pageType != PAGETYPE_NEWSLETTER)
            echo (' style="display:none"');
        echo_r('>');
        echo_r('    <td colspan="2">');
        echo_r('    <table width="100%">');
        echo_r('    <tr>');
        echo_r('      <td width="30%">' . get_translation('admin_page_formalign') . ':</td>');
        if (isset($_POST['page_FormTextAlign']) == true)
            $pageFormTextAlign = $_POST['page_FormTextAlign'];
        else
            $pageFormTextAlign = $pagePage->GetAdditionalParameter2();
        echo_r ('      <td><select name="page_FormTextAlign">');
        echo ('      <option value="' . $ALIGN_TOP . '"');
        if ($pageFormTextAlign == $ALIGN_TOP)
            echo (' selected');
        echo_r('>' . get_translation('admin_top') . '</option>');
        echo ('      <option value="' . $ALIGN_LEFT . '"');
        if ($pageFormTextAlign == $ALIGN_LEFT)
            echo (' selected');
        echo_r('>' . get_translation('admin_left') . '</option>');
        echo_r('      </select></td>');
        echo_r('    </tr>');
        echo_r('    </table>');
        echo_r('    </td>');
        echo_r('  </tr>');
        // Show in navigation
        echo_r('  <tr>');
        if (isset($_POST['page_ShowInNavigation']) == true)
            $showInNavigation = isset($_POST['page_ShowInNavigation']);
        else
            $showInNavigation = $pagePage->ShowInNavigation();
        echo_r('    <td width="30%">' . get_translation('admin_page_showinnavigation') . ':</td>');
            echo('    <td><input type="checkbox" name="page_ShowInNavigation" value="1"');
        if ($showInNavigation == true)
            echo(' checked');
        echo_r('></td>');
        echo_r('  </tr>');
        if (user_is_admin() == true)
        {
            // Main page
            echo_r('  <tr>');
            if ($pageEdtAction == "edit")
                $isMainPage = $pagePage->IsMainPage();
            else
                $isMainPage = isset($_POST['page_IsMainPage']);
            echo_r('    <td width="30%">' . get_translation('admin_page_ismainpage') . ':</td>');
                echo('    <td><input type="checkbox" name="page_IsMainPage" value="1"');
            if ($isMainPage == true)
                echo(' checked');
            echo_r('></td>');
            echo_r('  </tr>');
            // Delete protection
            echo_r('  <tr>');
            if ($pageEdtAction == "edit")
                $isDeleteProtected = $pagePage->IsDeleteProtected();
            else
                $isDeleteProtected = isset($_POST['page_DeleteProtected']);
            echo_r('    <td width="30%">' . get_translation('admin_page_deleteprotected') . ':</td>');
                echo('    <td><input type="checkbox" name="page_DeleteProtected" value="1"');
            if ($isDeleteProtected == true)
                echo(' checked');
            echo_r('></td>');
            echo_r('  </tr>');
        }
        else
        {
            if ($pagePage->IsMainPage() == true)
                echo_r('<input type="hidden" name="page_IsMainPage" value="1">');
            if ($pagePage->IsDeleteProtected() == true)
                echo_r('<input type="hidden" name="page_DeleteProtected" value="1">');
        }
        echo_r('</table>');

        if ($pageEdtAction == "edit")  // Edit
            print_bottom_links("page_Save", get_translation('admin_save'),
                               "page_Cancel", get_translation('admin_cancel'), false);
        else  // New
            print_bottom_links("page_Save", get_translation('admin_create'),
                               "page_Cancel", get_translation('admin_cancel'), false);

    }
    echo_r('<input type="hidden" name="page_EdtAction" value="' . $pageEdtAction . '">');
    echo_r('</form>');

    print_admin_footer();
?>