<?

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

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



	// ========================================================================================
	// edit block
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_content.gif" width="23" height="20"> '.$MsgText[0][240];
	$BrowserTitle = $MsgText[0][240];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL. '/options.html">'.$MsgText[0][4].'</a> > <a href="'.$MainURL. '/admin/blocks.html">'.$MsgText[0][151].'</a> > '.$MsgText[0][240];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		
		$query = "select * from `".$Settings['DBPrefix']."core-Blocks` where RecordNumber='".intval($Arguments3)."' LIMIT 1";
        	$result = mysql_query($query) or die (mysql_error());
		$row = mysql_fetch_array($result);
	
		if ($Permissions[2] == 'y' && $row['MinLevel'] <= $UserLevel && $row['MinEditLevel'] <= $UserLevel) {

			
			
			$TitleAlignmentSelected[$row['TitleAlignment']] = ' selected';
			$BlockLocationSelected[$row['BlockLocation']] = ' selected';
			$BlockAlignmentSelected[$row['BlockAlignment']] = ' selected';
			$BlockEnabledSelected[$row['BlockEnabled']] = ' selected';
			
			
			if ($row['PageType'] == 1 || $row['PageType'] == 2 || $row['PageType'] == 3) {
				$PageTypeSelected[$row['PageType']] = ' selected';
			}
			else if ($row['EnablePHP'] == 1) {
				$PageTypeSelected[3] = ' selected';
			}
			
			
			
			// read levels from db and create the dropdown
			$query57 = "select Level,Description from `".$Settings['DBPrefix']."core-Permissions` where Level<=".$UserLevel;
			$result57 = mysql_query($query57) or die (mysql_error());
			while ($row57 = mysql_fetch_array($result57)) {
				$LevelDescriptions[$row57['Level']] = $row57['Description'];
			}
	

			$MinLevelSelected[$row['MinLevel']] = ' selected';
		
			$PermissionsDropdown = '<option value="-1"'.$MinLevelSelected[-1].'> -1 - '.$MsgText[0][161].'</option><option value="0"'.$MinLevelSelected[0].'> 0 - '.$MsgText[0][162].'</option>';
			for ($i = 1; $i <= $UserLevel; $i++) {
				if ($LevelDescriptions[$i] != '') {
					$PermissionsDropdown .= '<option value="'.$i.'"'.$MinLevelSelected[$i].'> '.$i.' - '.$LevelDescriptions[$i].'</option>';
				}
				else {
					$PermissionsDropdown .= '<option value="'.$i.'"'.$MinLevelSelected[$i].'> '.$i.'</option>';
				}
			}
			
			if ($row['MinEditLevel'] < $row['MinLevel']) {
				$row['MinEditLevel'] = $row['MinLevel'];
			}
			
			$MinEditLevelSelected[$row['MinEditLevel']] = ' selected';
		
			$PermissionsDropdown2 = '<option value="-1"'.$MinEditLevelSelected[-1].'> -1 - '.$MsgText[0][161].'</option><option value="0"'.$MinEditLevelSelected[0].'> 0 - '.$MsgText[0][162].'</option>';
			for ($i = 1; $i <= $UserLevel; $i++) {
				if ($LevelDescriptions[$i] != '') {
					$PermissionsDropdown2 .= '<option value="'.$i.'"'.$MinEditLevelSelected[$i].'> '.$i.' - '.$LevelDescriptions[$i].'</option>';
				}
				else {
					$PermissionsDropdown2 .= '<option value="'.$i.'"'.$MinEditLevelSelected[$i].'> '.$i.'</option>';
				}
			}
		
			
			// remove any quotes from the block title
			$row['BlockTitle'] = str_replace('"', '&#34;', $row['BlockTitle']);
			$row['AdminLabel'] = str_replace('"', '&#34;', $row['AdminLabel']);
			
			
			$BlockTypes[''] = $MsgText[0][171];
			$BlockTypes['0'] = $MsgText[0][171];
			
			$BlockTypes['cr-1'] = $MsgText[0][173];
			$BlockTypes['cr-2'] = $MsgText[0][174];
			$BlockTypes['cr-3'] = $MsgText[0][175];
			//$BlockTypes['cr-4'] = 'Random Code/Text Preprogrammed';
			$BlockTypes['cr-5'] = $MsgText[0][176];
			$BlockTypes['cl-1'] = $MsgText[1][100];
			
			
			
			
		
			
		$query32 = "select * from `".$Settings['DBPrefix']."core-PageCategories` ORDER BY Name ASC";
		$result32 = mysql_query($query32) or die (mysql_error());
		
		while ($row32 = mysql_fetch_array($result32)) { 
            
			$CategoryIDsArray[$row32['Parent']][] = $row32['RecordNumber'];
			$CategoryNamesArray[$row32['Parent']][] = $row32['Name'];
			$CategoryExists[$row32['RecordNumber']] = 'y';
			
			if ($row32['Description'] != '') { 
				$CategoryDescriptionsArray[$row32['Parent']][] = '<br>'.$row32['Description'];
			}
			else {
				$CategoryDescriptionsArray[$row32['Parent']][] = '<!--  -->';
			}
			
			
			if ($row32['RecordNumber'] > $LargestPageCatID) {
				$LargestPageCatID = $row32['RecordNumber'];
			}
			
				
		}
		
		
		$row['PagesList'] = str_replace('-','',$row['PagesList']);
		$PagesListPieces = explode(',', $row['PagesList']);
		for ($c = 0; $c < count($PagesListPieces); $c++) {
			$PageSelected[$PagesListPieces[$c]] = ' checked';
		}
		
		$row['PageCatsList'] = str_replace('-','',$row['PageCatsList']);
		$PageCatsListPieces = explode(',', $row['PageCatsList']);
		for ($c = 0; $c < count($PageCatsListPieces); $c++) {
			$PageCatSelected[$PageCatsListPieces[$c]] = ' checked';
		}
		
		
		
		
			
		//query the database and load pages data
		$query33 = "select * from `".$Settings['DBPrefix']."core-Pages` where MinLevel<='".$UserLevel."' ORDER BY PageTitle asc, PageLink asc, RecordNumber asc";
		$result33 = mysql_query($query33) or die (mysql_error());
		
				
		// if any rows are returned
		if (mysql_num_rows($result33) != 0) {
						
			while ($row33 = mysql_fetch_array($result33)) {
			
				// if the page has been orphaned, put it back in top level
				if ($CategoryExists[$row33['PageParent']] != 'y') {
					$row33['PageParent'] = 0;
				}			
            	
				$PageIDsArray[$row33['PageParent']][] = $row33['RecordNumber'];
				$PageNamesArray[$row33['PageParent']][] = $row33['PageTitle'];
				$PageLabelsArray[$row33['PageParent']][] = $row33['AdminLabel'];
				$PageLinksArray[$row33['PageParent']][] = $row33['PageLink'];
				
				
				if ($row33['RecordNumber'] > $LargestPageID) {
					$LargestPageID = $row33['RecordNumber'];
				}
				
			}
			
			
			
			$CatsPrint = '<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="PageCatsList-0" value="y"'.$PageCatSelected['0'].'>&nbsp;<b>Top Level</b>';
			
			$LastParentAbove = '0';
			$CatLevel['0'] = 0;
			
						
			if (count($PageIDsArray['0']) > 0) {
				$CatsPrint .= '<br>';	
			}
			
			if (count($CategoryIDsArray['0']) > 0) {
				$CatSpacer = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			}
			else {
				$CatSpacer = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
			}
			
			for ($x = 0; $x < count($PageIDsArray['0']); $x++) {
					
				$CatsPrint .= '<table border="0" cellpadding="0" cellspacing="0"><tr><td>'.$CatSpacer.'</td><td><font size="'.$FontSize.'" color="'.$FontColor.'">&nbsp;&nbsp;&nbsp;<input type="checkbox" name="PagesList-'.$PageIDsArray['0'][$x].'" value="y"'.$PageSelected[$PageIDsArray['0'][$x]].'>&nbsp;'.$PageNamesArray['0'][$x].' ('.$PageLinksArray['0'][$x].')</font></td></tr></table>';
									
			}
			
			
			
			
			function SpiderCategories69($CatParent) {
				
				Global $CategoryIDsArray, $CategoryNamesArray, $CategoryDescriptionsArray, $PageIDsArray, $PageNamesArray, $PageLinksArray, $CatsPrint, $LastParent, $LastParentAbove, $CatSpacersArray, $CatLevel, $CatsCount, $BaseURL, $ImagesURL, $MainURL, $FontSize, $FontColor, $PageCatSelected, $PageSelected;
				
				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]]++;
					
										
					$CatSpacer = '';
					for ($x = 0; $x < $CatLevel[$CatParent]; $x++) {
						
											
						if ($CatsCount[$CatLevel[$CatParent]] == count($CategoryIDsArray[$CatParent]) && $x == $CatLevel[$CatParent]-1) {
							$CatSpacersArray[$CatLevel[$CatParent]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							$ResetAfter = 'y';
						}
						else if ($CatsCount[$CatLevel[$CatParent]] == count($CategoryIDsArray[$CatParent])) {
							$CatSpacersArray[$CatLevel[$CatParent]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
						}
						else {
							if ($x < $CatLevel[$CatParent]) {
								$CatSpacersArray[$CatLevel[$CatParent]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
								$ResetAfter = 'y2';
							}
							else {
								$CatSpacersArray[$CatLevel[$CatParent]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							}
						}
						
						$ConnectorsWidth += $ConnectorsWidthAdd;	
						$CatSpacer .= $CatSpacersArray[$x+1];
						
						if ($ResetAfter == 'y') {
							$CatSpacersArray[$CatLevel[$CatParent]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							$ResetAfter = 'n';
						}
						else if ($ResetAfter == 'y2') {
							$CatSpacersArray[$CatLevel[$CatParent]] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
							$ResetAfter = 'n';
						}
									
					}
					
					$ConnectorsWidth = (($CatLevel[$CatParent]-1)*35)+35;
					$CatsPrint .= '<br><table border="0" cellpadding="0" cellspacing="0"><tr><td>'.$CatSpacer.'</td><td><font size="'.$FontSize.'" color="'.$FontColor.'">&nbsp;&nbsp;&nbsp;<input type="checkbox" name="PageCatsList-'.$CategoryIDsArray[$CatParent][$i].'" value="y"'.$PageCatSelected[$CategoryIDsArray[$CatParent][$i]].'>&nbsp;<b>'.$CategoryNamesArray[$CatParent][$i].'</b></font></td></tr></table>';
					
					$CatSpacer = '';
					for ($x = 0; $x < ($CatLevel[$CatParent]-1); $x++) {
						$CatSpacer .= $CatSpacersArray[$x+1];					
					}
					if ($CatsCount[$CatLevel[$CatParent]] == count($CategoryIDsArray[$CatParent])) {
						$CatSpacer .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
					}
					else {						
						$CatSpacer .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
					}

					
					if (count($CategoryIDsArray[$CategoryIDsArray[$CatParent][$i]]) > 0) {
						$CatSpacer .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
					}
					else {
						$CatSpacer .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
					}
					
					$ConnectorsWidth = (($CatLevel[$CatParent])*35)+35;
					
										
					for ($x = 0; $x < count($PageIDsArray[$CategoryIDsArray[$CatParent][$i]]); $x++) {
											
						$CatsPrint .= '<table border="0" cellpadding="0" cellspacing="0"><tr><td>'.$CatSpacer.'</td><td><font size="'.$FontSize.'" color="'.$FontColor.'">&nbsp;&nbsp;&nbsp;<input type="checkbox" name="PagesList-'.$PageIDsArray[$CategoryIDsArray[$CatParent][$i]][$x].'" value="y"'.$PageSelected[$PageIDsArray[$CategoryIDsArray[$CatParent][$i]][$x]].'>&nbsp;'.$PageNamesArray[$CategoryIDsArray[$CatParent][$i]][$x].' ('.$PageLinksArray[$CategoryIDsArray[$CatParent][$i]][$x].')</font></td></tr></table>';
					
					}
					
					
					if (count($CategoryIDsArray[$CatParent][$i]) > 0) {
						SpiderCategories69($CategoryIDsArray[$CatParent][$i]);
					}
				
				}
				
				
			}
			
			SpiderCategories69('0');
			
				
			
			
			$DisplayList69 = $CatsPrint;
			
			
		}
		
		
		$row['ModulesList'] = str_replace('-','',$row['ModulesList']);
		$ModulesListPieces = explode(',', $row['ModulesList']);
		for ($c = 0; $c < count($ModulesListPieces); $c++) {
			$ModuleSelected[$ModulesListPieces[$c]] = ' checked';
		}
		
		
		$DisplayList69 .= '<b><br>
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-core" value="y"'.$ModuleSelected['core'].'>&nbsp;'.$MsgText[0][569].'
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-cl" value="y"'.$ModuleSelected['cl'].'>&nbsp;'.$MsgText[1][1].'
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-mb" value="y"'.$ModuleSelected['mb'].'>&nbsp;'.$MsgText[2][1].'
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-pg" value="y"'.$ModuleSelected['pg'].'>&nbsp;'.$MsgText[3][1].'
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-nl" value="y"'.$ModuleSelected['nl'].'>&nbsp;'.$MsgText[5][1].'
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-gb" value="y"'.$ModuleSelected['gb'].'>&nbsp;'.$MsgText[6][1].'
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-na" value="y"'.$ModuleSelected['na'].'>&nbsp;'.$MsgText[7][1].'
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-lm" value="y"'.$ModuleSelected['lm'].'>&nbsp;'.$MsgText[8][1].'
			<br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="ModulesList-ec" value="y"'.$ModuleSelected['ec'].'>&nbsp;'.$MsgText[9][1].'			
			</b>';
			
			
		
			
			
			
			$PageContents = '<form name="PostForm" action="'.$MainURL. '/admin/blocks-edit-save" method="post"><input type="hidden" name="BlockIDToEdit" value="'.$row['RecordNumber'].'"><input type="hidden" name="BlockType" value="'.$row['BlockType'].'">

<script>
var ExistingImagesWindowCode = "";

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

	ExistingImagesWindowCode = window.open("'.$BaseURL.'/inc-core-admin-editor-existingimages.php?"+document.forms["PostForm"].elements["TitleImage"].value,"existingimages",WindowProperties);
}
function ExistingImageSelected(ImageName,ImageWidth,ImageHeight) {

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

}
function UploadToServer() {

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

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

	  }

	  function UploadedImageSelected(ImageName,ImageWidth,ImageHeight) {

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


<b>'.$MsgText[0][241].':</b> '.$BlockTypes[$row['BlockType']].'<br><br>';
			
					
			if ($row['BlockType'] == '' || $row['BlockType'] == '0') {
				// custom block
			
				//if ($row['EnablePHP'] == 1) { $EnablePHPChecked = ' checked'; }
				//if ($row['NLtoBR'] == 1) { $NLtoBRChecked = ' checked'; }
				//if ($row['ConvertLinks'] == 1) { $ConvertLinksChecked = ' checked'; }
			
			
				if ($Permissions[9] == 'y') {
					//$PHPSection = '<input type="checkbox" name="EnablePHP" value="1"'.$EnablePHPChecked.'> Yes';
														
					$row['BlockContents'] = preg_replace("/\&([\#\d\w]{1,5})\;/i", "&amp;\\1;", $row['BlockContents']);
					$row['BlockContents'] = str_replace('<!--', '&lt;!--', $row['BlockContents']);
					//$row['BlockContents'] = str_replace('</', '&lt;/', $row['BlockContents']);
					$row['BlockContents'] = str_replace('</textarea>', '&lt;/textarea>', $row['BlockContents']);
					
										
					$CustomContents = '<script>
var EditorStarted = false;

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

			oFCKeditor.BasePath = "'.$BaseURL.'/fckeditor/" ;	// "/fckeditor/" is the default value.

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

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

<div id="EditorDiv"><textarea id="BlockContents" name="BlockContents" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual">'.$row['BlockContents'].'</textarea></div><div id="NonEditorDiv" style="display: none;"><textarea id="BlockContents2" name="BlockContents2" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual">'.$row['BlockContents'].'</textarea></div><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt="">'.$MsgText[0][180].':&nbsp;&nbsp;<input type="checkbox" name="NLtoBR" value="1"'.$NLtoBRChecked.'> '.$MsgText[0][118].'<br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt=""><font size="1">'.$MsgText[0][181].'</font><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt="">'.$MsgText[0][182].':&nbsp;&nbsp;<input type="checkbox" name="ConvertLinks" value="1"'.$ConvertLinksChecked.'> '.$MsgText[0][118].'<br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt=""><font size="1">'.$MsgText[0][183].'</font><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="6" alt="">';

					$CustomBlockScripts = '<script type="text/javascript" src="'.$BaseURL.'/fckeditor/fckeditor.js"></script><script>UpdatePageType();</script>';
					
				}
				else {
					if ($row['EnablePHP'] == 1) {
						//$PHPSection = $MsgText[0][118].'<input type="hidden" name="EnablePHP" value="1">';
					
						$row['BlockContents'] = str_replace('"', '&#34;', $row['BlockContents']);
						$CustomContents = '<i>('.$MsgText[0][242].')</i><input id="EnablePHP" type="hidden" name="EnablePHP" value="1">';
					}
					else {
						//$PHPSection = $MsgText[0][119];
					
						$row['BlockContents'] = preg_replace("/\&([\#\d\w]{1,5})\;/i", "&amp;\\1;", $row['BlockContents']);
						$row['BlockContents'] = str_replace('<!--', '&lt;!--', $row['BlockContents']);
						$row['BlockContents'] = str_replace('</', '&lt;/', $row['BlockContents']);
					
						$CustomContents = '<script>
var EditorStarted = false;

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

			oFCKeditor.BasePath = "'.$BaseURL.'/fckeditor/" ;	// "/fckeditor/" is the default value.

			oFCKeditor.Height	= 500 ;
			
			//oFCKeditor.Create() ;
			oFCKeditor.ReplaceTextarea();
			
			EditorStarted = true;
		}
	
		document.getElementById("EditorDiv").style.display = "";
		document.getElementById("NonEditorDiv").style.display = "none";
		document.getElementById("EnablePHP").value = 0;
	}
	else if (PageType == 2) {
		document.getElementById("EditorDiv").style.display = "none";
		document.getElementById("NonEditorDiv").style.display = "";
		document.getElementById("EnablePHP").value = 0;
	}
}
</script>

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

<div id="EditorDiv"><textarea id="BlockContents" name="BlockContents" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual">'.$row['BlockContents'].'</textarea></div><div id="NonEditorDiv" style="display: none;"><textarea id="BlockContents2" name="BlockContents2" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual">'.$row['BlockContents'].'</textarea></div><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt="">'.$MsgText[0][180].':&nbsp;&nbsp;<input type="checkbox" name="NLtoBR" value="1"'.$NLtoBRChecked.'> '.$MsgText[0][118].'<br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt=""><font size="1">'.$MsgText[0][181].'</font><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="4" alt=""><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt="">'.$MsgText[0][182].':&nbsp;&nbsp;<input type="checkbox" name="ConvertLinks" value="1"'.$ConvertLinksChecked.'> '.$MsgText[0][118].'<br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="45" height="1" alt=""><font size="1">'.$MsgText[0][183].'</font><br><img src="'.$ImagesURL.'/admin/admin/spacer.gif" border="0" width="1" height="6" alt="">';

						$CustomBlockScripts = '<script type="text/javascript" src="'.$BaseURL.'/fckeditor/fckeditor.js"></script><script>UpdatePageType();</script>';
						
					}
				}
			
			
				
				$CustomBlockStuff = '<br><br>'.$EditorStuff.'<br><b>'.$MsgText[0][178].':</b><br>'.$CustomContents.'<br><br>';
				
				



} // end if custom block
else {

	if ($row['BlockType'] == 'cr-1') {
		// main menu
			
		include_once('./inc-core-admin-blocks-bw_menu.php');
	
	} // end cr-1
	//else if ($row['BlockType'] == 'cr-2') {
	
		// any options for the users online block will go here
	
	//}
	else if ($row['BlockType'] == 'cr-3') {
		// random link
			
		include_once('./inc-core-admin-blocks-bw_randlink.php');
	
	} // end cr-3
	else if ($row['BlockType'] == 'cr-4') {
		// random code/text
			
		include_once('./inc-core-admin-blocks-bw_randcode.php');
	
	} // end cr-4
	else if ($row['BlockType'] == 'cr-5') {
		// random code/text
			
		include_once('./inc-core-admin-blocks-bw_linkstopages.php');
	
	} // end cr-4
		

} // end pmb


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

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

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

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

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

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



<br><b>'.$MsgText[0][168].':</b>&nbsp;&nbsp;<select name="BlockLocation">
	<option value="1"'.$BlockLocationSelected['1'].'> '.$MsgText[0][7].'</option>
	<option value="2"'.$BlockLocationSelected['2'].'> '.$MsgText[0][8].'</option>
	<option value="3"'.$BlockLocationSelected['3'].'> '.$MsgText[0][9].'</option>
	<option value="4"'.$BlockLocationSelected['4'].'> '.$MsgText[0][10].'</option>
	<option value="5"'.$BlockLocationSelected['5'].'> '.$MsgText[0][11].'</option>
	<option value="6"'.$BlockLocationSelected['6'].'> '.$MsgText[0][12].'</option>
	<option value="7"'.$BlockLocationSelected['7'].'> '.$MsgText[0][13].'</option>
	<option value="8"'.$BlockLocationSelected['8'].'> '.$MsgText[0][14].'</option>
</select>
<br><!-- <font size="1">Position of the Block within the blocks framework.</font><br> -->

'.$CustomBlockStuff.'

<br><b>'.$MsgText[0][184].':</b>&nbsp;&nbsp;<select name="BlockAlignment">
	<option value="L"'.$BlockAlignmentSelected['L'].'> '.$MsgText[0][15].'</option>
	<option value="C"'.$BlockAlignmentSelected['C'].'> '.$MsgText[0][16].'</option>
	<option value="R"'.$BlockAlignmentSelected['R'].'> '.$MsgText[0][17].'</option>
</select>
<br><font size="1">'.$MsgText[0][185].'</font><br><br><b>'.$MsgText[0][186].':</b>&nbsp;&nbsp;<select name="BlockEnabled">
	<option value="0"'.$BlockEnabledSelected['0'].'> '.$MsgText[0][187].'</option>
	<option value="1"'.$BlockEnabledSelected['1'].'> '.$MsgText[0][188].'</option>
</select>
<br>
<br>
<b>'.$MsgText[0][189].':</b>&nbsp;&nbsp;<select name="MinLevel">'.$PermissionsDropdown.'</select><br><font size="1">'.$MsgText[0][190].'<br></font>
<br>
<b>'.$MsgText[0][543].':</b>&nbsp;&nbsp;<select name="MinEditLevel">'.$PermissionsDropdown2.'</select><br><font size="1">'.$MsgText[0][545].'<br></font>

<br>
<br>
<b>'.$MsgText[0][199].':</b>&nbsp;&nbsp;<input type="text" name="BlockPriority" size="3" value="'.$row['BlockPriority'].'">

<br><br><br>

<b>Pages To Display On:</b><br> - Leave this section blank to display the block on all site pages<br> - Selecting a page category will display the block on all pages within that category<br>

'.$DisplayList69.'

<input type="hidden" name="LargestPageID" value="'.$LargestPageID.'">
<input type="hidden" name="LargestPageCatID" value="'.$LargestPageCatID.'">



<br><br>
<br><br><b>'.$MsgText[0][243].':</b><br>&nbsp;&nbsp;&nbsp;<input type="checkbox" name="DeleteBlock" value="delete"> '.$MsgText[0][235].'<br>
<br><br>
<br>
<input type="submit" value="'.$MsgText[0][123].'">
<script>var FlexCMSScriptName="'.$Settings['ScriptName'].'";</script>
'.$CustomBlockScripts.'



</form><br>';
	
			

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

	} // end if logged in
	else {
	
		RedirectToLogin();
	
	}

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




?>
