<?

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


		
$PageTitle = $MsgText[0][697];
$BrowserTitle = $MsgText[0][697];
$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL.'/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[0][697];
	
if ($LoggedIn == 'y') {
		
	ReadPermissions();
	Global $Permissions;
		
	if ($Permissions[26] == 'y') {
	
	
		$PHPMaxFileSize = ini_get('upload_max_filesize');
		if (strtoupper(substr($PHPMaxFileSize,strlen($PHPMaxFileSize)-1,1)) == 'K') {
			// number is Kbytes so convert it
			$PHPMaxFileSize = ($PHPMaxFileSize * 1024);
		}
		else if (strtoupper(substr($PHPMaxFileSize,strlen($PHPMaxFileSize)-1,1)) == 'M') {
			// number is Mbytes so convert it
			$PHPMaxFileSize = ($PHPMaxFileSize * 1024 * 1024);
		}
		else if (strtoupper(substr($PHPMaxFileSize,strlen($PHPMaxFileSize)-1,1)) == 'G') {
			// good luck uploading a gig through a browser lol ...
			$PHPMaxFileSize = ($PHPMaxFileSize * 1024 * 1024 * 1024);
		}
			
			
		if ($PHPMaxFileSize < ($Settings['FileManagerMaxFileSize']*1024) && $PHPMaxFileSize > 0) {
			// PHP has a limit set, and it's smaller than Flex's
			$MaxFileSize = number_format($PHPMaxFileSize,0,'','');				
		}
		else if ($Settings['FileManagerMaxFileSize'] > 0) {
			// Flex's limit is the smaller one, but is > 0
			$MaxFileSize = number_format(($Settings['FileManagerMaxFileSize']*1024),0,'','');
		}
		else {
			// default to 2m if neither can be located
			$MaxFileSize = 2097152;				
		}
	
	
	
		
		if (strpos($Arguments3,'u') === false) {	
	
					
			
			$TileWidth = 106;
			$TileHeight = 118;
			$TileHeight2 = 100;
		
			$TileSpacing = 3;
			
			
			
			$FileSpecificIcon['pdf'] = 'pdf';
			
			$FileSpecificIcon['doc'] = 'doc';
			$FileSpecificIcon['docx'] = 'doc';
			
			$FileSpecificIcon['xls'] = 'xls';
			$FileSpecificIcon['xlsx'] = 'xls';
			
			$FileSpecificIcon['ppt'] = 'ppt';
			$FileSpecificIcon['pps'] = 'ppt';
			
			$FileSpecificIcon['mov'] = 'qt';
			$FileSpecificIcon['m4v'] = 'qt';
			$FileSpecificIcon['qt'] = 'qt';
			$FileSpecificIcon['qtm'] = 'qtm';
			
			$FileSpecificIcon['psd'] = 'psd';
			
			$FileSpecificIcon['js'] = 'js';
			
			$FileSpecificIcon['htm'] = 'html';
			$FileSpecificIcon['html'] = 'html';
			
			$FileSpecificIcon['php'] = 'php';
			$FileSpecificIcon['php3'] = 'php';
			$FileSpecificIcon['php4'] = 'php';
			$FileSpecificIcon['php5'] = 'php';
			$FileSpecificIcon['phps'] = 'php';
			
			$FileSpecificIcon['mp3'] = 'mp3';
			
			
			
			
					
									
			$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="-1"> -1 - '.$MsgText[0][161].'</option><option value="0" selected> 0 - '.$MsgText[0][162].'</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>';
				}
			}
			
			
					
		
			
			$FolderTilesSection = '<div style="width: 100%; height: 20px; clear: left;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="5" height="1" alt="" border="0"><font face="Arial" size="2"><b>Folders:</b></font></div>';
			
			$CurrentLocation = str_replace('+++','/',$Arguments4);
			if ($CurrentLocation == '') {
				$CurrentLocation = '/';
			}
			
			if ($CurrentLocation != '/') {
				// not already at the top level
				
				$FolderTilesSection .= '<div align="center" style="float: left; width: '.($TileWidth+($TileSpacing*2)).'px; height: '.($TileHeight+($TileSpacing*2)).'px; background-color: #ffffff;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"><br><div style="width: '.$TileWidth.'px; height: '.$TileHeight.'; background-color: #ffffff; text-align: center; overflow: hidden; font-size: 10px; font-family: Arial;"><a href="javascript:SelectFolder(\'..\');" style="text-decoration: none;"><img src="'.$ImagesURL.'/admin/folder_icon_up.gif" width="102" height="77" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="'.($TileWidth-6).'" height="3" alt="" border="0"><br>Up a Level</a></div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"></div>';
																			
				$ThisFolderParent = substr($CurrentLocation,0,strrpos($CurrentLocation,'/')-1);
				
				
				// =====
				// start of location bar links
				$FileManagerLocationBar = '<a href="'.$MainURL.'/admin/filemanager/'.$Arguments3.'/+++" style="text-decoration: none;">[Top Level]</a> / ';
				$LocationBarURL = '/';
				// =====
				
				
				$CLPieces = explode('/',$CurrentLocation);
				$ThisFolderParent = '/';
				for ($x = 1; $x < (count($CLPieces)-2); $x++) {
					$ThisFolderParent .= $CLPieces[$x].'/';
					
					// =====
					// add to location bar links
					$LocationBarURL .= $CLPieces[$x].'/';
					$FileManagerLocationBar .= '<a href="'.$MainURL.'/admin/filemanager/'.$Arguments3.'/'.str_replace('/','+++',$LocationBarURL).'" style="text-decoration: none;">'.$CLPieces[$x].'</a> / ';	
					// =====			
				}				
				
				// =====
				// end of location bar links
				$FileManagerLocationBar .= $CLPieces[$x].' / ';
				// =====
				
								
				

				$ThisFolderName = $CLPieces[count($CLPieces)-2];
				
				//$PageContents .= 'This Folder: '.$ThisFolderName.'<br>This Folder Parent: '.$ThisFolderParent.'<br><br>CL0:'.$CLPieces[0].'<br>CL1:'.$CLPieces[1].'<br>CL2:'.$CLPieces[2].'<br>CL3:'.$CLPieces[3].'<br>CL4:'.$CLPieces[4].'<br>CL Pieces:'.count($CLPieces).'<br><br>';
								
				$query = "select * from `".$Settings['DBPrefix']."core-Folders` where Folder='".$ThisFolderName."' and Location='".$ThisFolderParent."' limit 1";
	   			$result = mysql_query($query) or die (mysql_error());
				$row = mysql_fetch_array($result);
				
				if ($row['AddFoldersLevel'] <= $UserLevel && $row['RecordNumber'] > 0) {
					$FolderTilesSection .= '<div align="center" style="float: left; width: '.($TileWidth+($TileSpacing*2)).'px; height: '.($TileHeight+($TileSpacing*2)).'px; background-color: #ffffff;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"><br><div style="width: '.$TileWidth.'px; height: '.$TileHeight.'; background-color: #ffffff; text-align: center; overflow: hidden; font-size: 10px; font-family: Arial;"><a href="javascript:ShowCreateFolder();" style="text-decoration: none;"><img src="'.$ImagesURL.'/admin/folder_icon_new.gif" width="102" height="77" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="'.($TileWidth-6).'" height="3" alt="" border="0"><br>Create Folder</a></div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"></div>';
				
				}
				else {
					if ($ShowDisabledFunctions == true) {	
						$FolderTilesSection .= '<div align="center" style="float: left; width: '.($TileWidth+($TileSpacing*2)).'px; height: '.($TileHeight+($TileSpacing*2)).'px; background-color: #ffffff;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"><br><div style="width: '.$TileWidth.'px; height: '.$TileHeight.'; background-color: #ffffff; text-align: center; overflow: hidden; font-size: 10px; font-family: Arial;"><a href="javascript:alert(\'Your current permissions do not allow you to create a folder here.\');" style="text-decoration: none;"><img src="'.$ImagesURL.'/folder_icon_new_greyed.gif" width="102" height="77" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="'.($TileWidth-6).'" height="3" alt="" border="0"><br>Create Folder</a></div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"></div>';
					}
				
				}
				
				if ($row['AddFilesLevel'] <= $UserLevel && $row['RecordNumber'] > 0) {
					$AllowedToAddFiles = true;				
				}
				else {
					$AllowedToAddFiles = false;
				}
				
			}
			else {
			
				$FileManagerLocationBar = '[Top Level] / ';
			
				$FolderTilesSection .= '<div align="center" style="float: left; width: '.($TileWidth+($TileSpacing*2)).'px; height: '.($TileHeight+($TileSpacing*2)).'px; background-color: #ffffff;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"><br><div style="width: '.$TileWidth.'px; height: '.$TileHeight.'; background-color: #ffffff; text-align: center; overflow: hidden; font-size: 10px; font-family: Arial;"><img src="'.$ImagesURL.'/admin/folder_icon_up_greyed.gif" width="102" height="77" alt="You are already at the top directory level" title="You are already at the top directory level" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="'.($TileWidth-6).'" height="3" alt="" border="0"><br>&nbsp;</div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"></div>';
			
			
			
				$query = "select * from `".$Settings['DBPrefix']."core-Folders` where Folder='/' and Location='' limit 1";
	   			$result = mysql_query($query) or die (mysql_error());
				$row = mysql_fetch_array($result);
				
				if ($row['AddFoldersLevel'] <= $UserLevel && $row['RecordNumber'] > 0) {
					$FolderTilesSection .= '<div align="center" style="float: left; width: '.($TileWidth+($TileSpacing*2)).'px; height: '.($TileHeight+($TileSpacing*2)).'px; background-color: #ffffff;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"><br><div style="width: '.$TileWidth.'px; height: '.$TileHeight.'; background-color: #ffffff; text-align: center; overflow: hidden; font-size: 10px; font-family: Arial;"><a href="javascript:ShowCreateFolder();" style="text-decoration: none;"><img src="'.$ImagesURL.'/admin/folder_icon_new.gif" width="102" height="77" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="'.($TileWidth-6).'" height="3" alt="" border="0"><br>Create Folder</a></div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"></div>';
				
				}
				else {
					if ($ShowDisabledFunctions == true) {
						$FolderTilesSection .= '<div align="center" style="float: left; width: '.($TileWidth+($TileSpacing*2)).'px; height: '.($TileHeight+($TileSpacing*2)).'px; background-color: #ffffff;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"><br><div style="width: '.$TileWidth.'px; height: '.$TileHeight.'; background-color: #ffffff; text-align: center; overflow: hidden; font-size: 10px; font-family: Arial;"><a href="javascript:alert(\'Your current permissions do not allow you to create a folder here.\');" style="text-decoration: none;"><img src="'.$ImagesURL.'/folder_icon_new_greyed.gif" width="102" height="77" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="'.($TileWidth-6).'" height="3" alt="" border="0"><br>Create Folder</a></div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"></div>';
					}
				
				}
				
				if ($row['AddFilesLevel'] <= $UserLevel && $row['RecordNumber'] > 0) {
					$AllowedToAddFiles = true;				
				}
				else {
					$AllowedToAddFiles = false;
				}
			
			}
			
			
			// folders
			$query = "select * from `".$Settings['DBPrefix']."core-Folders` where Location='".$CurrentLocation."' and ViewFilesLevel<='".$UserLevel."' order by Folder asc";
	   		$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
			
				if ($row['ModifyLevel'] <= $UserLevel) {
					$OptionsGroup = 'fm';
				}
				else {
					$OptionsGroup = 'f';
				}
				
				if ($row['ModifyLevel'] == 0) {
					$row['ModifyLevel'] = 1;
				}
				if ($row['AddFoldersLevel'] == 0) {
					$row['AddFoldersLevel'] = 1;
				}
				if ($row['AddFilesLevel'] == 0) {
					$row['AddFilesLevel'] = 1;
				}
				if ($row['ViewFilesLevel'] == 0) {
					$row['ViewFilesLevel'] = 1;
				}
				
				
				$JSFolderNamesArray .= 'FolderNamesArray['.$row['RecordNumber'].'] = "'.$row['Folder'].'";';
				
				$FolderModifyLevelsArray .= 'FolderModifyLevelsArray['.$row['RecordNumber'].'] = "'.$row['ModifyLevel'].'";';
				$FolderAddFoldersLevelsArray .= 'FolderAddFoldersLevelsArray['.$row['RecordNumber'].'] = "'.$row['AddFoldersLevel'].'";';
				$FolderAddFilesLevelsArray .= 'FolderAddFilesLevelsArray['.$row['RecordNumber'].'] = "'.$row['AddFilesLevel'].'";';
				$FolderViewLevelsArray .= 'FolderViewLevelsArray['.$row['RecordNumber'].'] = "'.$row['ViewFilesLevel'].'";';
				
											
				$FolderTilesSection .= '<div align="center" style="float: left; width: '.($TileWidth+($TileSpacing*2)).'px; height: '.($TileHeight+($TileSpacing*2)).'px; background-color: #ffffff;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"><br><div style="width: '.$TileWidth.'px; height: '.$TileHeight.'; background-color: #ffffff; text-align: center; overflow: hidden; font-size: 10px; font-family: Arial;"><a href="javascript:SelectFolder(\''.str_replace('/','+++',$row['Folder']).'\');" style="text-decoration: none;" onMouseOver="MouseIsIn(\''.$row['RecordNumber'].'\', \''.$row['Folder'].'\', \''.$OptionsGroup.'\');" onMouseOut="MouseIsOut();"><img src="'.$ImagesURL.'/admin/folder_icon.gif" width="102" height="77" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="'.($TileWidth-6).'" height="3" alt="" border="0"><br>'.$row['Folder'].'</a></div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"></div>';
				
			}
			
			
			
			
			
			
			if ($AllowedToAddFiles == true) {
							
				$InitSection .= '<script language="Javascript">
				document.getElementById("UploadFileBar").style.display = "";
				
				if (AvailableHeight > 0) {
					document.getElementById("MainTilesContainer").style.height=(AvailableHeight-140);
				}		
				</script>';
				
			}
			else {
							
				$InitSection .= '<script language="Javascript">
				if (AvailableHeight > 0) {
					document.getElementById("MainTilesContainer").style.height=(AvailableHeight-60);
				}		
				</script>';
			
			}
			
			
			
			// files
			
			if (strpos($Arguments3,'i') !== false) {
				// just images
				$query = "select * from `".$Settings['DBPrefix']."core-Files` where Location='".$CurrentLocation."' and FileType=3 and ViewLevel<='".$UserLevel."' order by Filename asc";
			}
			else if (strpos($Arguments3,'f') !== false) {
				// just flash 
				$query = "select * from `".$Settings['DBPrefix']."core-Files` where Location='".$CurrentLocation."' and FileType=7 and ViewLevel<='".$UserLevel."' order by Filename asc";
			}
			else {
				// all files
				$query = "select * from `".$Settings['DBPrefix']."core-Files` where Location='".$CurrentLocation."' and ViewLevel<='".$UserLevel."' order by Filename asc";
			}
	   		$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
			
						
				if ($row['ModifyLevel'] <= $UserLevel) {
					$OptionsGroup = 'm';
				}
				else {
					$OptionsGroup = '';
				}
				
				if ($row['ThumbnailExists'] == 1 && $row['ImageWidth'] > 0 && $row['ImageHeight'] > 0) {
					if (($row['ImageWidth']/$row['ImageHeight']) > .75) {
						$FileThumb = '<table width="102" height="77" cellpadding="0" cellspacing="0" border="0" style="border: 1px solid #9D9D9D" align="center"><tr><td bgcolor="#ffffff" align="center"><div align="center" style="width: 100%; height: 100%; text-decoration: none;" onMouseOver="MouseIsIn(\''.$row['RecordNumber'].'\', \''.$row['Filename'].'\', \''.$OptionsGroup.'\');" onMouseOut="MouseIsOut();" onClick="SelectFile(\''.$row['Filename'].'\');"><table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" valign="middle"><img src="'.$BaseURL.'/thumbnails/'.$row['RecordNumber'].'_'.$row['Filename'].'" alt="" border="0"></td></tr></table></div></td></tr></table>';
					}
					else {
						$FileThumb = '<table width="102" height="77" cellpadding="0" cellspacing="0" border="0" style="border: 1px solid #9D9D9D" align="center"><tr><td bgcolor="#ffffff" align="center"><div align="center" style="width: 100%; height: 100%; text-decoration: none;" onMouseOver="MouseIsIn(\''.$row['RecordNumber'].'\', \''.$row['Filename'].'\', \''.$OptionsGroup.'\');" onMouseOut="MouseIsOut();" onClick="SelectFile(\''.$row['Filename'].'\');"><img src="'.$BaseURL.'/thumbnails/'.$row['RecordNumber'].'_'.$row['Filename'].'" alt="" border="0"></div></td></tr></table>';
					}
				}
				else {
					if ($row['FileType'] == '') {
						$row['FileType'] = 0;
					}
					
					$FNPieces = explode('.',$row['Filename']);
					$FileExtension = $FNPieces[count($FNPieces)-1];
					
					if ($FileSpecificIcon[$FileExtension] != '') {
						$FileTypeIcon = $FileSpecificIcon[$FileExtension];
					}
					else {
						$FileTypeIcon = $row['FileType'];
					}
					
									
					$FileThumb = '<table width="102" height="77" cellpadding="0" cellspacing="0" border="0" style="border: 1px solid #9D9D9D" align="center"><tr><td bgcolor="#ffffff" align="center"><div align="center" style="width: 100%; height: 100%; text-decoration: none;" onMouseOver="MouseIsIn(\''.$row['RecordNumber'].'\', \''.$row['Filename'].'\', \''.$OptionsGroup.'\');" onMouseOut="MouseIsOut();" onClick="SelectFile(\''.$row['Filename'].'\');"><img src="'.$ImagesURL.'/admin/spacer.gif" width="100" height="2" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/filetypes_'.$FileTypeIcon.'.gif" alt="" border="0"></div></td></tr></table>';
				}
				
				
				$FileNameLength = 16;
				if (strlen($row['Filename']) > $FileNameLength) {
					$FileNamePrint = substr($row['Filename'], 0, ($FileNameLength-2)).'...';
				}
				else {
					$FileNamePrint = $row['Filename'];
				}
				
				
				$FileNamesArray .= 'FileNamesArray['.$row['RecordNumber'].'] = "'.str_replace('"','\\"',$row['Filename']).'";';
				
				$Ending = 'Bytes';
				$FileSizeCalc = $row['FileSize'];
				if ($FileSizeCalc >= 1024) {
					$FileSizeCalc = ($FileSizeCalc/1024);
					$Ending = 'KBytes';
				}
				if ($FileSizeCalc >= 1024) {
					$FileSizeCalc = ($FileSizeCalc/1024);
					$Ending = 'MBytes';
				}
				$FileSizePrint = number_format($FileSizeCalc,1).' '.$Ending;
				
				$FileSizesArray .= 'FileSizesArray['.$row['RecordNumber'].'] = "'.$FileSizePrint.'";';	
				
				
				if ($row['ImageWidth'] > 0) {
					$FileDimensionsArray .= 'FileDimensionsArray['.$row['RecordNumber'].'] = "'.$row['ImageWidth'].'x'.$row['ImageHeight'].'";';				
				}
				else {
					$FileDimensionsArray .= 'FileDimensionsArray['.$row['RecordNumber'].'] = "";';
				}
				
				
				$FileDatesArray .= 'FileDatesArray['.$row['RecordNumber'].'] = "'.date('l, F j, Y @ g:i:sa',$row['CreationDate']).'";';
				
				
				$ModifyLevelsArray .= 'ModifyLevelsArray['.$row['RecordNumber'].'] = "'.$row['ModifyLevel'].'";';
				$ViewLevelsArray .= 'ViewLevelsArray['.$row['RecordNumber'].'] = "'.$row['ViewLevel'].'";';
				
				
						
				
				if (strpos($Arguments3,'f') === false || strpos(strtolower($row['Filename']),'swf') !== false || strpos(strtolower($row['Filename']),'flv') !== false) {
					$FileTilesSection .= '<div align="center" style="float: left; width: '.($TileWidth+($TileSpacing*2)).'px; height: '.($TileHeight+($TileSpacing*2)).'px; background-color: #ffffff;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"><br><div align="center" style="width: '.$TileWidth.'px; height: '.$TileHeight2.'; background-color: #ffffff; text-align: center; overflow: hidden; text-decoration: none; font-size: 10px; font-family: Arial;" onMouseOver="MouseIsIn(\''.$row['RecordNumber'].'\', \''.$row['Filename'].'\', \''.$OptionsGroup.'\');" onMouseOut="MouseIsOut();" onClick="SelectFile(\''.$row['Filename'].'\');">'.$FileThumb.'<img src="'.$ImagesURL.'/admin/spacer.gif" width="'.($TileWidth-6).'" height="3" alt="" border="0"><br>'.$FileNamePrint.'</div><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="'.($TileSpacing-1).'" alt="" border="0"></div>';
				}
			
			}
			
			
			
			if ($FileTilesSection != '') {
				$FileTilesSection = '<div style="width: 100%; height: 20px; clear: left;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="5" height="1" alt="" border="0"><font face="Arial" size="2"><b>Files:</b></font></div>'.$FileTilesSection;
			}
			
			
			
			
			
			$query55 = "select * from `".$Settings['DBPrefix']."core-Folders` where ViewFilesLevel<='".$UserLevel."' ORDER BY Folder ASC";
			$result55 = mysql_query($query55) or die (mysql_error());
		
			while ($row55 = mysql_fetch_array($result55)) { 
            
				$FolderIDsArray[$row55['Location']][] = $row55['RecordNumber'];
				$FolderNamesArray[$row55['Location']][] = $row55['Folder'];
				$FolderExists[$row55['RecordNumber']] = 'y';
				$AddFilesLevelArray[$row55['Location']][] = $row55['AddFilesLevel'];
				
			}
			
						
			$MoveDestinationsList = '<option value="/"> /</option>';
			
			$CatParent5 = '/';
			$LastParentAbove5 = '/';
			$CatLevel5['/'] = 0;
						
			function SpiderCategories50($CatParent5) {
				
				Global $FolderIDsArray, $FolderNamesArray, $MoveDestinationsList, $LastParent5, $LastParentAbove5, $CatSpacersArray5, $CatLevel5, $CatsCount5, $CurrentLocation, $AddFilesLevelArray, $UserLevel;
				
				for ($i = 0; $i < count($FolderIDsArray[$CatParent5]); $i++) {
					
					$LastParentAboveB5 = $LastParentAbove5;
					$LastParentB5 = $LastParent5;
					
					$CatLevel5[$CatParent5.$FolderNamesArray[$CatParent5][$i].'/'] = $CatLevel5[$CatParent5];
					if ($CatParent5 != $LastParent5 && $CatParent5 == $LastParentAbove5) {
				
						$CatLevel5[$CatParent5.$FolderNamesArray[$CatParent5][$i].'/'] = $CatLevel5[$CatParent5] + 1;
						$CatLevel5[$CatParent5]++;
												
						$CatsCount5[$CatLevel5[$CatParent5]] = 0;
				
					}
					
					$LastParent5 = $CatParent5;
					$LastParentAbove5 = $CatParent5.$FolderNamesArray[$CatParent5][$i].'/';
					
					$CatsCount5[$CatLevel5[$CatParent5]]++;
					
										
					$CatSpacer5 = '';
					for ($x = 0; $x < $CatLevel5[$CatParent5]; $x++) {
						
						if ($CatsCount5[$CatLevel5[$CatParent5]] == count($CatParent5.$FolderNamesArray[$CatParent5][$i].'/') && $x == $CatLevel5[$CatParent5]-1) {
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							$ResetAfter5 = 'y';
						}
						else if ($CatsCount5[$CatLevel5[$CatParent5]] == count($CatParent5.$FolderNamesArray[$CatParent5][$i].'/')) {
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
						}
						else {
							if ($x < $CatLevel5[$CatParent5]) {
								$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&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;';
							}
						}
						
							
						$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;&nbsp;';
							$ResetAfter5 = 'n';
						}
										
					}
					
					
					if ($CatParent5.$FolderNamesArray[$CatParent5][$i].'/' == $CurrentLocation) {
						$MoveDestinationsList .= '<option value="'.$CatParent5.$FolderNamesArray[$CatParent5][$i].'/'.'" selected> '.$CatSpacer5.' '.$FolderNamesArray[$CatParent5][$i].'</option>';
					}
					else {
						$MoveDestinationsList .= '<option value="'.$CatParent5.$FolderNamesArray[$CatParent5][$i].'/'.'"> '.$CatSpacer5.' '.$FolderNamesArray[$CatParent5][$i].'</option>';
					}
					
									
					if (count($FolderIDsArray[$CatParent5][$i]) > 0) {
						SpiderCategories50($CatParent5.$FolderNamesArray[$CatParent5][$i].'/');						
					}
				
				}
				
				
			}
			
			SpiderCategories50('/');
			
			
			
			
			
			
			
			
			
			
			
			
			if (strpos($Arguments3,'i') !== false) {
				$ImageMode = 'var ImageMode = true;';
			}
			else {
				$ImageMode = 'var ImageMode = false;';
			}
			
			if (strpos($Arguments3,'l') !== false) {
				$ImageLinkMode = 'var ImageLinkMode = true;';
			}
			else {
				$ImageLinkMode = 'var ImageLinkMode = false;';
			}
			
			
			if (strpos($Arguments3,'e') !== false) {
				$FromEditor = 'var FromEditor = true;';
			}
			else {
				$FromEditor = 'var FromEditor = false;';
			}
			
			
							
		
			
			$PageContents .= '<script language="Javascript">
				var FileNamesArray = new Array();
				'.$FileNamesArray.'
				var FileSizesArray = new Array();
				'.$FileSizesArray.'
				var FileDimensionsArray = new Array();
				'.$FileDimensionsArray.'
				var FileDatesArray = new Array();
				'.$FileDatesArray.'
				
				var ModifyLevelsArray = new Array();
				'.$ModifyLevelsArray.'
				var ViewLevelsArray = new Array();
				'.$ViewLevelsArray.'
				
				
				var FolderNamesArray = new Array();
				'.$JSFolderNamesArray.'
				var FolderModifyLevelsArray = new Array();
				'.$FolderModifyLevelsArray.'
				var FolderAddFilesLevelsArray = new Array();
				'.$FolderAddFilesLevelsArray.'
				var FolderAddFoldersLevelsArray = new Array();
				'.$FolderAddFoldersLevelsArray.'
				var FolderViewLevelsArray = new Array();
				'.$FolderViewLevelsArray.'
				
				
				'.$ImageMode.'
				'.$ImageLinkMode.'
				'.$FromEditor.'
								
								
				var AvailableWidth, AvailableHeight, BrowserIsIE, BrowserIsMoz;
				if(document.layers || (document.getElementById && !document.all)) {
					AvailableWidth = window.innerWidth;
					AvailableHeight = window.innerHeight;
					BrowserIsMoz = true;
				}
				else if (document.all) {
					AvailableWidth = document.body.clientWidth;
					AvailableHeight = document.body.clientHeight;
					BrowserIsIE = true;
				}
				
				
				// function to transfer selected file URL back to editor								
				function OpenFile( fileUrl ) {
					
					if (FromEditor == true) {
						if (window.top.opener) {
											
							if (ImageMode == true) {
								window.top.opener.SetUrl(encodeURI( fileUrl ).replace( \'#\', \'%23\' ), "", "", "");
								window.top.opener.GetE("txtBorder").value = "0";
							}
							else if (ImageLinkMode == true) {
								window.top.opener.GetE("txtLnkUrl").value = encodeURI( fileUrl ).replace( \'#\', \'%23\' );
							}
							else {
								window.top.opener.GetE("txtUrl").value = "";
								window.top.opener.OnUrlChange();
								window.top.opener.GetE("txtUrl").value = encodeURI( fileUrl ).replace( \'#\', \'%23\' );
								window.top.opener.OnUrlChange();
							}
						
							window.top.close() ;
							window.top.opener.focus() ;
						}
						else {
							alert("Original window could not be located.  Please re-start the file manager from its original source and try again.");
						}						
					}
					
				}
				
				// navigate to selected folder
				function SelectFolder(FolderToOpen) {
					if (FolderToOpen != "..") {
						window.location = "'.$MainURL.'/admin/filemanager/'.$Arguments3.'/'.str_replace('/','+++',$CurrentLocation).'"+FolderToOpen+"+++";
					}
					else {
						window.location = "'.$MainURL.'/admin/filemanager/'.$Arguments3.'/'.str_replace('/','+++',$ThisFolderParent).'";
					}
				}
				
				// select file and send to editor
				function SelectFile(FileToOpen) {
					OpenFile("'.$BaseURL.$CurrentLocation.'"+FileToOpen);
				}
											
							
				
				var MouseIn, CurrentFileID, CurrentFileName, CurrentOptionsGroup;
				function MouseIsIn(MOFileID, MOFileName, MOOptionsGroup) {
					MouseIn = true;
					
					if (ContextMenuVisible != true) {
						CurrentFileID = MOFileID;
						CurrentFileName = MOFileName;
						CurrentOptionsGroup = MOOptionsGroup;
					}
				}
				function MouseIsOut() {
					MouseIn = false;
				}
				
 
				var ContextMenuX, ContextMenuY, ContextMenuVisible;
				if (BrowserIsMoz) {
					document.addEventListener("mouseup", ShowContextMenu, false);
				}
				if (BrowserIsIE) {
					document.attachEvent("oncontextmenu", ShowContextMenu);
					document.attachEvent("onclick", ShowContextMenu);
				}

				function ShowContextMenu(event) {
					if (MouseIn == true) {
						if (document.getElementById) {

							ContextMenuX = event.clientX;
							ContextMenuY = event.clientY;
				
							if ((BrowserIsIE && event.type == "contextmenu") || (BrowserIsMoz && event.which > 1)) {
								if ((ContextMenuX+parseInt(document.getElementById("ContextMenu").offsetWidth)) >= AvailableWidth) {
									ContextMenuX = (AvailableWidth-parseInt(document.getElementById("ContextMenu").offsetWidth)-3);
								}
								if ((ContextMenuY+parseInt(document.getElementById("ContextMenu").offsetHeight)) >= AvailableHeight) {
									ContextMenuY = (AvailableHeight-parseInt(document.getElementById("ContextMenu").offsetHeight)-3);
								}
				
								document.getElementById("ContextMenu").style.top = ContextMenuY+"px";
								document.getElementById("ContextMenu").style.left = ContextMenuX+"px";
								
								
								if (BrowserIsIE || BrowserIsMoz) {
									if (CurrentOptionsGroup == "fm") {
									
										document.getElementById("ContextMenuFiles").style.display = "none";
										document.getElementById("ContextMenuFolders").style.display = "";
										
										document.getElementById("ContextMenu").style.visibility = "visible";
										ContextMenuVisible = true;
									
									}
									else if (CurrentOptionsGroup != "f") {
									
										document.getElementById("ContextMenuFiles").style.display = "";
										document.getElementById("ContextMenuFolders").style.display = "none";
									
								
										if (CurrentOptionsGroup == "m") {
											// if allowed to modify
											document.getElementById("ContextMenuModify").style.display = "";
										}
										else {
											document.getElementById("ContextMenuModify").style.display = "none";
											}
									
										if (FromEditor == true) {
											document.getElementById("ContextMenuSelect").style.display = "";
										}
										else {
											document.getElementById("ContextMenuSelect").style.display = "none";
										}
										
										document.getElementById("ContextMenu").style.visibility = "visible";
										ContextMenuVisible = true;
										
									}
									else if (CurrentOptionsGroup == "f") {
									
										alert("Your current permissions do not allow you to modify this folder.");
									
									}
									else {
									
										document.getElementById("ContextMenu").style.visibility = "";
										ContextMenuVisible = false;
									
									}
																		
								}
								else {
									alert("Unable to display context menu -- incompatible browser?");
								}
																
								return false;
							}
							if ((BrowserIsIE && event.type == "click") || (BrowserIsMoz && event.which == 1)) {
								HideContextMenu();
							}
						}
						else {
							alert("Your browser does not appear to support the required functions for the file manager to operate.");
						}
					}
					else {
						if ((BrowserIsIE && event.type == "click") || (BrowserIsMoz && event.which == 1)) {
							if ((event.clientX >= ContextMenuX && event.clientX <= (ContextMenuX+document.getElementById("ContextMenu").offsetWidth)) && (event.clientY >= ContextMenuY && event.clientY <= (ContextMenuY+document.getElementById("ContextMenu").offsetHeight)) && ContextMenuVisible == true) {
								// left click within the menu, so leave it visible
							}
							else {	
								HideContextMenu();
							}
						}
					}
				}
				
				function HideContextMenu() {
					document.getElementById("ContextMenu").style.visibility = "hidden";
					ContextMenuVisible = false;
					
					CurrentFileID = "";
					CurrentFileName = "";
					CurrentOptionsGroup = "";
				}
				
				
				function ShowRenameWindow() {
					document.getElementById("RenameWindow").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("RenameWindow").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("RenameWindow").offsetHeight))/2);
									
					document.getElementById("RenameWindow").style.top = ThisWindowY+"px";
					document.getElementById("RenameWindow").style.left = ThisWindowX+"px";
					
					document.getElementById("RenameFileID").value = CurrentFileID;
					document.getElementById("NewFileName").value = CurrentFileName;
					document.getElementById("NewFileName").focus();
					document.getElementById("NewFileName").select();
				}
				function HideRenameWindow() {
					document.getElementById("RenameWindow").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				
				function ShowDeleteWindow() {
					document.getElementById("DeleteWindow").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("DeleteWindow").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("DeleteWindow").offsetHeight))/2);
									
					document.getElementById("DeleteWindow").style.top = ThisWindowY+"px";
					document.getElementById("DeleteWindow").style.left = ThisWindowX+"px";
					
					document.getElementById("DeleteFileID").value = CurrentFileID;					
				}
				function HideDeleteWindow() {
					document.getElementById("DeleteWindow").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				
				function ShowCreateFolder() {
					ShowLockScreen();
					document.getElementById("CreateFolder").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("CreateFolder").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("CreateFolder").offsetHeight))/2);
									
					document.getElementById("CreateFolder").style.top = ThisWindowY+"px";
					document.getElementById("CreateFolder").style.left = ThisWindowX+"px";									
				}
				function HideCreateFolder() {
					document.getElementById("CreateFolder").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				function ShowProperties(FileID) {
					document.getElementById("FilePropertiesName").innerHTML = FileNamesArray[FileID];
					document.getElementById("FilePropertiesSize").innerHTML = FileSizesArray[FileID];
					document.getElementById("FilePropertiesDimensions").innerHTML = FileDimensionsArray[FileID];
					document.getElementById("FilePropertiesDate").innerHTML = FileDatesArray[FileID];
					
					document.getElementById("FileProperties").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("FileProperties").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("FileProperties").offsetHeight))/2);
									
					document.getElementById("FileProperties").style.top = ThisWindowY+"px";
					document.getElementById("FileProperties").style.left = ThisWindowX+"px";									
				}
				function HideProperties() {
					document.getElementById("FileProperties").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				function ShowMoveWindow() {
					document.getElementById("MoveWindow").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("MoveWindow").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("MoveWindow").offsetHeight))/2);
									
					document.getElementById("MoveWindow").style.top = ThisWindowY+"px";
					document.getElementById("MoveWindow").style.left = ThisWindowX+"px";
					
					document.getElementById("MoveFileID").value = CurrentFileID;
				}
				function HideMoveWindow() {
					document.getElementById("MoveWindow").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				function ShowPermissionWindow() {
					document.getElementById("PermissionWindow").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("PermissionWindow").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("PermissionWindow").offsetHeight))/2);
									
					document.getElementById("PermissionWindow").style.top = ThisWindowY+"px";
					document.getElementById("PermissionWindow").style.left = ThisWindowX+"px";
					
					document.getElementById("PermissionFileID").value = CurrentFileID;
					document.getElementById("ModifyLevel").value = ModifyLevelsArray[CurrentFileID];
					document.getElementById("ViewLevel").value = ViewLevelsArray[CurrentFileID];
				}
				function HidePermissionWindow() {
					document.getElementById("PermissionWindow").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				
				
				
				
				function ShowFolderPermissionWindow() {
					document.getElementById("FolderPermissionWindow").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("FolderPermissionWindow").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("FolderPermissionWindow").offsetHeight))/2);
									
					document.getElementById("FolderPermissionWindow").style.top = ThisWindowY+"px";
					document.getElementById("FolderPermissionWindow").style.left = ThisWindowX+"px";
					
					document.getElementById("PermissionFolderID").value = CurrentFileID;
					document.getElementById("FolderModifyLevel").value = FolderModifyLevelsArray[CurrentFileID];
					document.getElementById("FolderAddFilesLevel").value = FolderAddFilesLevelsArray[CurrentFileID];
					document.getElementById("FolderAddFoldersLevel").value = FolderAddFoldersLevelsArray[CurrentFileID];
					document.getElementById("FolderViewLevel").value = FolderViewLevelsArray[CurrentFileID];
				}
				function HideFolderPermissionWindow() {
					document.getElementById("FolderPermissionWindow").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				function ShowFolderMoveWindow() {
					document.getElementById("FolderMoveWindow").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("FolderMoveWindow").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("FolderMoveWindow").offsetHeight))/2);
									
					document.getElementById("FolderMoveWindow").style.top = ThisWindowY+"px";
					document.getElementById("FolderMoveWindow").style.left = ThisWindowX+"px";
					
					document.getElementById("MoveFolderID").value = CurrentFileID;					
				}
				function HideFolderMoveWindow() {
					document.getElementById("FolderMoveWindow").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				function ShowFolderRenameWindow() {
					document.getElementById("FolderRenameWindow").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("FolderRenameWindow").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("FolderRenameWindow").offsetHeight))/2);
									
					document.getElementById("FolderRenameWindow").style.top = ThisWindowY+"px";
					document.getElementById("FolderRenameWindow").style.left = ThisWindowX+"px";
					
					document.getElementById("RenameFolderID").value = CurrentFileID;
					document.getElementById("RenameNewFolderName").value = FolderNamesArray[CurrentFileID];				
				}
				function HideFolderRenameWindow() {
					document.getElementById("FolderRenameWindow").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				function ShowFolderDeleteWindow() {
					document.getElementById("FolderDeleteWindow").style.visibility = "visible";
										
					var ThisWindowX = ((AvailableWidth-parseInt(document.getElementById("FolderDeleteWindow").offsetWidth))/2);
					var ThisWindowY = ((AvailableHeight-parseInt(document.getElementById("FolderDeleteWindow").offsetHeight))/2);
									
					document.getElementById("FolderDeleteWindow").style.top = ThisWindowY+"px";
					document.getElementById("FolderDeleteWindow").style.left = ThisWindowX+"px";
					
					document.getElementById("DeleteFolderID").value = CurrentFileID;					
				}
				function HideFolderDeleteWindow() {
					document.getElementById("FolderDeleteWindow").style.visibility = "hidden";
					HideLockScreen();
				}
				
				
				
				
				
				
				
				var ScreenLocked;
				function ShowLockScreen() {
					document.getElementById("LockScreen").style.visibility = "visible";
					ScreenLocked = true;
				}				
				function HideLockScreen() {
					document.getElementById("LockScreen").style.visibility = "hidden";
					ScreenLocked = false;
				}
				
				function ContextMenuClick(ContextMenuSelection) {
					if (ContextMenuSelection == "Select") {
						OpenFile("'.$BaseURL.$CurrentLocation.'"+CurrentFileName);
					}
					else if (ContextMenuSelection == "Properties") {
						ShowLockScreen();
						ShowProperties(CurrentFileID);
					}
					else if (ContextMenuSelection == "View") {
						window.open("'.$BaseURL.$CurrentLocation.'"+CurrentFileName);
					}
					else if (ContextMenuSelection == "Download") {
						window.open("'.$MainURL.'/admin/filemanager-functions/download/'.$Arguments3.'/"+CurrentFileID);
					}
					else if (ContextMenuSelection == "Move") {
						ShowLockScreen();
						ShowMoveWindow(CurrentFileID);
					}
					else if (ContextMenuSelection == "Permissions") {
						ShowLockScreen();
						ShowPermissionWindow(CurrentFileID);
					}
					else if (ContextMenuSelection == "Rename") {
						ShowLockScreen();
						ShowRenameWindow();
					}
					else if (ContextMenuSelection == "Replace") {
						alert("Replace: "+CurrentFileID+"-"+CurrentFileName);
					}
					else if (ContextMenuSelection == "Delete") {
						ShowLockScreen();
						ShowDeleteWindow();
					}
					
					
					else if (ContextMenuSelection == "FolderPermissions") {
						ShowLockScreen();
						ShowFolderPermissionWindow(CurrentFileID);
					}					
					else if (ContextMenuSelection == "FolderMove") {
						ShowLockScreen();
						ShowFolderMoveWindow(CurrentFileID);
					}					
					else if (ContextMenuSelection == "FolderRename") {
						ShowLockScreen();
						ShowFolderRenameWindow(CurrentFileID);
					}					
					else if (ContextMenuSelection == "FolderDelete") {
						ShowLockScreen();
						ShowFolderDeleteWindow(CurrentFileID);
					}
					
					
					
					HideContextMenu();
				}
				

				document.oncontextmenu = new Function("return false") ;
							
								
				</script>
				
				
				<style> 
				.ContextMenuMain {
					position: absolute;
					width: 100px;
					top: 0px;
					left: 0px;
					background-color: #eeeeee;
					visibility: hidden; 
					border: 1px solid #000000;
					padding: 0px; 
					z-index: 100;
				}
				.ContextMenuItem {
					padding: 4px 8px 4px 8px; 
					color: #000000;
					text-decoration: none;
					font-family: arial; 
					font-size: 12px;
					font-weight: normal; 
					display: block;
				}
				.ContextMenuItemSepMajor {
					border-top: 1px solid #000000;
					margin: 0px;
				}
				.ContextMenuItemSepMinor {
					border-top: 1px solid #c0c0c0;
					margin: 0px;
				}
				a.ContextMenuItem:hover {
					color: #505050;
				}
				
				
				.LockScreenMain {
					position: absolute;
					width: 100%;
					height: 100%;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;
					visibility: hidden;
					
					z-index: 50;
					
					opacity:.75;
					filter: alpha(opacity=75); 
					-moz-opacity: 0.75;		
				}
				
				
				.RenameWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.DeleteWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.CreateFolderMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.PropertiesWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.MoveWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.PermissionWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.FolderPermissionWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.FolderMoveWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.FolderRenameWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				.FolderDeleteWindowMain {
					position: absolute;
					top: 0px;
					left: 0px;
					
					background-color: #eeeeee;					
					border: 1px solid #000000;
					padding: 10px;
					
					visibility: hidden;
					
					z-index: 80;
				}
				
				</style>


				
				<div id="ContextMenu" class="ContextMenuMain">
					<div id="ContextMenuFiles">
					<div id="ContextMenuSelect">
						<a href="javascript:ContextMenuClick(\'Select\');" class="ContextMenuItem">Select File</a>
						<div class="ContextMenuItemSepMajor"></div>
					</div>
					<a href="javascript:ContextMenuClick(\'View\');" class="ContextMenuItem">View</a>
					<div class="ContextMenuItemSepMinor"></div>
					<a href="javascript:ContextMenuClick(\'Download\');" class="ContextMenuItem">Download</a>
					<div id="ContextMenuModify">
						<div class="ContextMenuItemSepMajor"></div>
						<a href="javascript:ContextMenuClick(\'Permissions\');" class="ContextMenuItem">Permissions</a>
						<div class="ContextMenuItemSepMajor"></div>
						<a href="javascript:ContextMenuClick(\'Move\');" class="ContextMenuItem">Move</a>
						<div class="ContextMenuItemSepMinor"></div>
						<a href="javascript:ContextMenuClick(\'Rename\');" class="ContextMenuItem">Rename</a>
						<div class="ContextMenuItemSepMajor"></div>
						<!--<a href="javascript:ContextMenuClick(\'Replace\');" class="ContextMenuItem"><font color="#ff0000">Replace</font></a>
						<div class="ContextMenuItemSepMinor"></div>-->
						<a href="javascript:ContextMenuClick(\'Delete\');" class="ContextMenuItem">Delete</a>
					</div>
					<div class="ContextMenuItemSepMajor"></div>
					<a href="javascript:ContextMenuClick(\'Properties\');" class="ContextMenuItem">Properties</a>
					</div>
					<div id="ContextMenuFolders">
						<a href="javascript:ContextMenuClick(\'FolderPermissions\');" class="ContextMenuItem">Permissions</a>
						<div class="ContextMenuItemSepMajor"></div>
						<!--<a href="javascript:ContextMenuClick(\'FolderMove\');" class="ContextMenuItem">Move</a>
						<div class="ContextMenuItemSepMinor"></div>-->
						<a href="javascript:ContextMenuClick(\'FolderRename\');" class="ContextMenuItem">Rename</a>
						<div class="ContextMenuItemSepMajor"></div>
						<a href="javascript:ContextMenuClick(\'FolderDelete\');" class="ContextMenuItem">Delete</a>
					</div>
				</div>
								
				<div id="LockScreen" class="LockScreenMain"></div>
				
				<div id="RenameWindow" class="RenameWindowMain"><div align="center"><font face="Arial" size="2"><b>Enter New File Name</b></font></div><br><table cellpadding="0" cellspacing="0" border="0"><tr><form name="RenameForm" action="'.$MainURL.'/admin/filemanager-functions/rename/'.$Arguments3.'" method="post"><td align="right"><input type="text" name="NewFileName" id="NewFileName" value="" size="30"></td><td align="left"><input type="hidden" id="RenameFileID" name="RenameFileID" value="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Rename File&nbsp;&nbsp;"></td><td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="CancelButton" type="button" value="&nbsp;&nbsp;Cancel&nbsp;&nbsp;" onClick="HideRenameWindow();"></td></form></tr></table></div>
				
				
				<div id="DeleteWindow" class="DeleteWindowMain"><div align="center"><font face="Arial" size="2"><b>Are You Sure You Wish To Delete This File?</b></font></div><br><table cellpadding="0" cellspacing="0" border="0"><tr><form name="DeleteForm" action="'.$MainURL.'/admin/filemanager-functions/delete/'.$Arguments3.'" method="post"><td align="right"><input type="hidden" id="DeleteFileID" name="DeleteFileID" value=""><input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Yes, Delete File&nbsp;&nbsp;"></td><td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="CancelButton" type="button" value="&nbsp;&nbsp;No, Don\'t Delete&nbsp;&nbsp;" onClick="HideDeleteWindow();"></td></form></tr></table></div>
				
				
				<div id="CreateFolder" class="CreateFolderMain"><div align="center"><font face="Arial" size="2"><b>Enter New Folder Name</b></font></div><br><table cellpadding="0" cellspacing="0" border="0"><tr><form name="CreateFolderForm" action="'.$MainURL.'/admin/filemanager-functions/createfolder/'.$Arguments3.'" method="post"><input type="hidden" name="CurrentLocation" value="'.$CurrentLocation.'"><td align="right"><input type="text" name="NewFolderName" id="NewFolderName" value="" size="30"></td><td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Create Folder&nbsp;&nbsp;"></td><td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="CancelButton" type="button" value="&nbsp;&nbsp;Cancel&nbsp;&nbsp;" onClick="HideCreateFolder();"></td></form></tr></table></div>
				
				<div id="FileProperties" class="PropertiesWindowMain"><div align="center"><font face="Arial" size="2"><b>File Properties</b></font><br><br><table cellpadding="3" cellspacing="0" border="0"><tr><td align="left"><font face="Arial" size="2">File Name&nbsp;&nbsp;</font></td><td align="left"><font face="Arial" size="2"><div id="FilePropertiesName"></div></font></td></tr><tr><td align="left"><font face="Arial" size="2">File Size&nbsp;&nbsp;</font></td><td align="left"><font face="Arial" size="2"><div id="FilePropertiesSize"></div></font></td></tr><tr><td align="left"><font face="Arial" size="2">Dimensions&nbsp;&nbsp;</font></td><td align="left"><font face="Arial" size="2"><div id="FilePropertiesDimensions"></div></font></td></tr><tr><td align="left"><font face="Arial" size="2">Created&nbsp;&nbsp;</font></td><td align="left"><font face="Arial" size="2"><div id="FilePropertiesDate"></div></font></td></tr><form></table><br><input name="CancelButton" type="button" value="&nbsp;&nbsp;&nbsp;OK&nbsp;&nbsp;&nbsp;" onClick="HideProperties();"></form></div></div>
				
				<div id="MoveWindow" class="MoveWindowMain"><div align="center"><font face="Arial" size="2"><b>Select Destination Folder</b></font></div><br><table width="200" cellpadding="0" cellspacing="0" border="0"><tr><form name="MoveForm" action="'.$MainURL.'/admin/filemanager-functions/move/'.$Arguments3.'" method="post"><td colspan="5" align="center"><select name="FileDestination" size="1">'.$MoveDestinationsList.'</select><br>&nbsp;</td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="50%" align="right"><input type="hidden" id="MoveFileID" name="MoveFileID" value=""><input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Move File&nbsp;&nbsp;"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="50%" align="left"><input name="CancelButton" type="button" value="&nbsp;&nbsp;Cancel&nbsp;&nbsp;" onClick="HideMoveWindow();"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></form></tr></table></div>
				
				<div id="PermissionWindow" class="PermissionWindowMain"><div align="center"><font face="Arial" size="2"><b>Modify File Permissions</b></font></div><br><table width="200" cellpadding="0" cellspacing="0" border="0"><tr><form name="PermissionForm" action="'.$MainURL.'/admin/filemanager-functions/permissions/'.$Arguments3.'" method="post"><td colspan="5" align="center"><font face="Arial" size="2"><b>Minimum Level Required To Modify File:</b><br><select id="ModifyLevel" name="ModifyLevel" size="1">'.$PermissionsDropdown.'</select><br>&nbsp;</td></tr><tr><td colspan="5" align="center"><font face="Arial" size="2"><b>Minimum Level Required To View File:</b><br><select id="ViewLevel" name="ViewLevel" size="1">'.$PermissionsDropdown.'</select><br><br>&nbsp;</td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="50%" align="right"><input type="hidden" id="PermissionFileID" name="PermissionFileID" value=""><input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Update Permissions&nbsp;&nbsp;"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="50%" align="left"><input name="CancelButton" type="button" value="&nbsp;&nbsp;Cancel&nbsp;&nbsp;" onClick="HidePermissionWindow();"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></form></tr></table></div>
				
				<div id="FolderPermissionWindow" class="FolderPermissionWindowMain"><div align="center"><font face="Arial" size="2"><b>Modify Folder Permissions</b></font></div><br><table width="200" cellpadding="0" cellspacing="0" border="0"><tr><form name="FolderPermissionForm" action="'.$MainURL.'/admin/filemanager-functions/folderpermissions/'.$Arguments3.'" method="post"><td colspan="5" align="center"><font face="Arial" size="2"><b>Minimum Level Required To Modify Folder:</b><br><select id="FolderModifyLevel" name="FolderModifyLevel" size="1">'.$PermissionsDropdown.'</select><br><br>&nbsp;</td></tr><tr><td colspan="5" align="center"><font face="Arial" size="2"><b>Minimum Level Required To Add Files:</b><br><select id="FolderAddFilesLevel" name="FolderAddFilesLevel" size="1">'.$PermissionsDropdown.'</select><br><br>&nbsp;</td></tr><tr><td colspan="5" align="center"><font face="Arial" size="2"><b>Minimum Level Required To Add Folders:</b><br><select id="FolderAddFoldersLevel" name="FolderAddFoldersLevel" size="1">'.$PermissionsDropdown.'</select><br><br>&nbsp;</td></tr><tr><tr><tr><td colspan="5" align="center"><font face="Arial" size="2"><b>Minimum Level Required To View Folder:</b><br><select id="FolderViewLevel" name="FolderViewLevel" size="1">'.$PermissionsDropdown.'</select><br><br>&nbsp;</td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="50%" align="right"><input type="hidden" id="PermissionFolderID" name="PermissionFolderID" value=""><input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Update Permissions&nbsp;&nbsp;"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="50%" align="left"><input name="CancelButton" type="button" value="&nbsp;&nbsp;Cancel&nbsp;&nbsp;" onClick="HideFolderPermissionWindow();"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></form></tr></table></div>
				
				<div id="FolderRenameWindow" class="FolderRenameWindowMain"><div align="center"><font face="Arial" size="2"><b>Rename Folder</b></font></div><br><table width="200" cellpadding="0" cellspacing="0" border="0"><tr><form name="FolderRenameForm" action="'.$MainURL.'/admin/filemanager-functions/folderrename/'.$Arguments3.'" method="post"><td colspan="5" align="center"><font face="Arial" size="2"><b>Enter New Folder Name:</b><br><input type="text" name="RenameNewFolderName" id="RenameNewFolderName" value="" size="30"><br><br>&nbsp;</td></tr><tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="50%" align="right"><input type="hidden" id="RenameFolderID" name="RenameFolderID" value=""><input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Rename Folder&nbsp;&nbsp;"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td width="50%" align="left"><input name="CancelButton" type="button" value="&nbsp;&nbsp;Cancel&nbsp;&nbsp;" onClick="HideFolderRenameWindow();"></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></form></tr></table></div>
				
				<div id="FolderDeleteWindow" class="FolderDeleteWindowMain"><div align="center"><font face="Arial" size="2"><b>Are You Sure You Wish To Delete This Folder?</b><br><br>All folders and files within it will also be deleted!  This action can not be undone!</font></div><br><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><form name="FolderDeleteForm" action="'.$MainURL.'/admin/filemanager-functions/folderdelete/'.$Arguments3.'" method="post"><td align="right"><input type="hidden" id="DeleteFolderID" name="DeleteFolderID" value=""><input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Yes, Delete Folder&nbsp;&nbsp;"></td><td align="left">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="CancelButton" type="button" value="&nbsp;&nbsp;No, Don\'t Delete&nbsp;&nbsp;" onClick="HideFolderDeleteWindow();"></td></form></tr></table></div>
						
				
				<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td width="10"><img src="'.$ImagesURL.'/admin/spacer.gif" width="10" height="1" alt="" border="0"></td><td width="100%" valign="top"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="10" alt="" border="0"><br><table width="100%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"><table width="100%" cellpadding="5" cellspacing="0" border="0"><tr>
					<td bgcolor="#ffffff"><table cellpadding="0" cellspacing="0" border="0"><tr><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="5" height="1" alt="" border="0"><img src="'.$ImagesURL.'/admin/folder_icon_mini.gif" width="23" height="18" alt="" border="0"><img src="'.$ImagesURL.'/admin/spacer.gif" width="10" height="1" alt="" border="0"></td><td><font face="Arial" size="2"><b>'.$FileManagerLocationBar.'</b></font></td></tr></table></td>
					<td bgcolor="#ffffff" width="160"><table cellpadding="0" cellspacing="0" border="0"><tr><td><img src="'.$ImagesURL.'/admin/spacer.gif" width="5" height="1" alt="" border="0"><a href="'.$MainURL.'/admin/filemanager-functions/scan/'.$Arguments3.'/'.$Arguments4.'"><img src="'.$ImagesURL.'/admin/refresh.gif" width="18" height="18" alt="" border="0"></a><img src="'.$ImagesURL.'/admin/spacer.gif" width="6" height="1" alt="" border="0"></td><td><font face="Arial" size="2"><b><a href="'.$MainURL.'/admin/filemanager-functions/scan/'.$Arguments3.'/'.$Arguments4.'" style="text-decoration: none;">Scan For Changes</a></b></font></td></tr></table></td>
				</tr></table></td></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="5" alt="" border="0"><br><div id="MainTilesContainer" style="background-color: #ffffff; border: 1px solid #000000; overflow: auto;">'.$FolderTilesSection.$FileTilesSection.'</div><div id="UploadFileBar" style="height: 90px; display: none; background-color: #eeeeee;"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="10" alt="" border="0"><br><div align="center"><font face="Arial" size="2"><b>Upload New File To This Folder [ '.$CurrentLocation.' ]</b></font><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="8" alt="" border="0"><br><table cellpadding="0" cellspacing="0" border="0"><tr><form name="FileUploadForm" action="'.$MainURL.'/admin/filemanager-functions/upload/'.$Arguments3.'" method="post" enctype="multipart/form-data"><td align="right"><font face="Arial" size="2"><input type="file" name="FileData"></font></td><td align="left"><input type="hidden" name="MAX_FILE_SIZE" value="'.$MaxFileSize.'"><input type="hidden" name="CurrentLocation" value="'.$CurrentLocation.'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Upload&nbsp;&nbsp;"></td></form></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="5" alt="" border="0"><br><font face="Arial" size="1">Maximum File Size: '.number_format($MaxFileSize/1024,0,'','').' KBytes</font></div></div></td><td width="10"><img src="'.$ImagesURL.'/admin/spacer.gif" width="10" height="1" alt="" border="0"></td></tr></table>'.$InitSection;
							
						
	
		} // end regular file manager
		else {
			// upload version
			
			
			//$query55 = "select * from `".$Settings['DBPrefix']."core-Folders` where ViewFilesLevel<='".$UserLevel."' and SystemFolder=0 ORDER BY Location ASC, Folder ASC";
			$query55 = "select * from `".$Settings['DBPrefix']."core-Folders` where ViewFilesLevel<='".$UserLevel."' ORDER BY Location ASC, Folder ASC";
			$result55 = mysql_query($query55) or die (mysql_error());
		
			while ($row55 = mysql_fetch_array($result55)) { 
            
				$FolderIDsArray[$row55['Location']][] = $row55['RecordNumber'];
				$FolderNamesArray[$row55['Location']][] = $row55['Folder'];
				$FolderExists[$row55['RecordNumber']] = 'y';
				$AddFilesLevelArray[$row55['Location']][] = $row55['AddFilesLevel'];
				
			}
			
			//var_dump($FolderNamesArray);
			
			$FirstAvailableFound = false;
			
			if ($AddFilesLevelArray[''][0] <= $UserLevel) {
				$UploadFoldersList = '<input type="radio" name="CurrentLocation" value="/" checked> [Top Level]<br>';
				$FirstAvailableFound = true;
			}
			else {
				$UploadFoldersList = '<img src="'.$ImagesURL.'/admin/lock.gif" width="15" height="15" alt="Insufficient Permissions To Upload Here" border="0"> [Top Level]<br>';
			}
			
			
			$CatParent5 = '/';
			$LastParentAbove5 = '/';
			$CatLevel5['/'] = 0;
			
									
			function SpiderCategories20($CatParent5) {
				
				Global $FolderIDsArray, $FolderNamesArray, $UploadFoldersList, $LastParent5, $LastParentAbove5, $CatSpacersArray5, $CatLevel5, $CatsCount5, $CurrentLocation, $AddFilesLevelArray, $UserLevel, $FirstAvailableFound, $ImagesURL;
				
				//print '<br><br>---<br><b>'.$CatParent5.'</b> - '.count($FolderIDsArray[$CatParent5]).'<br>---<br><br>';
				for ($i = 0; $i < count($FolderIDsArray[$CatParent5]); $i++) {
					
					$LastParentAboveB5 = $LastParentAbove5;
					$LastParentB5 = $LastParent5;
					
					$CatLevel5[$CatParent5.$FolderNamesArray[$CatParent5][$i].'/'] = $CatLevel5[$CatParent5];
					if ($CatParent5 != $LastParent5 && $CatParent5 == $LastParentAbove5) {
				
						$CatLevel5[$CatParent5.$FolderNamesArray[$CatParent5][$i].'/'] = $CatLevel5[$CatParent5] + 1;
						$CatLevel5[$CatParent5]++;
												
						$CatsCount5[$CatLevel5[$CatParent5]] = 0;
				
					}
					
					$LastParent5 = $CatParent5;
					$LastParentAbove5 = $CatParent5.$FolderNamesArray[$CatParent5][$i].'/';
					
					$CatsCount5[$CatLevel5[$CatParent5]]++;
					
										
					$CatSpacer5 = '';
					for ($x = 0; $x < $CatLevel5[$CatParent5]; $x++) {
						
						if ($CatsCount5[$CatLevel5[$CatParent5]] == count($CatParent5.$FolderNamesArray[$CatParent5][$i].'/') && $x == $CatLevel5[$CatParent5]-1) {
							//$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;|------';
							$CatSpacersArray5[$CatLevel5[$CatParent5]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							$ResetAfter5 = 'y';
						}
						else if ($CatsCount5[$CatLevel5[$CatParent5]] == count($CatParent5.$FolderNamesArray[$CatParent5][$i].'/')) {
							$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;&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 ($FirstAvailableFound == false && $AddFilesLevelArray[$CatParent5][$i] <= $UserLevel) {
						$UploadFoldersList .= ''.$CatSpacer5.' <input type="radio" name="CurrentLocation" value="'.$CatParent5.$FolderNamesArray[$CatParent5][$i].'/" checked> '.$FolderNamesArray[$CatParent5][$i].'<br>';
						$FirstAvailableFound = true;
					}
					else {
						if ($AddFilesLevelArray[$CatParent5][$i] <= $UserLevel) {
							$UploadFoldersList .= ''.$CatSpacer5.' <input type="radio" name="CurrentLocation" value="'.$CatParent5.$FolderNamesArray[$CatParent5][$i].'/"> '.$FolderNamesArray[$CatParent5][$i].'<br>';
						}
						else {
							$UploadFoldersList .= ''.$CatSpacer5.' <img src="'.$ImagesURL.'/admin/lock.gif" width="15" height="15" alt="Insufficient Permissions To Upload Here" border="0"> '.$FolderNamesArray[$CatParent5][$i].'<br>';
						}
					}
					
					//print '<br>'.$CatParent5.$FolderNamesArray[$CatParent5][$i].'/'.' ('.count($FolderNamesArray[$CatParent5.$FolderNamesArray[$CatParent5][$i].'/']).')';					
					if (count($FolderIDsArray[$CatParent5][$i]) > 0) {
						SpiderCategories20($CatParent5.$FolderNamesArray[$CatParent5][$i].'/');						
					}
				
				}
				
				
			}
			
			SpiderCategories20('/');
			
			
			$PageContents = '<br><div align="center"><table width="50%" cellpadding="1" cellspacing="0" border="0"><tr><td bgcolor="#000000"><table width="100%" cellpadding="5" cellspacing="0" border="0"><form name="FileUploadForm" action="'.$MainURL.'/admin/filemanager-functions/upload/'.$Arguments3.'" method="post" enctype="multipart/form-data"><tr><td bgcolor="#ffffff" align="center"><font face="Arial" size="2"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="10" alt="" border="0"><br><font size="3"><b>Upload File</b></font><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="20" alt="" border="0"><br><b>Select File To Upload:</b><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><input type="file" name="FileData"><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="5" alt="" border="0"><br><font face="Arial" size="1">Maximum File Size: '.number_format($MaxFileSize/1024,0,'','').' KBytes</font><input type="hidden" name="MAX_FILE_SIZE" value="'.$MaxFileSize.'"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="30" alt="" border="0"><br><b>Select Location To Store File:</b><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="4" alt="" border="0"><br><table cellpadding="5" cellspacing="0" border="0"><tr><td><font face="Arial" size="2">'.$UploadFoldersList.'<br><div align="center"><a href="'.$MainURL.'/admin/filemanager/'.str_replace('u','',$Arguments3).'"><b>Manage Folders</b></a></div></font></td></tr></table><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="40" alt="" border="0"><br><input name="SubmitButton" type="submit" value="&nbsp;&nbsp;Upload File&nbsp;&nbsp;"><br><img src="'.$ImagesURL.'/admin/spacer.gif" width="1" height="10" alt="" border="0"></font></td></tr></table></td></tr></form></table></div><br>&nbsp;';
		
	
		} // end upload version
		
		
		
		print '<html><head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>File Manager</title>
		<meta name="Description" content="">
		<meta name="Keywords" content="">
		<meta name="Author" content="FlexCMS">
		<meta name="Generator" content="FlexCMS">
		<META NAME="Robots" CONTENT="INDEX,FOLLOW">
		<META NAME="Rating" CONTENT="General">
		<meta name="MSSmartTagsPreventParsing" content="TRUE"></head>
		<body bgcolor="#eeeeee" text="#000000" link="#000000" vlink="#000000" alink="#000000" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" rightmargin="0" style="margin:0">'.$PageContents.'</body></html>';
				
		exit();
			

	} // end if has permission
	else {
		
		$PageContents = $MsgText[0][97];
	
	}

}
else {
	
	RedirectToLogin();

}
	
	

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


?>