<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	// main pages admin page (with page categories)
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_content.gif" width="23" height="20"> '.$MsgText[0][244];
	$BrowserTitle = $MsgText[0][244];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[0][244];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[18] == 'y') {
	
	
		$query = "select * from `".$Settings['DBPrefix']."core-PageCategories` ORDER BY Name ASC";
		$result = mysql_query($query) or die (mysql_error());
		
		while ($row = mysql_fetch_array($result)) { 
            
			$CategoryIDsArray[$row['Parent']][] = $row['RecordNumber'];
			$CategoryNamesArray[$row['Parent']][] = $row['Name'];
			$CategoryExists[$row['RecordNumber']] = 'y';
			
			if ($row['Description'] != '') { 
				$CategoryDescriptionsArray[$row['Parent']][] = '<br>'.$row['Description'];
			}
			else {
				$CategoryDescriptionsArray[$row['Parent']][] = '<!--  -->';
			}
			
				
		}
		
		
		if ($Permissions[19] == 'y') {
			$CreateNewLinks = '<br><a href="#new">'.$MsgText[0][245].'</a> | <a href="#newcat">'.$MsgText[0][246].'</a><br><br>';
		}
		
		$PageContents = $CreateNewLinks.'<br><b>'.$MsgText[0][247].':</b><br>';
		
	
	
				
		//query the database and load pages data
		$query = "select * from `".$Settings['DBPrefix']."core-Pages` where MinLevel<='".$UserLevel."' and MinEditLevel<='".$UserLevel."' ORDER BY PageTitle asc, PageLink asc, RecordNumber asc";
		$result = mysql_query($query) or die (mysql_error());
		
				
		// if any rows are returned
		if (mysql_num_rows($result) != 0) {
						
			while ($row = mysql_fetch_array($result)) {
			
				// if the page has been orphaned, put it back in top level
				if ($CategoryExists[$row['PageParent']] != 'y') {
					$row['PageParent'] = 0;
				}			
            	
				$PageIDsArray[$row['PageParent']][] = $row['RecordNumber'];
				$PageNamesArray[$row['PageParent']][] = $row['PageTitle'];
				$PageLabelsArray[$row['PageParent']][] = $row['AdminLabel'];
				$PageLinksArray[$row['PageParent']][] = $row['PageLink'];
				
			}
			

			

			$CatsPrint .= '<br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="10" alt="" border="0"><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:ExpandCollapse(\''.$ItemsCount.'\');" style="text-decoration: none;"><img id="img'.$ItemsCount.'" src="'.$ImagesURL.'/admin/minus.gif" border="0" width="9" height="9" alt=""><font size="2" face="Arial" color="'.$Colors['Text'].'">&nbsp;<b>'.$MsgText[0][248].'</b></font><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><div id="div'.$ItemsCount.'"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="40"><img src="'.$ImagesURL.'/admin/spacer.gif" width="40" height="1" alt="" border="0"></td><td width="100%">';
			
			
			
			
			
			
			
			function SpiderCategories($CatParent) {
				
				Global $CategoryIDsArray, $CategoryNamesArray, $CategoryDescriptionsArray, $PageIDsArray, $PageNamesArray, $PageLabelsArray, $PageLinksArray, $CatsPrint, $LastParent, $LastParentAbove, $CatSpacersArray, $CatLevel, $CatsCount, $BaseURL, $ImagesURL, $MainURL, $FontSize, $FontColor, $MsgText, $Permissions, $ItemsCount, $Colors;
				
				for ($i = 0; $i < count($CategoryIDsArray[$CatParent]); $i++) {
					
					$LastParentAboveB = $LastParentAbove;
					$LastParentB = $LastParent;
					
					$CatLevel[$CategoryIDsArray[$CatParent][$i]] = $CatLevel[$CatParent];
					if ($CatParent != $LastParent && $CatParent == $LastParentAbove) {
				
						$CatLevel[$CategoryIDsArray[$CatParent][$i]] = $CatLevel[$CatParent] + 1;
						$CatLevel[$CatParent]++;
						
						$CatsCount[$CatLevel[$CatParent]] = 0;
				
					}
					
					$LastParent = $CatParent;
					$LastParentAbove = $CategoryIDsArray[$CatParent][$i];
					
					$CatsCount[$CatLevel[$CatParent]]++;
					
	
	
					if ($Permissions[20] == 'y') {
						$CatEditLink = '&nbsp;&nbsp;&nbsp;<font size="1"><a href="'.$MainURL.'/admin/pages-catedit/'.$CategoryIDsArray[$CatParent][$i].'.html">'.$MsgText[0][661].'</a></a>';
					}
		
		
				

					if ($CategoryDescriptionsArray[$CatParent][$i] != '') {
						$CategoryDescriptionsArray[$CatParent][$i] = $CategoryDescriptionsArray[$CatParent][$i] . '<br>';
					}
					
					$ItemsCount++;
					
					$CatsPrint .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><table border="0" cellpadding="0" cellspacing="0"><tr><td><font size="2" face="Arial" color="'.$Colors['Text'].'">&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:ExpandCollapse(\''.$ItemsCount.'\');" style="text-decoration: none;"><img id="img'.$ItemsCount.'" src="'.$ImagesURL.'/admin/minus.gif" border="0" width="9" height="9" alt=""></a><font size="2" face="Arial" color="'.$Colors['Text'].'">&nbsp;</font></td><td><a href="javascript:ExpandCollapse(\''.$ItemsCount.'\');" style="text-decoration: none;"><font size="2" face="Arial" color="'.$Colors['Text'].'"><b>'.$CategoryNamesArray[$CatParent][$i].'</b></a>'.$CatEditLink.'<font size="1">'.$CategoryDescriptionsArray[$CatParent][$i].'</font></font></td></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><div id="div'.$ItemsCount.'"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="40"><img src="'.$ImagesURL.'/admin/spacer.gif" width="40" height="1" alt="" border="0"></td><td width="100%">';
					
					if (count($CategoryIDsArray[$CatParent][$i]) > 0) {
						SpiderCategories($CategoryIDsArray[$CatParent][$i]);
					}
					
										
					for ($x = 0; $x < count($PageIDsArray[$CategoryIDsArray[$CatParent][$i]]); $x++) {
											
																	

						$CatsPrint .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><table border="0" cellpadding="0" cellspacing="0"><tr><td width="20"><img src="'.$ImagesURL.'/admin/spacer.gif" width="20" height="1" alt="" border="0"></td><td width="1" bgcolor="'.$Colors['Text'].'"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="1" alt="" border="0"></td><td width="10"><img src="'.$ImagesURL.'/admin/spacer.gif" width="10" height="1" alt="" border="0"></td><td><font size="2" face="Arial" color="'.$Colors['Link'].'"><a href="'.$MainURL.'/admin/pages-edit/'.$PageIDsArray[$CategoryIDsArray[$CatParent][$i]][$x].'.html" style="text-decoration: none;"><b>'.$PageNamesArray[$CategoryIDsArray[$CatParent][$i]][$x].'</b></a><br><font size="1">'.$PageLinksArray[$CategoryIDsArray[$CatParent][$i]][$x].'</font></font></td><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="20" height="1" alt="" border="0"></td><td align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/pages/'.$PageLinksArray[$CategoryIDsArray[$CatParent][$i]][$x].'.html" target="_blank"><img src="'.$ImagesURL.'/admin/pages_view.gif" border="0" width="16" height="16" alt=""><br>'.$MsgText[0][249].'</font></a></td><td width="12"><img src="'.$ImagesURL.'/admin/spacer.gif" width="12" height="1" alt="" border="0"></td><td align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/admin/pages-edit/'.$PageIDsArray[$CategoryIDsArray[$CatParent][$i]][$x].'.html"><img src="'.$ImagesURL.'/admin/pages_edit.gif" border="0" width="16" height="16" alt=""><br>'.$MsgText[0][155].'</a></td><td width="12"><img src="'.$ImagesURL.'/admin/spacer.gif" width="12" height="1" alt="" border="0"></td><td align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/admin/pages-delete/'.$PageIDsArray[$CategoryIDsArray[$CatParent][$i]][$x].'.html"><img src="'.$ImagesURL.'/admin/pages_delete.gif" border="0" width="16" height="16" alt=""><br>'.$MsgText[0][156].'</font></a></td></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br>';
						
						
					
					}
					
					
					
					
					
					
					
					$CatsPrint .= '</td></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"></div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="10" alt="" border="0"><br>';
				
				
				}
				
				
			}
			
			SpiderCategories('0');
			
			
			
			$LastParentAbove = '0';
			$CatLevel['0'] = 0;
			
			
			for ($x = 0; $x < count($PageIDsArray['0']); $x++) {
					
				
				for ($x = 0; $x < count($PageIDsArray[0]); $x++) {
											
								
					$CatsPrint .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><table border="0" cellpadding="0" cellspacing="0"><tr><td width="20"><img src="'.$ImagesURL.'/admin/spacer.gif" width="20" height="1" alt="" border="0"></td><td width="1" bgcolor="'.$Colors['Text'].'"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="1" alt="" border="0"></td><td width="10"><img src="'.$ImagesURL.'/admin/spacer.gif" width="10" height="1" alt="" border="0"></td><td><font size="2" face="Arial" color="'.$Colors['Link'].'"><a href="'.$MainURL.'/admin/pages-edit/'.$PageIDsArray[0][$x].'.html" style="text-decoration: none;"><b>'.$PageNamesArray[0][$x].'</b></a><br><font size="1">'.$PageLinksArray[0][$x].'</font></font></td><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="20" height="1" alt="" border="0"></td><td align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/pages/'.$PageLinksArray[0][$x].'.html" target="_blank"><img src="'.$ImagesURL.'/admin/pages_view.gif" border="0" width="16" height="16" alt=""><br>'.$MsgText[0][249].'</font></a></td><td width="12"><img src="'.$ImagesURL.'/admin/spacer.gif" width="12" height="1" alt="" border="0"></td><td align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/admin/pages-edit/'.$PageIDsArray[0][$x].'.html"><img src="'.$ImagesURL.'/admin/pages_edit.gif" border="0" width="16" height="16" alt=""><br>'.$MsgText[0][155].'</a></td><td width="12"><img src="'.$ImagesURL.'/admin/spacer.gif" width="12" height="1" alt="" border="0"></td><td align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/admin/pages-delete/'.$PageIDsArray[0][$x].'.html"><img src="'.$ImagesURL.'/admin/pages_delete.gif" border="0" width="16" height="16" alt=""><br>'.$MsgText[0][156].'</font></a></td></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br>';
										
				
				}
									
			}
			
			
			
			
			
			
			$CatsPrint .= '</td></tr></table></div>';
			
			
			
			$PageContents .= $CatsPrint;
			
			
			$PageContents .= '<script>

var ItemsCount = '.number_format($ItemsCount,0,'','').';

function CollapseAll() {

	for (x=1; x<=ItemsCount; x++) {
	
		var ElementID = document.getElementById("div"+x);
		var ImgElementID = document.getElementById("img"+x);
		
		ElementID.style.display = "none"
		ImgElementID.src = "'.$ImagesURL.'/admin/plus.gif";
	
	}

}

function ExpandCollapse(IDNumber) {

	var ElementID = document.getElementById("div"+IDNumber);
	var ImgElementID = document.getElementById("img"+IDNumber);
	
	if (ElementID.style.display != "none") {
		ElementID.style.display = "none"
		ImgElementID.src = "'.$ImagesURL.'/admin/plus.gif";
	}
	else {
		ElementID.style.display = ""
		ImgElementID.src = "'.$ImagesURL.'/admin/minus.gif";
	}

}

CollapseAll();

</script>';
			
			
			
			
		}
		else {
		
			$PageContents .= '('.$MsgText[0][250].')<br>';
		
		}
		
	
		
		if ($Permissions[19] == 'y') {
	
	
			
		
		
		for ($d = 1; $d <= 31; $d++) {
			if ($d < 10) {
				$DaysSelect .= '<option value="'.$d.'"> &nbsp;&nbsp;'.$d.'</option>';
			}
			else {
				$DaysSelect .= '<option value="'.$d.'"> '.$d.'</option>';
			}
		}
		$CurrentYear = date('Y',GetTimestamp());
		for ($y = 2004; $y <= 2020; $y++) {
			if ($CurrentYear == $y) {
				$YearsSelect .= '<option value="'.$y.'" selected> '.$y.'</option>';
			}
			else {
				$YearsSelect .= '<option value="'.$y.'"> '.$y.'</option>';
			}
		}
		
		$HoursSelect = '<option value="0"> 12</option>';
		for ($h = 1; $h <= 11; $h++) {
			if ($h < 10) {
				$HoursSelect .= '<option value="'.$h.'"> &nbsp;&nbsp;'.$h.'</option>';
			}
			else {
				$HoursSelect .= '<option value="'.$h.'"> '.$h.'</option>';
			}
		}
		
		for ($m = 0; $m <= 59; $m++) {
			if ($m < 10) {
				$MinutesSelect .= '<option value="'.$m.'"> 0'.$m.'</option>';
			}
			else {
				$MinutesSelect .= '<option value="'.$m.'"> '.$m.'</option>';
			}
		}
		
		
		$query = "select Level,Description from `".$Settings['DBPrefix']."core-Permissions` where Level<=".$UserLevel;
   		$result = mysql_query($query) or die (mysql_error());
		while ($row = mysql_fetch_array($result)) {
			$LevelDescriptions[$row['Level']] = $row['Description'];
		}
		
		$PermissionsDropdown = '<option value="0"> 0 - Everyone</option>';
		for ($i = 1; $i <= $UserLevel; $i++) {
			if ($LevelDescriptions[$i] != '') {
				$PermissionsDropdown .= '<option value="'.$i.'"> '.$i.' - '.$LevelDescriptions[$i].'</option>';
			}
			else {
				$PermissionsDropdown .= '<option value="'.$i.'"> '.$i.'</option>';
			}
		}
		
		
			
					
			
			
			$PageCategoryDropdown = '<option value="0"> '.$MsgText[0][248].'</option>';
			
			$CatParent5 = 0;
			$LastParentAbove5 = '0';
			$CatLevel5['0'] = 0;
						
			function SpiderCategories5($CatParent5) {
				
				Global $CategoryIDsArray, $CategoryNamesArray, $PageCategoryDropdown, $LastParent5, $LastParentAbove5, $CatSpacersArray5, $CatLevel5, $CatsCount5;
				
				for ($i = 0; $i < count($CategoryIDsArray[$CatParent5]); $i++) {
					
					$LastParentAboveB5 = $LastParentAbove5;
					$LastParentB5 = $LastParent5;
					
					$CatLevel5[$CategoryIDsArray[$CatParent5][$i]] = $CatLevel5[$CatParent5];
					if ($CatParent5 != $LastParent5 && $CatParent5 == $LastParentAbove5) {
				
						$CatLevel5[$CategoryIDsArray[$CatParent5][$i]] = $CatLevel5[$CatParent5] + 1;
						$CatLevel5[$CatParent5]++;
												
						$CatsCount5[$CatLevel5[$CatParent5]] = 0;
				
					}
					
					$LastParent5 = $CatParent5;
					$LastParentAbove5 = $CategoryIDsArray[$CatParent5][$i];
					
					$CatsCount5[$CatLevel5[$CatParent5]]++;
					
										
					$CatSpacer5 = '';
					for ($x = 0; $x < $CatLevel5[$CatParent5]; $x++) {
						
						if ($CatsCount5[$CatLevel5[$CatParent5]] == count($CategoryIDsArray[$CatParent5]) && $x == $CatLevel5[$CatParent5]-1) {
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;\'------';
							$ResetAfter5 = 'y';
						}
						else if ($CatsCount5[$CatLevel5[$CatParent5]] == count($CategoryIDsArray[$CatParent5])) {
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
						}
						else {
							if ($x < $CatLevel5[$CatParent5]) {
								$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;|------';
								$ResetAfter5 = 'y2';
							}
							else {
								$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							}
						}
						
							
						$CatSpacer5 .= $CatSpacersArray5[$x+1];
						
						if ($ResetAfter5 == 'y') {
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							$ResetAfter5 = 'n';
						}
						else if ($ResetAfter5 == 'y2') {
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							$ResetAfter5 = 'n';
						}
										
					}
					
					
					
					$PageCategoryDropdown .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';
					
										
					if (count($CategoryIDsArray[$CatParent5][$i]) > 0) {
						SpiderCategories5($CategoryIDsArray[$CatParent5][$i]);
					}
				
				}
				
				
			}
			
			SpiderCategories5('0');
			
			
			$EnablePHP = '';
			if ($Permissions[9] == 'y') {
				$EnablePHP = '<option value="3"'.$PageTypeSelected[3].'> PHP-Enabled Code</option>';
			}
			
		
		
		
		$PageContents .= '<script>

function ValidateForm() {

	document.forms["PostForm"].elements["SubmitButton"].disabled = true;
				
	return true;
	
}

</script><br><br><br><a name="new"></a><b>'.$MsgText[0][245].':</b><form name="PostForm" method="post" action="'.$MainURL.'/admin/pages-new-save">


<script>
var ExistingImagesWindowCode = "";

function SelectImage() {
	var WindowProperties = "width=420,height=300,left=" + (screen.width-420)/2 + ",top=" + (screen.height-300)/2 + ",location=no,menubar=no,directories=no,toolbar=no,status=no,scrollbars=no,resizable=yes";

	ExistingImagesWindowCode = window.open("'.$BaseURL.'/inc-core-admin-editor-existingimages.php","existingimages",WindowProperties);
}
function ExistingImageSelected(ImageName,ImageWidth,ImageHeight) {

	ExistingImagesWindowCode.close();
	
	document.forms["PostForm"].elements["TitleImage"].value = "/images/uploaded/"+ImageName;

}
function UploadToServer() {

		var WindowProperties = "width=580,height=380,left=" + (screen.width-580)/2 + ",top=" + (screen.height-380)/2 + ",location=no,menubar=no,directories=no,toolbar=no,status=no,scrollbars=no,resizable=yes";

		UploadWindowCode = window.open("'.$BaseURL.'/inc-core-admin-editor-imageupload.php","imageupload",WindowProperties);

	  }

	  function UploadedImageSelected(ImageName,ImageWidth,ImageHeight) {

		UploadWindowCode.close();
	
		document.forms["PostForm"].elements["TitleImage"].value = "/images/uploaded/"+ImageName;
		
	  }
</script>


<b>'.$MsgText[0][517].':</b>&nbsp;&nbsp;<input type="text" name="AdminLabel" size="30"><br><font size="1">'.$MsgText[0][518].'</font><br>

<br><b>'.$MsgText[0][252].':</b>&nbsp;&nbsp;<select name="PageCategory">'.$PageCategoryDropdown.'</select><br><br>
		
		
<br><b>'.$MsgText[0][253].':</b>&nbsp;&nbsp;<input type="text" name="PageLink" size="30"><br><font size="1">'.$MsgText[0][254].'</font><br>

<br><b>'.$MsgText[0][255].':</b>&nbsp;&nbsp;<input type="text" name="PageTitle" size="30"><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="45"><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt=""></td>
      <td width="100%"><font face="'.$FontFace.'" size="'.$FontSize.'">
	  '.$MsgText[0][519].':&nbsp;&nbsp;<input type="text" name="TitleImage" size="40" value="'.$row['TitleImage'].'"><br><input type="button" value="'.$MsgText[0][521].'" onClick="SelectImage();">&nbsp;<input type="button" value="'.$MsgText[0][563].'" onClick="UploadToServer();"><br><font size="1">'.$MsgText[0][520].'<br></font>

<img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br>'.$MsgText[0][166].':&nbsp;&nbsp;<select name="TitleAlignment">
	<option value="L"> '.$MsgText[0][15].'</option>
	<option value="C"> '.$MsgText[0][16].'</option>
	<option value="R"> '.$MsgText[0][17].'</option>
</select>
<br><font size="1">'.$MsgText[0][257].'<br></font>

 </td>
    </tr>
</table>


<br>
<b>'.$MsgText[0][689].':</b><br>

<script>
var EditorStarted = false;

function UpdatePageType() {
	var PageType = document.getElementById("PageType").value;
	
	if (PageType == 1) {
		if (EditorStarted == false) {
			var oFCKeditor = new FCKeditor( "PageContents" ) ;

			oFCKeditor.BasePath = "'.$BaseURL.'/fckeditor/" ;	// "/fckeditor/" is the default value.
												
			oFCKeditor.Height	= 500 ;
			
			//oFCKeditor.Create() ;
			oFCKeditor.ReplaceTextarea();
			
			EditorStarted = true;
		}
	
		document.getElementById("EditorDiv").style.display = "";
		document.getElementById("NonEditorDiv").style.display = "none";
		document.getElementById("EnablePHP").value = 0;
	}
	else if (PageType == 2) {
		document.getElementById("EditorDiv").style.display = "none";
		document.getElementById("NonEditorDiv").style.display = "";
		document.getElementById("EnablePHP").value = 0;
	}
	else if (PageType == 3) {
		document.getElementById("EditorDiv").style.display = "none";
		document.getElementById("NonEditorDiv").style.display = "";
		document.getElementById("EnablePHP").value = 1;
	}
}
</script>

<select name="PageType" id="PageType" size="1" onChange="UpdatePageType();">
<option value="1"'.$PageTypeSelected[1].'> Rich Text / HTML Editor</option>
<option value="2"'.$PageTypeSelected[2].'> Plain Text / HTML Without Editor</option>
'.$EnablePHP.'
</select><br><input id="EnablePHP" type="hidden" name="EnablePHP" value="0">

<br><b>'.$MsgText[0][263].':</b><br>


<div id="EditorDiv"><textarea id="PageContents" name="PageContents" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual"></textarea></div><div id="NonEditorDiv" style="display: none;"><textarea id="PageContents2" name="PageContents2" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual"></textarea></div>



<br>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="45"><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt=""></td>
      <td width="100%"><font face="'.$FontFace.'" size="'.$FontSize.'">

'.$MsgText[0][258].':&nbsp;&nbsp;<select name="PageAlignment">
	<option value="L"> '.$MsgText[0][15].'</option>
	<option value="C"> '.$MsgText[0][16].'</option>
	<option value="R"> '.$MsgText[0][17].'</option>
</select>
<br><font size="1">'.$MsgText[0][259].'</font><br>

<img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br>'.$MsgText[0][180].':&nbsp;&nbsp;<input type="checkbox" name="NLtoBR" value="1"> '.$MsgText[0][118].'<br><font size="1">'.$MsgText[0][181].'<br></font><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br>'.$MsgText[0][182].':&nbsp;&nbsp;<input type="checkbox" name="ConvertLinks" value="1"> '.$MsgText[0][118].'<br>
<br>
</td>
    </tr>
</table>

<img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="8" alt=""><br>

<b>'.$MsgText[0][675].':</b>&nbsp;&nbsp;<input type="text" name="BrowserTitle" size="50" value="'.str_replace('"','&#34;',$row['BrowserTitle']).'"><br><font size="1">'.$MsgText[0][676].'<br></font>

<br>
<b>'.$MsgText[0][648].':</b>&nbsp;&nbsp;<input type="text" name="MetaKeywords" size="50" value="'.str_replace('"','&#34;',$row['MetaKeywords']).'"><br><font size="1">'.$MsgText[0][649].'<br></font>

<br>
<b>'.$MsgText[0][650].':</b>&nbsp;&nbsp;<input type="text" name="MetaDescription" size="50" value="'.str_replace('"','&#34;',$row['MetaDescription']).'"><br><font size="1">'.$MsgText[0][651].'<br></font>

<br>

<br>


<img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br><b>'.$MsgText[0][265].':</b>&nbsp;&nbsp;<select name="PageEnabled">
	<option value="0"> '.$MsgText[0][266].'</option>
	<option value="1" selected> '.$MsgText[0][267].'</option>
</select>
<br>

<br>
<b>'.$MsgText[0][268].':</b>&nbsp;&nbsp;<input type="checkbox" name="HidePage" value="y"> '.$MsgText[0][118].'<br><font size="1">'.$MsgText[0][269].'<br></font>

<br>
<b>Show Printable Link:</b>&nbsp;&nbsp;<input type="checkbox" name="ShowPrintable" value="1"> '.$MsgText[0][118].'
<br><br>
<b>Show Email Link:</b>&nbsp;&nbsp;<input type="checkbox" name="ShowEmail" value="1"> '.$MsgText[0][118].'

<br><br>
<b>'.$MsgText[0][189].':</b>&nbsp;&nbsp;<select name="MinLevel">'.$PermissionsDropdown.'</select><br><font size="1">'.$MsgText[0][270].'<br></font>
<br>
<b>'.$MsgText[0][543].':</b>&nbsp;&nbsp;<select name="MinEditLevel">'.$PermissionsDropdown.'</select><br><font size="1">'.$MsgText[0][544].'<br></font>

<br><br>
<b>'.$MsgText[0][271].':</b> '.date('F jS Y @ g:i:s A',GetTimestamp()).'
<br>
<br>
<b>'.$MsgText[0][272].':</b>&nbsp;<input type="checkbox" name="UseStartDate" value="Yes"> '.$MsgText[0][118].'&nbsp;&nbsp;&nbsp;&nbsp;<select name="SDMonth"><option value="1"> '.$MsgText[0][284].'</option><option value="2"> '.$MsgText[0][285].'</option><option value="3"> '.$MsgText[0][286].'</option><option value="4"> '.$MsgText[0][287].'</option><option value="5"> '.$MsgText[0][288].'</option><option value="6"> '.$MsgText[0][289].'</option><option value="7"> '.$MsgText[0][290].'</option><option value="8"> '.$MsgText[0][291].'</option><option value="9"> '.$MsgText[0][292].'</option><option value="10"> '.$MsgText[0][293].'</option><option value="11"> '.$MsgText[0][294].'</option><option value="12"> '.$MsgText[0][295].'</option></select>&nbsp;<select name="SDDay">'.$DaysSelect.'</select>&nbsp;<select name="SDYear">'.$YearsSelect.'</select> @ <select name="SDHour">'.$HoursSelect.'</select>:<select name="SDMinute">'.$MinutesSelect.'</select>&nbsp;<select name="SDAmPm"><option value="am"> AM</option><option value="pm"> PM</option></select><br><font size="1">'.$MsgText[0][273].'<br></font>

<br>
<b>'.$MsgText[0][274].':</b>&nbsp;<input type="checkbox" name="UseEndDate" value="Yes"> '.$MsgText[0][118].'&nbsp;&nbsp;&nbsp;&nbsp;<select name="EDMonth"><option value="1"> '.$MsgText[0][284].'</option><option value="2"> '.$MsgText[0][285].'</option><option value="3"> '.$MsgText[0][286].'</option><option value="4"> '.$MsgText[0][287].'</option><option value="5"> '.$MsgText[0][288].'</option><option value="6"> '.$MsgText[0][289].'</option><option value="7"> '.$MsgText[0][290].'</option><option value="8"> '.$MsgText[0][291].'</option><option value="9"> '.$MsgText[0][292].'</option><option value="10"> '.$MsgText[0][293].'</option><option value="11"> '.$MsgText[0][294].'</option><option value="12"> '.$MsgText[0][295].'</option></select>&nbsp;<select name="EDDay">'.$DaysSelect.'</select>&nbsp;<select name="EDYear">'.$YearsSelect.'</select> @ <select name="EDHour">'.$HoursSelect.'</select>:<select name="EDMinute">'.$MinutesSelect.'</select>&nbsp;<select name="EDAmPm"><option value="am"> AM</option><option value="pm"> PM</option></select><br><font size="1">'.$MsgText[0][275].'<br></font>




<br>
<br>
<input type="submit" name="SubmitButton" value="'.$MsgText[0][276].'">


</form><br><br><script>var FlexCMSScriptName="'.$Settings['ScriptName'].'";</script><script type="text/javascript" src="'.$BaseURL.'/fckeditor/fckeditor.js"></script><script>UpdatePageType();</script>';


		} // end if permission 19 (create new pages)
		
		if ($Permissions[20] == 'y') {
		
		
			$PageContents .= '<div align="left"><hr width="70%"></div>'.$MsgText[0][277].'<br><br><br><a name="newcat"></a><b>'.$MsgText[0][246].':</b><form name="PageCatForm" action="'.$MainURL . '/admin/pages-newcat" method="post">

<b>'.$MsgText[0][278].':</b><br>
<select name="CatParent">'.$PageCategoryDropdown.'</select>
<br><br>

<b>'.$MsgText[0][279].':</b><br><input type="text" name="CatName" size="30">

<br><br>

<b>'.$MsgText[0][280].':</b><br><input type="text" name="CatDescription" size="50">


<br><br>
<b>'.$MsgText[0][281].':</b>&nbsp;&nbsp;<input type="checkbox" name="HideCategory" value="y"> '.$MsgText[0][118].'<br><font size="1">'.$MsgText[0][282].'<br></font>

<br><br><br>

<input type="submit" value="'.$MsgText[0][283].'">


</form><br><br><br>';
		
		
		} // end if permission 20 (edit page categories)


		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

	// ========================================================================================




?>
