<?

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



	// ========================================================================================
	// manage news/articles
	// ========================================================================================
	
	/*$query = "select * from `".$Settings['DBPrefix']."na-Settings`";
	$result = mysql_query($query) or die (mysql_error());
	while ($row = mysql_fetch_array($result)) {
		$nlSettings[$row['Name']] = $row['Value'];
	}*/
	
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_articles.gif" width="22" height="21"> '.$MsgText[7][2];
	$BrowserTitle = $MsgText[7][2];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[7][2];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[701] == 'y') {
			
			
					$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].';';
					

						$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)) {
						$CategoriesList .= '<option value="'.$row2['RecordNumber'].'"> '.$row2['CategoryName'].' ('.$row2['RecordNumber'].')</option>';
					}
			
			
			
			
			$query = "select * from `".$Settings['DBPrefix']."na-Categories` ORDER BY CategoryName ASC";
			$result = mysql_query($query) or die (mysql_error());
			
			while ($row = mysql_fetch_array($result)) { 
	            
				$CategoryIDsArray[$row['Parent']][] = $row['RecordNumber'];
				$CategoryNamesArray[$row['Parent']][] = $row['CategoryName'];
				$CategoryDescriptionsArray[$row['Parent']][] = $row['CategoryDescription'];
				$CategoryExists[$row['RecordNumber']] = 'y';
								
			}
			
			
				
			if ($Permissions[702] == 'y') {
			
				if ($Permissions[703] == 'y') {
					$NewCatLink = ' | <a href="#newcat">'.$MsgText[7][6].'</a>';
				}			
				
				$PageContents .= '<a href="#new">'.$MsgText[7][7].'</a>'.$NewCatLink.'<br><br><br><b>'.$MsgText[7][8].':</b><br>';
				
			
			
			
			$query = "select * from `".$Settings['DBPrefix']."na-Articles` order by Title asc";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
			
				// if the page has been orphaned, put it back in top level
				if ($CategoryExists[$row['Category']] != 'y' && $CategoryExists[$row['Category2']] != 'y' && $CategoryExists[$row['Category3']] != 'y' && $CategoryExists[$row['Category4']] != 'y' && $CategoryExists[$row['Category5']] != 'y' && $CategoryExists[$row['Category6']] != 'y' && $CategoryExists[$row['Category7']] != 'y' && $CategoryExists[$row['Category8']] != 'y' && $CategoryExists[$row['Category9']] != 'y' && $CategoryExists[$row['Category10']] != 'y') {
					$row['Category'] = 0;
				}
            	
				
				if ($Permissions[702] == 'y' && $row['ApprovedBy'] == 0) {
					$row['Title'] .= ' <font color="#ff0000">('.$MsgText[7][89].')</font>';
				}
				
				
				$ArticleIDsArray[$row['Category']][] = $row['RecordNumber'];
				$ArticleTitlesArray[$row['Category']][] = $row['Title'];
				$ArticleDescriptionsArray[$row['Category']][] = $row['Subtitle'];
				
				
								
				if ($row['Category2'] > 0) {
					$ArticleIDsArray[$row['Category2']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category2']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category2']][] = $row['Subtitle'];
				}
				if ($row['Category3'] > 0) {
					$ArticleIDsArray[$row['Category3']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category3']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category3']][] = $row['Subtitle'];
				}
				if ($row['Category4'] > 0) {
					$ArticleIDsArray[$row['Category4']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category4']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category4']][] = $row['Subtitle'];
				}
				if ($row['Category5'] > 0) {
					$ArticleIDsArray[$row['Category5']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category5']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category5']][] = $row['Subtitle'];
				}
				if ($row['Category6'] > 0) {
					$ArticleIDsArray[$row['Category6']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category6']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category6']][] = $row['Subtitle'];
				}
				if ($row['Category7'] > 0) {
					$ArticleIDsArray[$row['Category7']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category7']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category7']][] = $row['Subtitle'];
				}
				if ($row['Category8'] > 0) {
					$ArticleIDsArray[$row['Category8']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category8']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category8']][] = $row['Subtitle'];
				}
				if ($row['Category9'] > 0) {
					$ArticleIDsArray[$row['Category9']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category9']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category9']][] = $row['Subtitle'];
				}
				if ($row['Category10'] > 0) {
					$ArticleIDsArray[$row['Category10']][] = $row['RecordNumber'];
					$ArticleTitlesArray[$row['Category10']][] = $row['Title'];
					$ArticleDescriptionsArray[$row['Category10']][] = $row['Subtitle'];
				}
				
			}
			
			
			/*
			$CatsPrint .= '<br><div align="center"><table width="98%" border="0" cellpadding="1" cellspacing="0"><tr><td bgcolor="#c0c0c0">
				<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td bgcolor="#f4f4f4"><font size="2" face="Arial" color="#484848"><b>'.$MsgText[0][248].'</b></font><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="5" alt="" border="0"><br>';
			*/
			
			$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/plus.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.'" style="display: none;"><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, $LinkURLsArray, $ArticleTitlesArray, $ArticleDescriptionsArray, $ArticleIDsArray, $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[703] == 'y') {
						//$CatEditLink = ' - <a href="'.$MainURL.'/admin/articles-cat-edit/'.$CategoryIDsArray[$CatParent][$i].'.html"><font color="#484848">Edit Category</font></a>';
						$CatEditLink = '&nbsp;&nbsp;&nbsp;<font size="1"><a href="'.$MainURL.'/admin/articles-cat-edit/'.$CategoryIDsArray[$CatParent][$i].'.html">'.$MsgText[0][661].'</a></a>';
					}
			
		
					/*
					$CatsPrint .= '<br><div align="center"><table width="98%" border="0" cellpadding="1" cellspacing="0"><tr><td bgcolor="#c0c0c0">

<table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td bgcolor="#f4f4f4">

<font size="2" face="Arial" color="#484848"><b>'.$CategoryNamesArray[$CatParent][$i].'</b>'.$CatEditLink.$CategoryDescriptionsArray[$CatParent][$i].'</font><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="5" alt="" border="0"><br>';
					*/
					
					$ItemsCount++;
										
					if ($CategoryDescriptionsArray[$CatParent][$i] != '') {
						$CategoryDescriptionsArray[$CatParent][$i] = '<br>' . $CategoryDescriptionsArray[$CatParent][$i];
					}
					
					$CatsPrint .= '<img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="10" 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><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($ArticleIDsArray[$CategoryIDsArray[$CatParent][$i]]); $x++) {
											
						/*
						$CatsPrint .= '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="2" alt="" border="0"></td></tr><tr><td bgcolor="#d0d0d0"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="1" alt="" border="0"></td></tr><tr><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="2" alt="" border="0"></td></tr></table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td colspan="2" width="100%"><font size="2" face="Arial" color="#484848"><b>'.$ArticleTitlesArray[$CategoryIDsArray[$CatParent][$i]][$x].'</b></font></td>
      <td rowspan="2" width="75" align="center"><img src="'.$ImagesURL.'/admin/spacer.gif" width="75" height="1" alt="" border="0"><br><table width="75" border="0" cellpadding="0" cellspacing="0"><tr><td width="50%" align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/articles/view/'.$ArticleIDsArray[$CategoryIDsArray[$CatParent][$i]][$x].'.html" target="_blank"><img src="'.$ImagesURL.'/admin/pages_view.gif" border="0" width="16" height="16" alt=""><br><font color="#484848">'.$MsgText[0][249].'</font></a></td><td width="50%" align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/admin/articles-edit/'.$ArticleIDsArray[$CategoryIDsArray[$CatParent][$i]][$x].'.html"><img src="'.$ImagesURL.'/admin/pages_edit.gif" border="0" width="16" height="16" alt=""><br><font color="#484848">'.$MsgText[0][155].'</font></a></td></tr></table></td>
    </tr>
    <tr>
      <td width="65%"><font size="2" face="Arial" color="#484848">'.$LinkDescriptionsArray[$CategoryIDsArray[$CatParent][$i]][$x].'</font></td>
      <td width="35%"><font size="2" face="Arial" color="#484848">'.$LinkURLsArray[$CategoryIDsArray[$CatParent][$i]][$x].'</font></td>
    </tr>
</table>';
						*/
						
						
						if ($ArticleDescriptionsArray[$CategoryIDsArray[$CatParent][$i]][$x] != '') {
							
							if (strlen($ArticleDescriptionsArray[$CategoryIDsArray[$CatParent][$i]][$x]) > 70) {
								$ArticleDescriptionsArray[$CategoryIDsArray[$CatParent][$i]][$x] = substr($ArticleDescriptionsArray[$CategoryIDsArray[$CatParent][$i]][$x],0,70).'...';
							}
						
							$ArticleDescriptionsArray[$CategoryIDsArray[$CatParent][$i]][$x] = '<br><font size="1">'.$ArticleDescriptionsArray[$CategoryIDsArray[$CatParent][$i]][$x].'</font>';
						}
						

						$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/articles-edit/'.$ArticleIDsArray[$CategoryIDsArray[$CatParent][$i]][$x].'.html" style="text-decoration: none;"><b>'.$ArticleTitlesArray[$CategoryIDsArray[$CatParent][$i]][$x].'</b></a>'.$ArticleDescriptionsArray[$CategoryIDsArray[$CatParent][$i]][$x].'</font></td><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="20" height="1" alt="" border="0"></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.'/articles/view/'.$ArticleIDsArray[$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/articles-edit/'.$ArticleIDsArray[$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></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br>';
						
						
					
					}
					
					
					/*
					$CatsPrint .= '</td></tr></table>

						</td></tr></table></div>';
					*/
					
					$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');
			
			
			
			if (count($ArticleIDsArray[0]) > 0) {
								
				for ($x = 0; $x < count($ArticleIDsArray[0]); $x++) {
											
						
					/*
					$CatsPrint .= '<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="2" alt="" border="0"></td></tr><tr><td bgcolor="#d0d0d0"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="1" alt="" border="0"></td></tr><tr><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="2" alt="" border="0"></td></tr></table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td colspan="2" width="100%"><font size="2" face="Arial" color="#484848"><b>'.$ArticleTitlesArray[0][$x].'</b></font></td>
      <td rowspan="2" width="75" align="center"><img src="'.$ImagesURL.'/admin/spacer.gif" width="75" height="1" alt="" border="0"><br><table width="75" border="0" cellpadding="0" cellspacing="0"><tr><td width="50%" align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/articles/view/'.$ArticleIDsArray[0][$x].'.html" target="_blank"><img src="'.$ImagesURL.'/admin/pages_view.gif" border="0" width="16" height="16" alt=""><br><font color="#484848">'.$MsgText[0][249].'</font></a></td><td width="50%" align="center"><font size="1" face="Arial"><a href="'.$MainURL.'/admin/articles-edit/'.$ArticleIDsArray[0][$x].'.html"><img src="'.$ImagesURL.'/admin/pages_edit.gif" border="0" width="16" height="16" alt=""><br><font color="#484848">'.$MsgText[0][155].'</font></a></td></tr></table></td>
    </tr>
    <tr>
      <td width="65%"><font size="2" face="Arial" color="#484848">'.$LinkDescriptionsArray[0][$x].'</font></td>
      <td width="35%"><font size="2" face="Arial" color="#484848">'.$LinkURLsArray[0][$x].'</font></td>
    </tr>
</table>';
					*/
					
					if ($ArticleDescriptionsArray[0][$x] != '') {
							
						if (strlen($ArticleDescriptionsArray[0][$x]) > 70) {
							$ArticleDescriptionsArray[0][$x] = substr($ArticleDescriptionsArray[0][$x],0,70).'...';
						}
						
						$ArticleDescriptionsArray[0][$x] = '<br><font size="1">'.$ArticleDescriptionsArray[0][$x].'</font>';
					}
					

			
					$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/articles-edit/'.$ArticleIDsArray[0][$x].'.html" style="text-decoration: none;"><b>'.$ArticleTitlesArray[0][$x].'</b></a>'.$ArticleDescriptionsArray[0][$x].'</font></td><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="20" height="1" alt="" border="0"></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.'/articles/view/'.$ArticleIDsArray[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/articles-edit/'.$ArticleIDsArray[0][$x].'.html"><img src="'.$ImagesURL.'/admin/pages_edit.gif" border="0" width="16" height="16" alt=""><br>'.$MsgText[0][155].'</a></td></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br>';
					
					

				}
					
			}
			
			
			
			
			/*
			$CatsPrint .= '</td></tr></table>
				</td></tr></table></div>';
			*/
			
			$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 .= '<a href="#new">'.$MsgText[7][7].'</a><br><br>';
			
			
				$query = "select * from `".$Settings['DBPrefix']."na-Articles` where Poster='".$UserNumber."' and ApprovedBy=0 order by DateCode desc";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
				
					$PageContents .= '<br><b>'.$MsgText[7][13].':</b><br><br><table cellpadding="1" cellspacing="0" border="0">';
												
					while ($row = mysql_fetch_array($result)) {	
				
						$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$MainURL.'/admin/articles-edit/'.$row['RecordNumber'].'.html"><b>'.$row['Title'].'</b></a><br><font size="1">'.$MsgText[7][10].': '.date("F j, Y",$row['DateCode']).'<br></font></td><td><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;&nbsp;</td></tr><tr><td colspan="2" height="10"></td></tr>';	
			
					}
				
					$PageContents .= '</table>';
					
				}
				
				
				$query = "select * from `".$Settings['DBPrefix']."na-Articles` where Poster='".$UserNumber."' and ApprovedBy>0 order by DateCode desc";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
				
					$PageContents .= '<br><b>'.$MsgText[7][88].':</b><br><br><table cellpadding="1" cellspacing="0" border="0">';
												
					while ($row = mysql_fetch_array($result)) {	
				
						$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$MainURL.'/admin/articles-edit/'.$row['RecordNumber'].'.html"><b>'.$row['Title'].'</b></a><br><font size="1">'.$MsgText[7][10].': '.date("F j, Y",$row['DateCode']).'<br></font></td><td><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;&nbsp;</td></tr><tr><td colspan="2" height="10"></td></tr>';	
			
					}
				
					$PageContents .= '</table>';
					
				}
							
				
			}
			
			
			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>';
			}
			
			
			
			$CategoryDropdown = '<option value="0"> '.$MsgText[0][248].'</option>';
			
			
			$CatParent5 = 0;
			$LastParentAbove5 = '0';
			$CatLevel5['0'] = 0;
						
			function SpiderCategories5($CatParent5) {
				
				Global $CategoryIDsArray, $CategoryNamesArray, $CategoryDescriptionsArray, $CategoryDropdown, $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';
						}
										
					}
					
					
					
					$CategoryDropdown .= '<option value="'.$CategoryIDsArray[$CatParent5][$i].'"> '.$CatSpacer5.' '.$CategoryNamesArray[$CatParent5][$i].'</option>';
					
										
					if (count($CategoryIDsArray[$CatParent5][$i]) > 0) {
						SpiderCategories5($CategoryIDsArray[$CatParent5][$i]);
					}
				
				}
				
				
			}
			
			SpiderCategories5('0');	
			
			
			
			$PageContents .= '<br><br><a name="new"></a><b>'.$MsgText[7][7].':</b><form name="PostForm" method="post" action="'.$MainURL.'/admin/articles-new-save" enctype="multipart/form-data">
		
<b>'.$MsgText[7][15].':</b><br><input type="text" name="Title" size="50" style="'.$FormStyle.'"><br>

<b>'.$MsgText[7][16].':</b><br><input type="text" name="Subtitle" size="50" style="'.$FormStyle.'"><br><br>

<b>'.$MsgText[7][17].':</b><br><textarea name="Teaser" cols="50" rows="3" wrap="virtual" style="width: 450px; '.$FormStyle.'"></textarea><br><br>

<b>'.$MsgText[7][18].':</b><br><textarea name="PageContents" cols="50" rows="8" wrap="virtual" style="width:450px; '.$FormStyle.'"></textarea>



					'.$LaunchEditorLink.'<br>
					
					
					

<b>'.$MsgText[7][90].':</b><br><textarea name="ArticleFooter" cols="50" rows="2" wrap="virtual" style="width:450px; '.$FormStyle.'"></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.'"><br>

<b>'.$MsgText[7][93].':</b><br><input type="text" name="SourceLink" size="50" style="'.$FormStyle.'"><br><font size="1">'.$MsgText[7][94].'<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" style="'.$FormStyle.'"><br>
						
						<br><br>
						<b>'.$MsgText[7][26].':</b><br>
						<select name="Category" style="'.$FormStyle.'">'.$CategoryDropdown.'</select><br>
						<select name="Category2" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select><br>
						<select name="Category3" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select><br>
						<select name="Category4" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select><br>
						<select name="Category5" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select><br>
						<select name="Category6" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select><br>
						<select name="Category7" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select><br>
						<select name="Category8" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select><br>
						<select name="Category9" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select><br>
						<select name="Category10" style="'.$FormStyle.'"><option value="0"></option>'.$CategoryDropdown.'</select>
						
						<br><br><br>

';
			if ($Permissions[702] == 'y') {
				$PageContents .= '<b>'.$MsgText[7][27].':</b>&nbsp;&nbsp;<input type="checkbox" name="ApproveArticle" value="y" checked><br><br>';
			}
			

			$PageContents .= '<br><input type="submit" value="'.$MsgText[7][28].'" style="'.$FormStyle.'"></form><br><br><br><br>';
			
			
			if ($Permissions[703] == 'y') {
				$PageContents .= '<a name="newcat"></a><b>'.$MsgText[7][6].':</b><form name="CatForm" method="post" action="'.$MainURL.'/admin/articles-cat-new-save">
		
<b>'.$MsgText[7][29].':</b><br><input type="text" name="CategoryName" size="50" style="'.$FormStyle.'">
<br><br>
<b>'.$MsgText[7][95].':</b><br><input type="text" name="CategoryDescription" size="50" style="'.$FormStyle.'">
<br><br>
<b>'.$MsgText[7][26].':</b><br><select name="Parent" style="'.$FormStyle.'">'.$CategoryDropdown.'</select><br>
<br><br><input type="submit" value="'.$MsgText[7][30].'" style="'.$FormStyle.'"></form>';

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

	}
	else {
	
		RedirectToLogin();
	
	}
		


?>
