<?

/*
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
*/



	// ========================================================================================
	// edit article
	// ========================================================================================
	
	$query = "select * from `".$Settings['DBPrefix']."na-Settings`";
	$result = mysql_query($query) or die (mysql_error());
	while ($row = mysql_fetch_array($result)) {
		$naSettings[$row['Name']] = $row['Value'];
	}
	
	
	if ($naSettings['Title'] == '') {
		$naSettings['Title'] = $MsgText[7][1];
	}
	

	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_articles.gif" width="22" height="21"> '.$MsgText[7][40];
	$BrowserTitle = $MsgText[7][40];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > <a href="'.$MainURL.'/admin/articles.html">'.$naSettings['Title'].'</a> > '.$MsgText[7][40];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[701] == 'y') {
			
			$Arguments3 = intval($Arguments3);
			
			if ($Arguments3 > 0) {
			
				$query = "select * from `".$Settings['DBPrefix']."na-Articles` where RecordNumber='".$Arguments3."' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$row = mysql_fetch_array($result);
					
					
					$PageTypeSelected[$row['PageType']] = ' selected';
					
					
				$CurrentCategoryID = $row['Category'];
				$CurrentCategoryID2 = $row['Category2'];
				$CurrentCategoryID3 = $row['Category3'];
				$CurrentCategoryID4 = $row['Category4'];
				$CurrentCategoryID5 = $row['Category5'];
				$CurrentCategoryID6 = $row['Category6'];
				$CurrentCategoryID7 = $row['Category7'];
				$CurrentCategoryID8 = $row['Category8'];
				$CurrentCategoryID9 = $row['Category9'];
				$CurrentCategoryID10 = $row['Category10'];
				
						
				$query2 = "select * from `".$Settings['DBPrefix']."na-Categories` ORDER BY CategoryName ASC";
				$result2 = mysql_query($query2) or die (mysql_error());
			
				while ($row2 = mysql_fetch_array($result2)) { 
	    	        
					$CategoryIDsArray[$row2['Parent']][] = $row2['RecordNumber'];
					$CategoryNamesArray[$row2['Parent']][] = $row2['CategoryName'];
				
				}
				
				
				
				$CategoryDropdown = '<option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown2 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown3 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown4 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown5 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown6 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown7 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown8 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown9 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				$CategoryDropdown10 = '<option value="0"></option><option value="0"> '.$MsgText[0][248].'</option>';
				
				
			
			$CatParent5 = 0;
			$LastParentAbove5 = '0';
			$CatLevel5['0'] = 0;
						
			function SpiderCategories5($CatParent5) {
				
				Global $CurrentCategoryID, $CurrentCategoryID2, $CurrentCategoryID3, $CurrentCategoryID4, $CurrentCategoryID5, $CategoryIDsArray, $CategoryNamesArray, $CategoryDropdown, $CategoryDropdown2, $CategoryDropdown3, $CategoryDropdown4, $CategoryDropdown5, $CategoryDropdown6, $CategoryDropdown7, $CategoryDropdown8, $CategoryDropdown9, $CategoryDropdown10, $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;\'------';
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;|------';
								$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
								$ResetAfter5 = 'y2';
							}
							else {
								//$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
								$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;';
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							$ResetAfter5 = 'n';
						}
										
					}
					
					
					if ($CurrentCategoryID == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID2 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown2 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID3 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown3 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID4 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown4 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID5 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown5 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID6 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown6 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID7 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown7 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID8 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown8 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID9 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown9 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';




					if ($CurrentCategoryID10 == $CategoryIDsArray[$CatParent5][$i]) {
						$Selected = ' selected';
					}
					else {
						$Selected = '';
					}
					
					$CategoryDropdown10 .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"'.$Selected.'> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';

					
										
					if (count($CategoryIDsArray[$CatParent5][$i]) > 0) {
						SpiderCategories5($CategoryIDsArray[$CatParent5][$i]);
					}
				
				
				} // end loop
				
				
			}
			
			SpiderCategories5('0');
					
					
					
					
										
					$TypeExtensions[1] = '.gif';
					$TypeExtensions[2] = '.jpg';
					$TypeExtensions[3] = '.png';
					
					
					$Directory = './images/articles/';

					if (is_dir($Directory)) {
						if ($dh = opendir($Directory)) {
				   			while (($file = readdir($dh)) !== false) {
								if ($file != '.' && $file != '..' && $file != 'index.html' && $file != '.htaccess' && substr($file,strlen($file)-10,6) != '-thumb') {
									if (filetype($Directory . $file) == 'dir') {
										//$DirectoriesArray[] = $dir.$file;
										//ReadDirectory($dir . $file.'/');
									}
									else {
										$FilesArray[] = $file;
										$FileSizesArray[] = filesize($Directory . $file);
										
										$ImageInfo = @getimagesize($Directory . $file);
							
										$ImageWidths[] = $ImageInfo[0];
										$ImageHeights[] = $ImageInfo[1];
										$FileTypes[] = $ImageInfo[2];
									}
								}
							}
							closedir($dh);
						}
					}
	
	
					for ($i = 0; $i < count($FilesArray); $i++) {
						for ($j = 0; $j < count($FilesArray)-1; $j++) {
				
							if ($FilesArray[$j] > $FilesArray[$j+1]) {
													
								$Swap1 = $FilesArray[$j+1];
								$Swap2 = $FileSizesArray[$j+1];
								$Swap3 = $ImageWidths[$j+1];
								$Swap4 = $ImageHeights[$j+1];
								$Swap5 = $FileTypes[$j+1];
							
								$FilesArray[$j+1] = $FilesArray[$j];
								$FileSizesArray[$j+1] = $FileSizesArray[$j];
								$ImageWidths[$j+1] = $ImageWidths[$j];
								$ImageHeights[$j+1] = $ImageHeights[$j];
								$FileTypes[$j+1] = $FileTypes[$j];
							
								$FilesArray[$j] = $Swap1;
								$FileSizesArray[$j] = $Swap2;
								$ImageWidths[$j] = $Swap3;
								$ImageHeights[$j] = $Swap4;
								$FileTypes[$j] = $Swap5;
													
							}
												
						}
				
					}
					
					
					for ($i = 0; $i < count($FilesArray); $i++) {
	
						if ($FileSizesArray[$i] > 1024) {
							$FileSizesArray[$i] /= 1024;
							
							if ($FileSizesArray[$i] > 1024) {
								$FileSizesArray[$i] /= 1024;
								
								$FileSizesArray[$i] = number_format($FileSizesArray[$i],1) . ' MB';
							}
							else {
								$FileSizesArray[$i] = number_format($FileSizesArray[$i],1) . ' KB';
							}
						}
						else {
							$FileSizesArray[$i] = $FileSizesArray[$i] . ' bytes';
						}
						
						//$ImageWidthsList .= 'ImageWidths[\''.$FilesArray[$i].'\'] = '.$ImageWidths[$i].';';
						//$ImageHeightsList .= 'ImageHeights[\''.$FilesArray[$i].'\'] = '.$ImageHeights[$i].';';
					
						if ($FilesArray[$i] == $row['Image'].$TypeExtensions[$row['ImageType']]) {
							$ImagesDropdown .= '<option value="'.$FilesArray[$i].'" selected> '.$FilesArray[$i].' ('.$ImageWidths[$i].'x'.$ImageHeights[$i].', '.$FileSizesArray[$i].')</option>';
						}
						else {
							$ImagesDropdown .= '<option value="'.$FilesArray[$i].'"> '.$FilesArray[$i].' ('.$ImageWidths[$i].'x'.$ImageHeights[$i].', '.$FileSizesArray[$i].')</option>';
						}
		
					}
					
					/*
					$CategoriesList = '<option value="0"> '.$MsgText[7][9].' (0)</option>';
					$query2 = "select * from `".$Settings['DBPrefix']."na-Categories` order by CategoryName";
					$result2 = mysql_query($query2) or die (mysql_error());
					while ($row2 = mysql_fetch_array($result2)) {
						if ($row2['RecordNumber'] == $row['Category']) {
							$CategoriesList .= '<option value="'.$row2['RecordNumber'].'" selected> '.$row2['CategoryName'].' ('.$row2['RecordNumber'].')</option>';
						}
						else {
							$CategoriesList .= '<option value="'.$row2['RecordNumber'].'"> '.$row2['CategoryName'].' ('.$row2['RecordNumber'].')</option>';
						}
					}
					*/
					
					
					
					//if (($row['Poster'] == $UserNumber && $ApprovedBy == '0') || $Permissions[702] == 'y') {
					if ($row['Poster'] == $UserNumber || $Permissions[702] == 'y') {
					
					
			/*		
			if (isset($Settings['EditorPreviousColors'])) {
				$LaunchEditorLink = '<script>
					var FlexBaseURL = \''.$BaseURL.'\';
					
					var FlexBGColor = \''.$Colors['BG'].'\';
					var FlexTextColor = \''.$Colors['Text'].'\';
					var FlexLinkColor = \''.$Colors['Link'].'\';
					var FlexALinkColor = \''.$Colors['ALink'].'\';
					var FlexVLinkColor = \''.$Colors['VLink'].'\';
					
					var FlexFontFace = \''.$FontFace.'\';
					var FlexFontSize = \''.$FontSize.'\';
					
					
					function LaunchEditor() {
						var WindowProperties = \'width=780,height=500,left=\' + (screen.width-780)/2 + \',top=\' + (screen.height-500)/2 + \',location=no,menubar=no,directories=no,toolbar=no,status=yes,scrollbars=no,resizable=yes\';

						var WindowCode = window.open(\''.$BaseURL.'/editor.html\',\'editor\',WindowProperties);
					}
					
					var BrowserName = navigator.appName;
					var BrowserVersion = navigator.appVersion;
					var BrowserUA = navigator.userAgent;
					
					//if (BrowserVersion.indexOf("MSIE") > -1 && (BrowserVersion.indexOf("MSIE 6.0b") > -1 || BrowserVersion.indexOf("MSIE 6.0") > -1 || BrowserVersion.indexOf("MSIE 5.5") > -1) && (BrowserUA.indexOf("Mac") == -1 && BrowserUA.indexOf("Windows CE") == -1 && BrowserUA.indexOf("Opera") == -1)) {
						document.write(\'<br><input type="button" value="'.$MsgText[7][14].'" onClick="LaunchEditor();" style="width: 450px; '.$FormStyle.'">\');
					//}
					//else {
					//	document.write("<br>'.$MsgText[0][565].'");
					//}
					</script>
					<br><br><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="2" alt=""><br>';
			}
			*/
						
				
						$row['Article'] = preg_replace("/\&([\#\d\w]{1,5})\;/i", "&amp;\\1;", $row['Article']);
						//$row['Article'] = str_replace('</textarea>', '&lt;/textarea>', $row['Article']);
						$row['Article'] = str_replace('<!--', '&lt;!--', $row['Article']);
						$row['Article'] = str_replace('</', '&lt;/', $row['Article']);
						
		
		
		
		if ($row['HidePostedDate'] == 1) {
			$HidePostedDateChecked = ' checked';
		}
		
			
		if ($row['SetPublishDate'] == 1) {
			$PublishDateSelected['Specify'] = ' selected';
		
			$DatePieces = getdate($row['PublishDate']);
			
			for ($d = 1; $d <= 31; $d++) {
				if ($DatePieces['mday'] == $d) {
					$Selected = ' selected';
				}
				else {
					$Selected = '';
				}
				
				$DaysSelect .= '<option value="'.$d.'"'.$Selected.'> '.$d.'</option>';				
			}
			for ($y = 2004; $y <= 2020; $y++) {
				if ($DatePieces['year'] == $y) {
					$Selected = ' selected';
				}
				else {
					$Selected = '';
				}
				$YearsSelect .= '<option value="'.$y.'"'.$Selected.'> '.$y.'</option>';
			}
			
			$HoursSelect = '<option value="0"> 12</option>';
			if ($DatePieces['hours'] > 11) {
				$DatePieces['hours'] -= 12;
				$PDAmPmSelected['pm'] = ' selected';
			} 
			for ($h = 1; $h <= 11; $h++) {
				if ($DatePieces['hours'] == $h) {
					$Selected = ' selected';
				}
				else {
					$Selected = '';
				}
				if ($h < 10) {
					$HoursSelect .= '<option value="'.$h.'"'.$Selected.'> &nbsp;&nbsp;'.$h.'</option>';
				}
				else {
					$HoursSelect .= '<option value="'.$h.'"'.$Selected.'> '.$h.'</option>';
				}
			}
			
			for ($m = 0; $m <= 59; $m++) {
				if ($DatePieces['minutes'] == $m) {
					$Selected = ' selected';
				}
				else {
					$Selected = '';
				}
				if ($m < 10) {
					$MinutesSelect .= '<option value="'.$m.'"'.$Selected.'> 0'.$m.'</option>';
				}
				else {
					$MinutesSelect .= '<option value="'.$m.'"'.$Selected.'> '.$m.'</option>';
				}
			}
			$PDMonthSelected[$DatePieces['mon']] = ' selected';
			
			$PublishDateString = '<select name="PDMonth"><option value="1"'.$PDMonthSelected[1].'> '.$MsgText[0][284].'</option><option value="2"'.$PDMonthSelected[2].'> '.$MsgText[0][285].'</option><option value="3"'.$PDMonthSelected[3].'> '.$MsgText[0][286].'</option><option value="4"'.$PDMonthSelected[4].'> '.$MsgText[0][287].'</option><option value="5"'.$PDMonthSelected[5].'> '.$MsgText[0][288].'</option><option value="6"'.$PDMonthSelected[6].'> '.$MsgText[0][289].'</option><option value="7"'.$PDMonthSelected[7].'> '.$MsgText[0][290].'</option><option value="8"'.$PDMonthSelected[8].'> '.$MsgText[0][291].'</option><option value="9"'.$PDMonthSelected[9].'> '.$MsgText[0][292].'</option><option value="10"'.$PDMonthSelected[10].'> '.$MsgText[0][293].'</option><option value="11"'.$PDMonthSelected[11].'> '.$MsgText[0][294].'</option><option value="12"'.$PDMonthSelected[12].'> '.$MsgText[0][295].'</option></select>&nbsp;<select name="PDDay">'.$DaysSelect.'</select>&nbsp;<select name="PDYear">'.$YearsSelect.'</select> @ <select name="PDHour">'.$HoursSelect.'</select>:<select name="PDMinute">'.$MinutesSelect.'</select>&nbsp;<select name="PDAmPm"><option value="am"> AM</option><option value="pm"'.$PDAmPmSelected['pm'].'> PM</option></select>';
		}
		else {
			
			$DaysSelect = '';
			$CurrentDay = date('j',GetTimestamp());
			for ($d = 1; $d <= 31; $d++) {
				if ($CurrentDay == $d) {
					$ItemSelected = ' selected';
				}
				else {
					$ItemSelected = '';
				}		
					
				$DaysSelect .= '<option value="'.$d.'"'.$ItemSelected.'> '.$d.'</option>';
			}
			
			$MonthsSelect = '';
			$CurrentMonth = date('n',GetTimestamp());
			for ($m = 1; $m <= 12; $m++) {
				if ($CurrentMonth == $m) {
					$ItemSelected = ' selected';
				}
				else {
					$ItemSelected = '';
				}
						
				$MonthsSelect .= '<option value="'.$m.'"'.$ItemSelected.'> '.$MsgText[0][(283+$m)].'</option>';			
			}
			
			$YearsSelect = '';
			$CurrentYear = date('Y',GetTimestamp());
			for ($y = 2004; $y <= 2020; $y++) {
				if ($CurrentYear == $y) {
					$ItemSelected = ' selected';
				}
				else {
					$ItemSelected = '';
				}
				
				$YearsSelect .= '<option value="'.$y.'"'.$ItemSelected.'> '.$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>';
				}
			}
			
			$MinutesSelect = '';
			for ($m = 0; $m <= 59; $m++) {
				if ($m < 10) {
					$MinutesSelect .= '<option value="'.$m.'"> 0'.$m.'</option>';
				}
				else {
					$MinutesSelect .= '<option value="'.$m.'"> '.$m.'</option>';
				}
			}
			
			$PublishDateString = '<select name="PDMonth">'.$MonthsSelect.'</select>&nbsp;<select name="PDDay">'.$DaysSelect.'</select>&nbsp;<select name="PDYear">'.$YearsSelect.'</select> @ <select name="PDHour">'.$HoursSelect.'</select>:<select name="PDMinute">'.$MinutesSelect.'</select>&nbsp;<select name="PDAmPm"><option value="am"> AM</option><option value="pm"> PM</option></select>';
		}
			
			
			
						
				
						$PageContents .= '<br><form name="PostForm" action="'.$MainURL.'/admin/articles-edit-save" method="post" enctype="multipart/form-data"><input type="hidden" name="ArticleIDToEdit" value="'.$Arguments3.'">
		
<b>'.$MsgText[7][15].':</b><br><input type="text" name="Title" size="50" value="'.str_replace('"','&#34;',$row['Title']).'" style="'.$FormStyle.'"><br>

<b>'.$MsgText[7][16].':</b><br><input type="text" name="Subtitle" size="50" value="'.str_replace('"','&#34;',$row['Subtitle']).'" style="'.$FormStyle.'"><br><br>

<b>'.$MsgText[7][17].':</b><br><textarea name="Teaser" cols="50" rows="3" wrap="virtual" style="width: 450px; '.$FormStyle.'">'.str_replace('</textarea>','&#lt;/textarea>',$row['Teaser']).'</textarea><br><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/" ;

			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;
	}
}
</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>
</select><br>

<br><b>'.$MsgText[7][18].':</b><br>


<div id="EditorDiv"><textarea id="PageContents" name="PageContents" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual">'.$row['Article'].'</textarea></div><div id="NonEditorDiv" style="display: none;"><textarea id="PageContents2" name="PageContents2" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual">'.$row['Article'].'</textarea></div>
					
<script>var FlexCMSScriptName="'.$Settings['ScriptName'].'";</script><script type="text/javascript" src="'.$BaseURL.'/fckeditor/fckeditor.js"></script><script>UpdatePageType();</script><br><br>
					
					
					

<b>'.$MsgText[7][90].':</b><br><textarea name="ArticleFooter" cols="50" rows="2" wrap="virtual" style="width:450px; '.$FormStyle.'">'.$row['ArticleFooter'].'</textarea><br><font size="1">'.$MsgText[7][91].'<br></font>

					<br><br>
					
					<b>'.$MsgText[7][92].':</b><br><input type="text" name="Source" size="50" style="'.$FormStyle.'" value="'.str_replace('"','&#34;',$row['Source']).'"><br>

<b>'.$MsgText[7][93].':</b><br><input type="text" name="SourceLink" size="50" style="'.$FormStyle.'" value="'.str_replace('"','&#34;',$row['SourceLink']).'"><br><font size="1">'.$MsgText[7][94].'<br></font>



<br><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>


					<script>
					function UpdatePreview() {
						if (document.forms[\'PostForm\'].elements[\'FileData\'].value != \'\' || document.forms[\'PostForm\'].elements[\'ImagesList\'].value == \'\') {
							document.getElementById(\'ImagePreview\').src = \''.$ImagesURL.'/admin/spacer.gif\';
						}
						else {
							var ThumbFile = \'\';
							var FilePieces = document.forms[\'PostForm\'].elements[\'ImagesList\'].value.split(\'.\');
							for (i=0; i<(FilePieces.length-1); i++) {
								if (ThumbFile != \'\') {
									ThumbFile=ThumbFile+\'.\';
								}
								ThumbFile=ThumbFile+FilePieces[i];
							}
							
							ThumbFile=ThumbFile+\'-thumb.\'+FilePieces[FilePieces.length-1];
						
							document.getElementById(\'ImagePreview\').src = \''.$ImagesURL.'/articles/\'+ThumbFile;
						}
					}
					</script>
						<br><table border="0" cellpadding="0" cellspacing="0"><tr>
      						<td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[7][19].':</b><br><select name="ImagesList" onChange="UpdatePreview();" style="'.$FormStyle.'"><option value="">'.$MsgText[7][39].'</option>'.$ImagesDropdown.'</select>
						<br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="5" alt="" border="0"><br>'.$MsgText[7][20].':<br><input type="file" name="FileData" onChange="UpdatePreview();" style="'.$FormStyle.'"><br>&nbsp;&nbsp;&nbsp;&nbsp;'.$MsgText[7][21].':<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="NewName" value="Previous" checked> '.$MsgText[7][22].'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="NewName" value="Random"> '.$MsgText[7][23].'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="NewName" value="Enter"> '.$MsgText[7][24].': <input type="text" name="NewNameEnter" size="15" style="'.$FormStyle.'"></td>
						    <td><img src="'.$ImagesURL.'/admin/spacer.gif" width="35" height="'.$naSettings['ThumbMaxHeight'].'" alt="" border="0"></td>
							<td><img name="ImagePreview" id="ImagePreview" src="'.$ImagesURL.'/admin/spacer.gif" border="0"></td>
					    </tr></table>
						<script>UpdatePreview();</script>
						<br>
						<b>'.$MsgText[7][25].':</b><br><input type="text" name="ImageCaption" size="50" value="'.str_replace('"','&#34;',$row['ImageCaption']).'" style="'.$FormStyle.'"><br>
						
						<br><br>
						<b>'.$MsgText[7][26].':</b><br>
						<select name="Category" style="'.$FormStyle.'">'.$CategoryDropdown.'</select><br>
						<select name="Category2" style="'.$FormStyle.'">'.$CategoryDropdown2.'</select><br>
						<select name="Category3" style="'.$FormStyle.'">'.$CategoryDropdown3.'</select><br>
						<select name="Category4" style="'.$FormStyle.'">'.$CategoryDropdown4.'</select><br>
						<select name="Category5" style="'.$FormStyle.'">'.$CategoryDropdown5.'</select><br>
						<select name="Category6" style="'.$FormStyle.'">'.$CategoryDropdown6.'</select><br>
						<select name="Category7" style="'.$FormStyle.'">'.$CategoryDropdown7.'</select><br>
						<select name="Category8" style="'.$FormStyle.'">'.$CategoryDropdown8.'</select><br>
						<select name="Category9" style="'.$FormStyle.'">'.$CategoryDropdown9.'</select><br>
						<select name="Category10" style="'.$FormStyle.'">'.$CategoryDropdown10.'</select>

						<br><br><br><br>
						
						<b>Publish Date:</b>&nbsp;&nbsp;<select name="PublishDate" id="PublishDate" onClick="UpdatePDDiv(this.value);" onChange="UpdatePDDiv(this.value);"><option value="UseActual"> When Article Was Submitted</option><option value="Specify"'.$PublishDateSelected['Specify'].'> Specify Date & Time Below</option></select><br><br>
					
					<div id="SpecifyPublishDate"><b>'.$MsgText[0][271].':</b> '.date('F jS Y @ g:i:s A',GetTimestamp()).'<br><br>'.$PublishDateString.'<br><br><br></div>
					
					<script>
					function UpdatePDDiv(PDValue) {
						if (PDValue == "UseActual") {
							document.getElementById("SpecifyPublishDate").style.display = "none";
						}
						else {
							document.getElementById("SpecifyPublishDate").style.display = "";
						}
					}
					
					UpdatePDDiv(document.getElementById("PublishDate").value);
					</script>
					
					<b>Hide Date Posted:</b>&nbsp;&nbsp;<input type="checkbox" name="HidePostedDate" value="1"'.$HidePostedDateChecked.'><br><br><br>';
					
						
						
						if ($Permissions[702] == 'y') {
							if ($row['ApprovedBy'] != '0') {
								$ApprovedChecked = ' checked';
							}
							$PageContents .= '<b>'.$MsgText[7][38].':</b>&nbsp;&nbsp;<input type="checkbox" name="Approved" value="y"'.$ApprovedChecked.'><br><br>';
						}
						
							
						$PageContents .= '<br><b>'.$MsgText[7][37].':</b> &nbsp;<input type="checkbox" name="DeleteArticle" value="y"><br><br>
						
						<br><br><input type="submit" value="'.$MsgText[0][123].'" style="'.$FormStyle.'"><input type="hidden" name="MAX_FILE_SIZE" value="'.number_format(($Settings['MaxImageFileSize']*1024),0,'','').'"></form>';
				
					}
					else {
					
						$PageContents = $MsgText[7][36];
				
					}
				}
				else {
					$PageContents = $MsgText[7][35];
				}
			
			}
			else {
				$PageContents = $MsgText[7][35];
			}
			
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}
		


?>
