<?

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



	// ========================================================================================
	// preview message post
	// ========================================================================================
	
			for ($i = 33; $i <= 126; $i++) {
				$HTMLCodes[chr($i)] = $i;
			}
			
	
	
			$CharsToReplaceArray[';'] = 1;
			
			$SearchChars[] = '[';
			$ReplacementChars[] = '&#'.$HTMLCodes['['].';';
			$CharsToReplaceArray['['] = 1;
			
			$SearchChars[] = '/';
			$ReplacementChars[] = '&#'.$HTMLCodes['/'].';';
			$CharsToReplaceArray['/'] = 1;
			
			$SearchChars[] = ']';
			$ReplacementChars[] = '&#'.$HTMLCodes[']'].';';
			$CharsToReplaceArray[']'] = 1;
			
			$CharsToReplaceArray['&'] = 1;
			
			$CharsToReplaceArray['#'] = 1;
			
			$CharsToReplaceArray['l'] = 1;
			$CharsToReplaceArray['t'] = 1;
			
			
			for ($w = 0; $w <= 9; $w++) {
				$CharsToReplaceArray[$w] = 1;			
			}
			
			
			
	
			// smilies setup
				$query8 = "select * from `".$Settings['DBPrefix']."core-Smilies` where Enabled=1";
				$result8 = mysql_query($query8) or die (mysql_error());
				while ($row8 = mysql_fetch_array($result8)) {
				
					if ($row8['InsertCode'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode'];
						$SmilieFiles[$row8['InsertCode']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode']] = $row8['Description'];
					}
					if ($row8['InsertCode2'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode2'];
						$SmilieFiles[$row8['InsertCode2']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode2']] = $row8['Description'];
					}
					if ($row8['InsertCode3'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode3'];
						$SmilieFiles[$row8['InsertCode3']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode3']] = $row8['Description'];
					}
					if ($row8['InsertCode4'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode4'];
						$SmilieFiles[$row8['InsertCode4']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode4']] = $row8['Description'];
					}
					if ($row8['InsertCode5'] != '') {
						$SmiliesCount++;
						$SmilieCodes[] = $row8['InsertCode5'];
						$SmilieFiles[$row8['InsertCode5']] = $row8['ImageLink'];
						$SmilieDescriptions[$row8['InsertCode5']] = $row8['Description'];
					}
									
				}
				
				if ($SmiliesCount > 0) {
				
					for ($i = 0; $i < $SmiliesCount; $i++) {
						for ($h = 0; $h < ($SmiliesCount-1); $h++) {
						
							if (strlen($SmilieCodes[$h]) < strlen($SmilieCodes[$h+1])) {
									
								$Swap1 = $SmilieCodes[$h+1];
																	
								$SmilieCodes[$h+1] = $SmilieCodes[$h];
																
								$SmilieCodes[$h] = $Swap1;
									
							}
									
						}
					}
				
				
					for ($i = 0; $i < $SmiliesCount; $i++) {
									
						for ($x = 0; $x < strlen($SmilieCodes[$i]); $x++) {
						
							$CurrentChar = substr($SmilieCodes[$i], $x, 1);
		
							if ($CharsToReplaceArray[$CurrentChar] != 1) {
							
								$SearchChars[] = $CurrentChar;
								$ReplacementChars[] = '&#'.$HTMLCodes[$CurrentChar].';';
							
							}
						
						}
					
					}
				
				
				
					for ($i = 0; $i < $SmiliesCount; $i++) {
					
						/*
						$SmiliesSearchArray[] = ' '.$SmilieCodes[$i];
						$SmiliesSearchArray[] = '>'.$SmilieCodes[$i];
						
						if (substr($SmilieFiles[$SmilieCodes[$i]],0,4) != 'http') {
							$SmilieFiles[$SmilieCodes[$i]] = $ImagesURL . '/smilies/' . $SmilieFiles[$SmilieCodes[$i]]; 
						}
						
						$SmiliesReplaceArray[] = ' <img src="'.$SmilieFiles[$SmilieCodes[$i]].'" alt="'.$SmilieDescriptions[$SmilieCodes[$i]].'">';
						$SmiliesReplaceArray[] = '><img src="'.$SmilieFiles[$SmilieCodes[$i]].'" alt="'.$SmilieDescriptions[$SmilieCodes[$i]].'">';
						*/
						
						
						$SmiliesSearchArray[] = ' ' . $SmilieCodes[$i];
						
						if (substr($SmilieFiles[$SmilieCodes[$i]],0,4) != 'http') {
							$SmilieFiles[$SmilieCodes[$i]] = $ImagesURL . '/smilies/' . $SmilieFiles[$SmilieCodes[$i]]; 
						}
						
						$SmiliesReplaceArray[] = '<img src="'.$SmilieFiles[$SmilieCodes[$i]].'" alt="'.$SmilieDescriptions[$SmilieCodes[$i]].'">';
												
					
					}
				
				}
				else {
				
					$DoSmilies = false;
				
				}
			// end smilies setup
	
	
	
			// smilies setup
		
			$SmiliesBlock .= '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td>&nbsp;</td>';
		
		
			$query8 = "select * from `".$Settings['DBPrefix']."core-Smilies` where Enabled=1 and Hidden!=1 order by SmilieOrder asc";
			$result8 = mysql_query($query8) or die (mysql_error());
			while ($row8 = mysql_fetch_array($result8)) {
				
				if ($row8['InsertCode'] != '') {
				
					$InsertCode = $row8['InsertCode'];
					
					$InsertCode = str_replace('\\','\\\\',$InsertCode);
					$InsertCode = str_replace('\'','\\\'',$InsertCode);
					
					
					if (substr($row8['ImageLink'],0,4) != 'http') {
						$ImageLink = $ImagesURL . '/smilies/' . $row8['ImageLink'];					
					}
					else {
						$ImageLink = $row8['ImageLink'];
					}
					
					
					$SmiliesBlock .= '<td align="center"><a href="javascript:InsertSmiles(\''.$InsertCode.'\')"><img src="'.$ImageLink.'" border="0" alt="'.$row8['Description'].'"></a></td><td>&nbsp;</td>';
					
					
				}
				
			}

			
			$SmiliesBlock .= '</tr></table>';
	
	
	
	
	
	
				$row['Message'] = stripslashes($FormArguments['Message']);
	
	
		
				$row['Message'] = str_replace('<', '&lt;', $row['Message']);
				//$row['Message'] = str_replace("\n", '<br>', $row['Message']);
				//$row['Message'] = str_replace("\r", '', $row['Message']);
				
								
				$LowerCaseMessage = strtolower($row['Message']);
				
				
				// code -- do first
										
				// if [code] exists in message
				if (strpos($LowerCaseMessage,'[code]',0) !== false) {
				
					$Subject = $LowerCaseMessage;
					
					$OpenTags = '';
					$OpenTagsCount = 0;
					$CloseTags = '';
					$CloseTagsCount = 0;
					$AllTags = '';
					$AllTagsPos = '';
					$TotalTagsCount = 0;
					$AllTagsLevels = '';
					
					
					$Position = 0;
					$CurrentPos = 0;
										
					while (strpos($Subject,'[code]',$CurrentPos) !== false) {
						
						$Position = strpos($Subject,'[code]',$CurrentPos);
					
						$OpenTags[] = $Position;
						$OpenTagsCount++;
						$CurrentPos = $Position+strlen('[code]');
					
					}
					
		
					
					$Position = 0;
					$CurrentPos = 0;
					$Subject = strtolower($row['Message']);
					
					while (strpos($Subject,'[/code]',$CurrentPos) !== false) {
						
						$Position = strpos($Subject,'[/code]',$CurrentPos);
					
						$CloseTags[] = $Position;
						$CloseTagsCount++;
						$CurrentPos = $Position+strlen('[/code]');				
					}
					
					
					for ($i = 1; $i <= $OpenTagsCount; $i++) {
						$AllTags[] = 'open';
						$AllTagsPos[] = $OpenTags[$i-1];
					}
					for ($i = 1; $i <= $CloseTagsCount; $i++) {
						$AllTags[] = 'close';
						$AllTagsPos[] = $CloseTags[$i-1];
					}
									
					$TotalTagsCount = ($OpenTagsCount+$CloseTagsCount);
					
					
					for ($g = 0; $g < $TotalTagsCount; $g++) {
						for ($h = 0; $h < ($TotalTagsCount-1); $h++) {
	
							if ($AllTagsPos[$h] > $AllTagsPos[$h+1]) {
										
								$Swap1 = $AllTagsPos[$h+1];
								$Swap2 = $AllTags[$h+1];
																	
								$AllTagsPos[$h+1] = $AllTagsPos[$h];
								$AllTags[$h+1] = $AllTags[$h];
																	
								$AllTagsPos[$h] = $Swap1;
								$AllTags[$h] = $Swap2;
								
										
							}
						
						}
					}
				
					
					$Level = 1;
					for ($g = 0; $g < $TotalTagsCount; $g++) {
					
						if ($g > 0) {
						
							if ($AllTags[$g] == 'open' && $AllTags[$g-1] == 'open') {
								$Level++;
							}
							if ($AllTags[$g] == 'close' && $AllTags[$g-1] == 'close') {
								$Level--;
							}
						
						}
						
						$AllTagsLevels[$g] = $Level;
					
					}	
					
					
					
					
					for ($g = 0; $g < $TotalTagsCount; $g++) {
						for ($h = 0; $h < ($TotalTagsCount-1); $h++) {
	
							if ($AllTagsLevels[$h] > $AllTagsLevels[$h+1]) {
										
								$Swap1 = $AllTagsPos[$h+1];
								$Swap2 = $AllTags[$h+1];
								$Swap3 = $AllTagsLevels[$h+1];
																	
								$AllTagsPos[$h+1] = $AllTagsPos[$h];
								$AllTags[$h+1] = $AllTags[$h];
								$AllTagsLevels[$h+1] = $AllTagsLevels[$h];
																	
								$AllTagsPos[$h] = $Swap1;
								$AllTags[$h] = $Swap2;
								$AllTagsLevels[$h] = $Swap3;
								
										
							}
						
						}
					}
					
					
					
					// using the real version now, not the one converted to lower case for pattern matching:
					$Subject = $row['Message'];
												
					
					for ($g = 0; $g < $TotalTagsCount; $g=$g+2) {
										
						$FirstHalfBefore = substr($Subject,0,($AllTagsPos[$g]+6));
						$SecondHalfBefore = substr($Subject,$AllTagsPos[$g+1]);
						
						$LengthBefore = strlen($Subject);
						
						$Subject = $FirstHalfBefore . str_replace($SearchChars, $ReplacementChars, substr($Subject,($AllTagsPos[$g]+6), (($AllTagsPos[$g+1])-($AllTagsPos[$g]+6)) ) ) . $SecondHalfBefore;

						$LengthAfter = strlen($Subject);
					
						
						$AdditionalLength = ($LengthAfter-$LengthBefore);
					
						
						for ($h = ($g+2); $h < $TotalTagsCount; $h++) {
							$AllTagsPos[$h] = ($AllTagsPos[$h] + $AdditionalLength);			
						}
					
					}	
				
				
					$row['Message'] = $Subject;
								
				
					$row['Message'] = preg_replace("/(\[code\])(.*?)(\[\/code\])/sie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['Text'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['BG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\"><b>Code</b><br><br>'.stripslashes('\\2').'</font></td></tr></table></td></tr></table>'", $row['Message']);


				} // end if [code] found in message
				
				
				
				// smilies
				//if ($DoSmilies != false) {		
					$row['Message'] = str_replace($SmiliesSearchArray, $SmiliesReplaceArray, $row['Message']);
				//}
				
				
				
				$row['Message'] = str_replace("\n", '[br]', $row['Message']);
				$row['Message'] = str_replace("\r", '', $row['Message']);
				
				
				// horizontal rule (hr)
				$row['Message'] = str_replace('[hr]', '<hr>', $row['Message']);
				
				
				// font faces and sizes
				$row['Message'] = preg_replace("/(\[font=)(.*?)(\])/i", "<font face=\"\\2\">", $row['Message']);
				$row['Message'] = preg_replace("/(\[size=)(.*?)(\])/i", "<font size=\"\\2\">", $row['Message']);
				
				$row['Message'] = str_replace('[/font]', '</font>', $row['Message']);
				$row['Message'] = str_replace('[/size]', '</font>', $row['Message']);
				
				
				// bold
				$row['Message'] = preg_replace("/(\[b\])(.*?)(\[\/b\])/i", "<b>\\2</b>", $row['Message']);
				//$row['Message'] = str_replace('[b]', '<b>', $row['Message']);
				//$row['Message'] = str_replace('[/b]', '</b>', $row['Message']);
				//$row['Message'] = preg_replace("/\[b\]/i", "<b>", $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/b\]/i", "</b>", $row['Message']); 
				
				// italics
				$row['Message'] = preg_replace("/(\[i\])(.*?)(\[\/i\])/i", "<i>\\2</i>", $row['Message']);
				//$row['Message'] = str_replace('[i]', '<i>', $row['Message']);
				//$row['Message'] = str_replace('[/i]', '</i>', $row['Message']);
				//$row['Message'] = preg_replace("/\[i\]/i", "<i>", $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/i\]/i", "</i>", $row['Message']);
				
				// underline
				$row['Message'] = preg_replace("/(\[u\])(.*?)(\[\/u\])/i", "<u>\\2</u>", $row['Message']);
				//$row['Message'] = str_replace('[u]', '<u>', $row['Message']);
				//$row['Message'] = str_replace('[/u]', '</u>', $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/u\]/i", "</u>", $row['Message']);
				
				
				// colors
				$ColorCodes['black'] = '#000000';
				$ColorCodes['white'] = '#ffffff';
				$ColorCodes['red'] = '#ff0000';
				$ColorCodes['yellow'] = '#ffff00';
				$ColorCodes['green'] = '#008000';
				$ColorCodes['grey'] = '#888888';
				$ColorCodes['burgundy'] = '#990000';
				$ColorCodes['orange'] = '#ff9900';
				$ColorCodes['purple'] = '#9900ff';
				$ColorCodes['cream'] = '#ffffcc';
				$ColorCodes['teal'] = '#008080';
				$ColorCodes['salmon'] = '#ffcccc';
				$ColorCodes['blue'] = '#0000ff';
				$ColorCodes['pink'] = '#ff33cc';
				$ColorCodes['navy'] = '#003399';
				$ColorCodes['lightblue'] = '#33ccff';
				$ColorCodes['mauve'] = '#666699';
				$ColorCodes['limegreen'] = '#00ff00';
				
				//$row['Message'] = preg_replace("/(\[color\=)([a-zA-Z]+)(\])/i", "<font color=\"\\2\">", $row['Message']);
				$StringMatches = substr_count($row['Message'],'[color=');
				for ($i = 1; $i <= $StringMatches; $i++) {				
					$row['Message'] = preg_replace("/(\[color\=)(.*?)(\])(.*?)(\[\/color\])/ie", "'<font color='.\$ColorCodes['\\2'].'>'.stripslashes('\\4').'</font>'", $row['Message']);
				}
				 
				//$row['Message'] = preg_replace("/(\[\/color\])/", "</font>", $row['Message']); 
				
				
				
				  
				// urls
				$row['Message'] = preg_replace("/(\[url=\")(.*?)(\"\])(.*?)(\[\/url\])/ie", "'<a href=\"\\2\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\4</font></a>'", $row['Message']);
				
				// urls
				$row['Message'] = preg_replace("/(\[url=)(.*?)(\])(.*?)(\[\/url\])/ie", "'<a href=\"\\2\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\4</font></a>'", $row['Message']);			
				
				$row['Message'] = preg_replace("/(\[url\])(.*?)(\[\/url\])/ie", "'<a href=\"\\2\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">'.FormatLongURL('\\2').'</font></a>'", $row['Message']);
				
				
									
				// images
				$row['Message'] = preg_replace("/(\[img\])(.*?)(\[\/img\])/i", "<img src=\"\\2\" border=\"0\" alt=\"\">", $row['Message']);
				
				
				
				
		
				// convert URLs in text to clickable tags
				$row['Message'] = preg_replace("/(?<!\"|\>)(http:\/\/)([\w\.\-\/]+)/e", "'<a href=\"\\0\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\0</font></a>'", $row['Message']);
				
				
				
				$row['Message'] = str_replace('[br]', '<br>', $row['Message']);
				
				
				
				
				
				// emails
				
				// if [email] exists in the message
				if (strpos($LowerCaseMessage,'[email]',0) !== false) {
				
					$StringLength1 = rand(8, 14);
					$StringLength2 = rand(6, 15);
					$CharactersArray = array ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9','0');								
					$Random1 = 'a';
					$Random2 = 'b';
					for ($i = 1; $i <= $StringLength1; $i++) {
						$RandomNum = rand(1, 62);
						$Random1 .= $CharactersArray[$RandomNum];
					}
					for ($i = 1; $i <= $StringLength2; $i++) {
						$RandomNum = rand(1, 62);
						$Random2 .= $CharactersArray[$RandomNum];
					}
				
				
					$row['Message'] = preg_replace("/(\[email\])(.*?)(@)(.*?)(\[\/email\])/ie", "'<script language=\"JavaScript\">var '.\$Random1.' = \'\\2\'; var '.\$Random2.' = \'\\4\'; document.write(\'<a href=\"mai\'+\'lto:\'+'.\$Random1.'+String.fromCharCode(64)+'.\$Random2.'+\'\">\'+'.\$Random1.'+String.fromCharCode(64)+'.\$Random2.'+\'</a>\');</script>'", $row['Message']);			
				
				} // end if [email] found in message
				
				
				// alignment
				/*
				$row['Message'] = str_replace('[left]', '<div align="left">', $row['Message']);
				$row['Message'] = str_replace('[/left]', '</div>', $row['Message']);
				$row['Message'] = str_replace('[center]', '<div align="center">', $row['Message']);
				$row['Message'] = str_replace('[/center]', '</div>', $row['Message']);
				$row['Message'] = str_replace('[right]', '<div align="right">', $row['Message']);
				$row['Message'] = str_replace('[/right]', '</div>', $row['Message']);
				*/
				$row['Message'] = preg_replace("/(\[left\])(.*?)(\[\/left\])/i", "<div align=\"left\">\\2</div>", $row['Message']);
				$row['Message'] = preg_replace("/(\[center\])(.*?)(\[\/center\])/i", "<div align=\"center\">\\2</div>", $row['Message']);
				$row['Message'] = preg_replace("/(\[right\])(.*?)(\[\/right\])/i", "<div align=\"right\">\\2</div>", $row['Message']);
				
				
				
				// quotes -- do last
				
				// if [quote exists in the message
				if (strpos($LowerCaseMessage,'[quote',0) !== false) {
				
					// quotes with a user
					$StringMatches = substr_count($row['Message'],'[quote=');
					for ($i = 1; $i <= $StringMatches; $i++) {				
						$row['Message'] = preg_replace("/(\[quote=)(.*?)(\])(.*?)(\[\/quote\])/ie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['Text'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['BG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\"><b>Quote ('.stripslashes(\$DisplayNames[\\2]).')</b><br><br>'.stripslashes('\\4').'</font></td></tr></table></td></tr></table>'", stripslashes($row['Message']));
					}
					// quotes without a user
					$StringMatches = substr_count($row['Message'],'[quote]');
					for ($i = 1; $i <= $StringMatches; $i++) {				
						$row['Message'] = preg_replace("/(\[quote\])(.*?)(\[\/quote\])/ie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['Text'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['BG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\"><b>Quote</b><br><br>'.stripslashes('\\2').'</font></td></tr></table></td></tr></table>'", $row['Message']);
					}
				
				
				} // end if [quote exists in the message
				
				
				
			$MessagePreviewPrint = stripslashes($row['Message']);
		
		
		
		$FormArguments['BoardID'] = intval($FormArguments['BoardID']);
		$FormArguments['ThreadID'] = intval($FormArguments['ThreadID']);
		
		
		
		$query = "select * from `".$Settings['DBPrefix']."mb-Messages` where ThreadID=".$FormArguments['ThreadID']." order by DateCode desc";
		$result = mysql_query($query) or die (mysql_error());
		while ($row = mysql_fetch_array($result)) {
		
			if (date("j/n/Y", GetTimestamp()) == date("j/n/Y", $row['DateCode'])) {
				$PostTime = $MsgText[2][66].' @ '.date("g:ia", $row['DateCode']);
			}
			else if (date("j/n/Y", (GetTimestamp()-(60*60*24))) == date("j/n/Y", $row['DateCode'])) {
				$PostTime = $MsgText[2][67].' @ '.date("g:ia", $row['DateCode']);
			}
			else {
				$PostTime = $MsgText[0][33+date("n",$row['DateCode'])].' '.date("j, Y @ g:ia", $row['DateCode']);
			}
			
			
			
			// removed when processing full messages the same way as viewed in forum -- DC Feb 4, 2009
				//$row['Message'] = str_replace('<', '&lt;', $row['Message']);
				//$row['Message'] = str_replace("\n", '<br>', $row['Message']);
				//$row['Message'] = str_replace("\r", '', $row['Message']);
			//
			
				
				$row['Message'] = str_replace('<', '&lt;', $row['Message']);
				//$row['Message'] = str_replace("\n", '<br>', $row['Message']);
				//$row['Message'] = str_replace("\r", '', $row['Message']);
				
								
				$LowerCaseMessage = strtolower($row['Message']);
				
				
				// code -- do first
										
				// if [code] exists in message
				if (strpos($LowerCaseMessage,'[code]',0) !== false) {
				
					$Subject = $LowerCaseMessage;
					
					$OpenTags = '';
					$OpenTagsCount = 0;
					$CloseTags = '';
					$CloseTagsCount = 0;
					$AllTags = '';
					$AllTagsPos = '';
					$TotalTagsCount = 0;
					$AllTagsLevels = '';
					
					
					$Position = 0;
					$CurrentPos = 0;
										
					while (strpos($Subject,'[code]',$CurrentPos) !== false) {
						
						$Position = strpos($Subject,'[code]',$CurrentPos);
					
						$OpenTags[] = $Position;
						$OpenTagsCount++;
						$CurrentPos = $Position+strlen('[code]');
					
					}
					
		
					
					$Position = 0;
					$CurrentPos = 0;
					$Subject = strtolower($row['Message']);
					
					while (strpos($Subject,'[/code]',$CurrentPos) !== false) {
						
						$Position = strpos($Subject,'[/code]',$CurrentPos);
					
						$CloseTags[] = $Position;
						$CloseTagsCount++;
						$CurrentPos = $Position+strlen('[/code]');				
					}
					
					
					for ($i = 1; $i <= $OpenTagsCount; $i++) {
						$AllTags[] = 'open';
						$AllTagsPos[] = $OpenTags[$i-1];
					}
					for ($i = 1; $i <= $CloseTagsCount; $i++) {
						$AllTags[] = 'close';
						$AllTagsPos[] = $CloseTags[$i-1];
					}
									
					$TotalTagsCount = ($OpenTagsCount+$CloseTagsCount);
					
					
					for ($g = 0; $g < $TotalTagsCount; $g++) {
						for ($h = 0; $h < ($TotalTagsCount-1); $h++) {
	
							if ($AllTagsPos[$h] > $AllTagsPos[$h+1]) {
										
								$Swap1 = $AllTagsPos[$h+1];
								$Swap2 = $AllTags[$h+1];
																	
								$AllTagsPos[$h+1] = $AllTagsPos[$h];
								$AllTags[$h+1] = $AllTags[$h];
																	
								$AllTagsPos[$h] = $Swap1;
								$AllTags[$h] = $Swap2;
								
										
							}
						
						}
					}
				
					
					$Level = 1;
					for ($g = 0; $g < $TotalTagsCount; $g++) {
					
						if ($g > 0) {
						
							if ($AllTags[$g] == 'open' && $AllTags[$g-1] == 'open') {
								$Level++;
							}
							if ($AllTags[$g] == 'close' && $AllTags[$g-1] == 'close') {
								$Level--;
							}
						
						}
						
						$AllTagsLevels[$g] = $Level;
					
					}	
					
					
					
					
					for ($g = 0; $g < $TotalTagsCount; $g++) {
						for ($h = 0; $h < ($TotalTagsCount-1); $h++) {
	
							if ($AllTagsLevels[$h] > $AllTagsLevels[$h+1]) {
										
								$Swap1 = $AllTagsPos[$h+1];
								$Swap2 = $AllTags[$h+1];
								$Swap3 = $AllTagsLevels[$h+1];
																	
								$AllTagsPos[$h+1] = $AllTagsPos[$h];
								$AllTags[$h+1] = $AllTags[$h];
								$AllTagsLevels[$h+1] = $AllTagsLevels[$h];
																	
								$AllTagsPos[$h] = $Swap1;
								$AllTags[$h] = $Swap2;
								$AllTagsLevels[$h] = $Swap3;
								
										
							}
						
						}
					}
					
					
					
					// using the real version now, not the one converted to lower case for pattern matching:
					$Subject = $row['Message'];
												
					
					for ($g = 0; $g < $TotalTagsCount; $g=$g+2) {
										
						$FirstHalfBefore = substr($Subject,0,($AllTagsPos[$g]+6));
						$SecondHalfBefore = substr($Subject,$AllTagsPos[$g+1]);
						
						$LengthBefore = strlen($Subject);
						
						$Subject = $FirstHalfBefore . str_replace($SearchChars, $ReplacementChars, substr($Subject,($AllTagsPos[$g]+6), (($AllTagsPos[$g+1])-($AllTagsPos[$g]+6)) ) ) . $SecondHalfBefore;

						$LengthAfter = strlen($Subject);
					
						
						$AdditionalLength = ($LengthAfter-$LengthBefore);
					
						
						for ($h = ($g+2); $h < $TotalTagsCount; $h++) {
							$AllTagsPos[$h] = ($AllTagsPos[$h] + $AdditionalLength);			
						}
					
					}	
				
				
					$row['Message'] = $Subject;
								
				
					$row['Message'] = preg_replace("/(\[code\])(.*?)(\[\/code\])/sie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBorder'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\" color=\"'.\$Colors['MBQCText'].'\"><b>Code</b><br><br>'.stripslashes('\\2').'</font></td></tr></table></td></tr></table>'", $row['Message']);


				} // end if [code] found in message
				
				
				
				// smilies
				//if ($DoSmilies != false) {		
					$row['Message'] = str_replace($SmiliesSearchArray, $SmiliesReplaceArray, $row['Message']);
				//}
				
				
				$row['Message'] = str_replace("\n", '[br]', $row['Message']);
				$row['Message'] = str_replace("\r", '', $row['Message']);
				
				
				// horizontal rule (hr)
				$row['Message'] = str_replace('[hr]', '<hr>', $row['Message']);
				
				
				// font faces and sizes
				$row['Message'] = preg_replace("/(\[font=)(.*?)(\])/i", "<font face=\"\\2\">", $row['Message']);
				$row['Message'] = preg_replace("/(\[size=)(.*?)(\])/i", "<font size=\"\\2\">", $row['Message']);
				
				$row['Message'] = str_replace('[/font]', '</font>', $row['Message']);
				$row['Message'] = str_replace('[/size]', '</font>', $row['Message']);
				
				
				// bold
				$row['Message'] = preg_replace("/(\[b\])(.*?)(\[\/b\])/i", "<b>\\2</b>", $row['Message']);
				//$row['Message'] = str_replace('[b]', '<b>', $row['Message']);
				//$row['Message'] = str_replace('[/b]', '</b>', $row['Message']);
				//$row['Message'] = preg_replace("/\[b\]/i", "<b>", $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/b\]/i", "</b>", $row['Message']); 
				
				// italics
				$row['Message'] = preg_replace("/(\[i\])(.*?)(\[\/i\])/i", "<i>\\2</i>", $row['Message']);
				//$row['Message'] = str_replace('[i]', '<i>', $row['Message']);
				//$row['Message'] = str_replace('[/i]', '</i>', $row['Message']);
				//$row['Message'] = preg_replace("/\[i\]/i", "<i>", $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/i\]/i", "</i>", $row['Message']);
				
				// underline
				$row['Message'] = preg_replace("/(\[u\])(.*?)(\[\/u\])/i", "<u>\\2</u>", $row['Message']);
				//$row['Message'] = str_replace('[u]', '<u>', $row['Message']);
				//$row['Message'] = str_replace('[/u]', '</u>', $row['Message']); 
				//$row['Message'] = preg_replace("/\[\/u\]/i", "</u>", $row['Message']);
				
				
				// colors
				$ColorCodes['black'] = '#000000';
				$ColorCodes['white'] = '#ffffff';
				$ColorCodes['red'] = '#ff0000';
				$ColorCodes['yellow'] = '#ffff00';
				$ColorCodes['green'] = '#008000';
				$ColorCodes['grey'] = '#888888';
				$ColorCodes['burgundy'] = '#990000';
				$ColorCodes['orange'] = '#ff9900';
				$ColorCodes['purple'] = '#9900ff';
				$ColorCodes['cream'] = '#ffffcc';
				$ColorCodes['teal'] = '#008080';
				$ColorCodes['salmon'] = '#ffcccc';
				$ColorCodes['blue'] = '#0000ff';
				$ColorCodes['pink'] = '#ff33cc';
				$ColorCodes['navy'] = '#003399';
				$ColorCodes['lightblue'] = '#33ccff';
				$ColorCodes['mauve'] = '#666699';
				$ColorCodes['limegreen'] = '#00ff00';
				
				//$row['Message'] = preg_replace("/(\[color\=)([a-zA-Z]+)(\])/i", "<font color=\"\\2\">", $row['Message']);
				$StringMatches = substr_count($row['Message'],'[color=');
				for ($i = 1; $i <= $StringMatches; $i++) {				
					$row['Message'] = preg_replace("/(\[color\=)(.*?)(\])(.*?)(\[\/color\])/ie", "'<font color='.\$ColorCodes['\\2'].'>'.stripslashes('\\4').'</font>'", $row['Message']);
				}
				 
				//$row['Message'] = preg_replace("/(\[\/color\])/", "</font>", $row['Message']); 
				  
				
				
				// urls
				$row['Message'] = preg_replace("/(\[url=\")(.*?)(\"\])(.*?)(\[\/url\])/ie", "'<a href=\"\\2\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\4</font></a>'", $row['Message']);
				
				// urls
				$row['Message'] = preg_replace("/(\[url=)(.*?)(\])(.*?)(\[\/url\])/ie", "'<a href=\"\\2\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\4</font></a>'", $row['Message']);			
				
				$row['Message'] = preg_replace("/(\[url\])(.*?)(\[\/url\])/ie", "'<a href=\"\\2\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">'.FormatLongURL('\\2').'</font></a>'", $row['Message']);
				
				
									
				// images
				$row['Message'] = preg_replace("/(\[img\])(.*?)(\[\/img\])/i", "<img src=\"\\2\" border=\"0\" alt=\"\">", $row['Message']);
				
				
				
				
		
				// convert URLs in text to clickable tags
				$row['Message'] = preg_replace("/(?<!\"|\>)(http:\/\/)([\w\.\-\/]+)/e", "'<a href=\"\\0\" target=\"_blank\"><font color=\"'.\$Colors['MBText'].'\">\\0</font></a>'", $row['Message']);
				
				
				
				$row['Message'] = str_replace('[br]', '<br>', $row['Message']);
				
				
				
				
				// emails
				
				// if [email] exists in the message
				if (strpos($LowerCaseMessage,'[email]',0) !== false) {
				
					$StringLength1 = rand(8, 14);
					$StringLength2 = rand(6, 15);
					$CharactersArray = array ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','1','2','3','4','5','6','7','8','9','0');								
					$Random1 = 'a';
					$Random2 = 'b';
					for ($i = 1; $i <= $StringLength1; $i++) {
						$RandomNum = rand(1, 62);
						$Random1 .= $CharactersArray[$RandomNum];
					}
					for ($i = 1; $i <= $StringLength2; $i++) {
						$RandomNum = rand(1, 62);
						$Random2 .= $CharactersArray[$RandomNum];
					}
				
				
					$row['Message'] = preg_replace("/(\[email\])(.*?)(@)(.*?)(\[\/email\])/ie", "'<script language=\"JavaScript\">var '.\$Random1.' = \'\\2\'; var '.\$Random2.' = \'\\4\'; document.write(\'<a href=\"mai\'+\'lto:\'+'.\$Random1.'+String.fromCharCode(64)+'.\$Random2.'+\'\"><font color=\"'.\$Colors['MBText'].'\">\'+'.\$Random1.'+String.fromCharCode(64)+'.\$Random2.'+\'</font></a>\');</script>'", $row['Message']);			
				
				} // end if [email] found in message
				
				
				// alignment
				/*
				$row['Message'] = str_replace('[left]', '<div align="left">', $row['Message']);
				$row['Message'] = str_replace('[/left]', '</div>', $row['Message']);
				$row['Message'] = str_replace('[center]', '<div align="center">', $row['Message']);
				$row['Message'] = str_replace('[/center]', '</div>', $row['Message']);
				$row['Message'] = str_replace('[right]', '<div align="right">', $row['Message']);
				$row['Message'] = str_replace('[/right]', '</div>', $row['Message']);
				*/
				$row['Message'] = preg_replace("/(\[left\])(.*?)(\[\/left\])/i", "<div align=\"left\">\\2</div>", $row['Message']);
				$row['Message'] = preg_replace("/(\[center\])(.*?)(\[\/center\])/i", "<div align=\"center\">\\2</div>", $row['Message']);
				$row['Message'] = preg_replace("/(\[right\])(.*?)(\[\/right\])/i", "<div align=\"right\">\\2</div>", $row['Message']);
				
				
				
				// quotes -- do last
				
				$row['Message'] = str_replace('[quote=][/quote]','',$row['Message']);
				
				// if [quote exists in the message
				if (strpos($LowerCaseMessage,'[quote',0) !== false) {
				
					// quotes with a user
					$StringMatches = substr_count($row['Message'],'[quote=');
					for ($i = 1; $i <= $StringMatches; $i++) {				
						//$row['Message'] = preg_replace("/(\[quote=)(.*?)(\])(.*?)(\[\/quote\])/ie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBorder'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\" color=\"'.\$Colors['MBQCText'].'\"><b>Quote ('.stripslashes(\$DisplayNames[\\2]).')</b><br><br>'.stripslashes('\\4').'</font></td></tr></table></td></tr></table>'", stripslashes($row['Message']));
						$row['Message'] = preg_replace("/(\[quote=)([0-9]*?)(\])(.*?)(\[\/quote\])/ie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBorder'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\" color=\"'.\$Colors['MBQCText'].'\"><b>Quote ('.stripslashes(\$DisplayNames[\\2]).')</b><br><br>'.stripslashes('\\4').'</font></td></tr></table></td></tr></table>'", stripslashes($row['Message']));
					}
					// quotes without a user
					$StringMatches = substr_count($row['Message'],'[quote]');
					for ($i = 1; $i <= $StringMatches; $i++) {				
						$row['Message'] = preg_replace("/(\[quote\])(.*?)(\[\/quote\])/ie", "'<img src=\"'.\$TemplateImagesURL.'/admin/spacer.gif\" border=\"0\" width=\"1\" height=\"10\" alt=\"\"><br><table width=\"90%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBorder'].'\"><table width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\"><tr><td bgcolor=\"'.\$Colors['MBQCBG'].'\"><font face=\"'.\$FontFace.'\" size=\"'.\$FontSize.'\" color=\"'.\$Colors['MBQCText'].'\"><b>Quote</b><br><br>'.stripslashes('\\2').'</font></td></tr></table></td></tr></table>'", $row['Message']);
					}
				
				
				} // end if [quote exists in the message
				
				
				
				// smilies				
				//$row['Message'] = str_replace($SmiliesSearchArray, $SmiliesReplaceArray, $row['Message']);
				
				
				
				
				
				
				// end of pattern matching
		
		
		
			$PreviousMessages .= '<table width="80%" border="0" cellspacing="0" cellpadding="1"><tr><td bgcolor="'.$Colors['MBText'].'"><table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td bgcolor="'.$Colors['MBBG'].'"><font face="'.$FontFace.'" size="'.$FontSize.'" color="'.$Colors['MBText'].'"><b>'.$MsgText[2][68].': '.$DisplayNames[$row['Poster']].'&nbsp;&nbsp;-&nbsp;&nbsp;'.$PostTime.'</b><br><br>'.$row['Message'].'</font></td></tr></table></td></tr></table><br>';
		
		}
		
		if ($PreviousMessages != '') {
			$PreviousMessages = '<br><br><b>'.$MsgText[2][69].':</b><br><br>'.$PreviousMessages;
		}
		
		
		
		
		
		$MessageEditContents = stripslashes(str_replace('<','&l'.'t;',$FormArguments['Message']));
		$MessageEditContents = str_replace('&nb'.'sp;', '&#'.'38;nbsp;', $MessageEditContents);
		
		
		
		
		$query = "select * from `".$Settings['DBPrefix']."mb-Threads` where RecordNumber=".$FormArguments['ThreadID']." limit 1";
		$result = mysql_query($query) or die (mysql_error());
		$row = mysql_fetch_array($result);
		
		$MessagesCount = ($row['Replies'] + 1);
		$ThreadTitle = $row['Title'];
		$BoardID = $row['BoardID'];
		$ViewsCount = $row['Views'];
		$RepliesCount = $row['Replies'];
	
	
		$query = "select Title,Category,Description from `".$Settings['DBPrefix']."mb-Boards` where RecordNumber=".$FormArguments['BoardID']." limit 1";
		$result = mysql_query($query) or die (mysql_error());
		$row = mysql_fetch_array($result);
		
		$BoardTitle = $row['Title'];
		$BoardDescription = $row['Description'];
		$CategoryID = $row['Category'];
		
		
		
		$query = "select Title,Description from `".$Settings['DBPrefix']."mb-Categories` where RecordNumber=".$CategoryID." limit 1";
		$result = mysql_query($query) or die (mysql_error());
		$row = mysql_fetch_array($result);
		
		$CategoryTitle = $row['Title'];
		//$CategoryDescription = $row['Description'];
		
		
			
		
		$PageTitle = '<div align="'.$AlignmentCodes[$mbSettings['TitleAlignment']].'">'.$mbSettings['PageTitle'].'</div>';
		$BrowserTitle = $mbSettings['PageTitle'] . ' - '.$MsgText[2][59];
		$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL.'/forum.html">'.$mbSettings['PageTitle'].'</a> > <a href="'.$MainURL.'/forum.html#'.$CategoryID.'">'.$CategoryTitle.'</a> > <a href="'.$MainURL.'/forum/'.$FormArguments['BoardID'].'.html">'.$BoardTitle.'</a> > <a href="'.$MainURL.'/forum/'.$FormArguments['BoardID'].'/'.$FormArguments['ThreadID'].'.html">'.$ThreadTitle.'</a> > '.$MsgText[2][59];
		
		



		$PageContents = '<b>'.$MsgText[2][105].':</b><br><table width="80%" border="0" cellspacing="0" cellpadding="1"><tr><td bgcolor="'.$Colors['MBText'].'"><table width="100%" border="0" cellpadding="5" cellspacing="0"><tr><td bgcolor="'.$Colors['MBBG'].'"><font face="'.$FontFace.'" size="'.$FontSize.'" color="'.$Colors['MBText'].'">'.$MessagePreviewPrint.'&nbsp;</font></td></tr></table></td></tr></table><br><br><script>
		
var BrowserName = navigator.appName;
var BrowserVersion = navigator.appVersion;


function storeCaret(text) { 
	if (text.createTextRange) {
		text.caretPos = document.selection.createRange().duplicate();
	}
}

var TagOpen = ""; var TagClose = "";
var TagCode = ""; // tag code sent from page when inserting code
var InsertMode = "c"; // insert mode (c = combined, s = separate), set later by drop-down box on page

var TagOpen = new Array; // array of opening tags
var TagClose = new Array; // array of closing tags (for tags without a closing tag, this needs to be blank)
var TagCaret = new Array; // array or tag caret, or simply put, which tag to insert next if in \'separate mode\'


TagOpen[\'b\'] = "[b]";
TagClose[\'b\'] = "[/b]";
TagCaret[\'b\'] = 0;

TagOpen[\'i\'] = "[i]";
TagClose[\'i\'] = "[/i]";
TagCaret[\'i\'] = 0;

TagOpen[\'u\'] = "[u]";
TagClose[\'u\'] = "[/u]";
TagCaret[\'u\'] = 0;

TagOpen[\'url\'] = "[url]";
TagClose[\'url\'] = "[/url]";
TagCaret[\'url\'] = 0;

TagOpen[\'url_text\'] = "[url=http://]";
TagClose[\'url_text\'] = "[/url]";
TagCaret[\'url_text\'] = 0;

TagOpen[\'email\'] = "[email]";
TagClose[\'email\'] = "[/email]";
TagCaret[\'email\'] = 0;

TagOpen[\'img\'] = "[img]";
TagClose[\'img\'] = "[/img]";
TagCaret[\'img\'] = 0;

TagOpen[\'code\'] = "[code]";
TagClose[\'code\'] = "[/code]";
TagCaret[\'code\'] = 0;

TagOpen[\'quote\'] = "[quote]";
TagClose[\'quote\'] = "[/quote]";
TagCaret[\'quote\'] = 0;

TagOpen[\'left\'] = "[left]";
TagClose[\'left\'] = "[/left]";
TagCaret[\'left\'] = 0;

TagOpen[\'center\'] = "[center]";
TagClose[\'center\'] = "[/center]";
TagCaret[\'center\'] = 0;

TagOpen[\'right\'] = "[right]";
TagClose[\'right\'] = "[/right]";
TagCaret[\'right\'] = 0;

TagOpen[\'hr\'] = "[hr]";
TagClose[\'hr\'] = "";
TagCaret[\'hr\'] = 0;


// special set
TagOpen[\'color\'] = ""; // set by function
TagClose[\'color\'] = "[/color]";
TagCaret[\'color\'] = 0;
function InsertColor(ColorCode) {
	TagOpen[\'color\'] = "[color=" + ColorCode + "]";
	InsertCode(\'color\');
}

// special set
TagOpen[\'smile\'] = ""; // set by function
TagClose[\'smile\'] = "";
TagCaret[\'smile\'] = 0;
function InsertSmiles(SmileCode) {
	TagOpen[\'smile\'] = \' \'+SmileCode;
	InsertCode(\'smile\');
}


// special set
TagOpen[\'font\'] = ""; // set by function
TagClose[\'font\'] = "[/font]";
TagCaret[\'font\'] = 0;
function InsertFontFace() {
	TagOpen[\'font\'] = \'[font=\'+document.forms[\'PostForm\'].elements[\'FontFace\'].value+\']\';
	InsertCode(\'font\');
}

// special set
TagOpen[\'size\'] = ""; // set by function
TagClose[\'size\'] = "[/size]";
TagCaret[\'size\'] = 0;
function InsertFontSize() {
	TagOpen[\'size\'] = \'[size=\'+document.forms[\'PostForm\'].elements[\'FontSize\'].value+\']\';
	InsertCode(\'size\');
}


function InsertCode(TagCode) {
	//alert(TagCode);
	if (InsertMode == "c") { // if working in combined tags mode
		if (document.PostForm.Message.createTextRange && document.PostForm.Message.caretPos) {    
			// text range successfully created; add the tags around or after the selected text  
			var caretPos = document.PostForm.Message.caretPos;      
			caretPos.text = TagOpen[TagCode] + caretPos.text + TagClose[TagCode];
			document.PostForm.Message.focus(caretPos);
		}
		else if (document.getElementById(\'Message\').selectionEnd > document.getElementById(\'Message\').selectionStart) {
			var RangeStart = document.getElementById(\'Message\').selectionStart;
			var RangeEnd = document.getElementById(\'Message\').selectionEnd;
												
			document.PostForm.Message.value = document.PostForm.Message.value.substring(0,RangeStart)+TagOpen[TagCode]+document.getElementById(\'Message\').value.substring(RangeStart,RangeEnd)+TagClose[TagCode]+document.PostForm.Message.value.substring(RangeEnd);
			
			var caretPos = document.PostForm.Message.caretPos;
			document.PostForm.Message.focus(caretPos);
		}
		else {		
			// text range could not be created; add the tag to the end of the message
			document.PostForm.Message.value +=  TagOpen[TagCode] + TagClose[TagCode];
			
			var caretPos = document.PostForm.Message.caretPos;
			document.PostForm.Message.focus(caretPos);
		}
	}
	else if (InsertMode == "s") { // if working in separate tags mode
		var TagToInsert = "";
		if (TagCaret[TagCode] == 0) {
				TagToInsert = TagOpen[TagCode];
				if (TagClose[TagCode] != "") {
					// if there\'s an end tag, insert it next time
					TagCaret[TagCode] = 1;
				}
			}
			else {
				TagToInsert = TagClose[TagCode];
				TagCaret[TagCode] = 0;
			}
		
		if (document.PostForm.Message.createTextRange && document.PostForm.Message.caretPos) {  
			// text range successfully created; add the tags around or after the selected text      
			var caretPos = document.PostForm.Message.caretPos;      
			caretPos.text = caretPos.text + TagToInsert;
		}
		else {
			// text range could not be created; add the tag to the end of the message
			document.PostForm.Message.value += TagToInsert;
		}
		
		document.PostForm.Message.focus(caretPos); // update the message text with that from the modified range
	}
}


function ImagePrompt() {
	if (document.PostForm.Message.createTextRange && document.PostForm.Message.caretPos && document.PostForm.Message.caretPos.text != "") {    
		// text range successfully created; add the tags around or after the selected text  
		var caretPos = document.PostForm.Message.caretPos;      
		caretPos.text = "[img]" + caretPos.text + "[/img]";		
	}
	else if (document.getElementById(\'Message\').value.substring(document.getElementById(\'Message\').selectionStart, document.getElementById(\'Message\').selectionEnd) && BrowserVersion.indexOf("MSIE") == -1) {
		var RangeStart = document.getElementById(\'Message\').selectionStart;
		var RangeEnd = document.getElementById(\'Message\').selectionEnd;
					
		document.PostForm.Message.value = document.PostForm.Message.value.substring(0,RangeStart)+"[img]"+document.getElementById(\'Message\').value.substring(RangeStart,RangeEnd)+"[/img]"+document.PostForm.Message.value.substring(RangeEnd);
	}
	else {
		// text range could not be created
		
		var ImageURL = prompt("Enter URL Of Image To Insert:","http://");
		if (ImageURL != "" && ImageURL != null) {
			document.PostForm.Message.value += "[img]"+ImageURL+"[/img]";
		}
	}
}

function EmailPrompt() {
	if (document.PostForm.Message.createTextRange && document.PostForm.Message.caretPos && document.PostForm.Message.caretPos.text != "") {    
		// text range successfully created; add the tags around or after the selected text  
		var caretPos = document.PostForm.Message.caretPos;      
		caretPos.text = "[email]" + caretPos.text + "[/email]";		
	}
	else if (document.getElementById(\'Message\').value.substring(document.getElementById(\'Message\').selectionStart, document.getElementById(\'Message\').selectionEnd) && BrowserVersion.indexOf("MSIE") == -1) {
		var RangeStart = document.getElementById(\'Message\').selectionStart;
		var RangeEnd = document.getElementById(\'Message\').selectionEnd;
					
		document.PostForm.Message.value = document.PostForm.Message.value.substring(0,RangeStart)+"[email]"+document.getElementById(\'Message\').value.substring(RangeStart,RangeEnd)+"[/email]"+document.PostForm.Message.value.substring(RangeEnd);
	}
	else {
		// text range could not be created
		
		var Email = prompt("Enter Address To Insert:","");
		if (Email != "" && Email != null) {
			document.PostForm.Message.value += "[email]"+Email+"[/email]";
		}
	}
}

function URLPrompt1() {
	if (document.PostForm.Message.createTextRange && document.PostForm.Message.caretPos && document.PostForm.Message.caretPos.text != "") {    
		// text range successfully created; add the tags around or after the selected text  
		var caretPos = document.PostForm.Message.caretPos;      
		caretPos.text = "[url]" + caretPos.text + "[/url]";		
	}
	else if (document.getElementById(\'Message\').value.substring(document.getElementById(\'Message\').selectionStart, document.getElementById(\'Message\').selectionEnd) && BrowserVersion.indexOf("MSIE") == -1) {
		var RangeStart = document.getElementById(\'Message\').selectionStart;
		var RangeEnd = document.getElementById(\'Message\').selectionEnd;
					
		document.PostForm.Message.value = document.PostForm.Message.value.substring(0,RangeStart)+"[url]"+document.getElementById(\'Message\').value.substring(RangeStart,RangeEnd)+"[/url]"+document.PostForm.Message.value.substring(RangeEnd);
	}
	else {
		// text range could not be created
		
		var InsertURL = prompt("Enter URL To Insert:","http://");
		if (InsertURL != "" && InsertURL != null) {
			document.PostForm.Message.value += "[url]"+InsertURL+"[/url]";
		}
	}
}

function URLPrompt2() {
	if (document.PostForm.Message.createTextRange && document.PostForm.Message.caretPos && document.PostForm.Message.caretPos.text != "") {    
		// text range successfully created; add the tags around or after the selected text  
		var InsertURL = prompt("Enter URL To Insert:","http://");
		if (InsertURL != "" && InsertURL != null) {
			var caretPos = document.PostForm.Message.caretPos;      
			caretPos.text = "[url="+InsertURL+"]" + caretPos.text + "[/url]";			
		}
	}
	else if (document.getElementById(\'Message\').value.substring(document.getElementById(\'Message\').selectionStart, document.getElementById(\'Message\').selectionEnd) && BrowserVersion.indexOf("MSIE") == -1) {
		var RangeStart = document.getElementById(\'Message\').selectionStart;
		var RangeEnd = document.getElementById(\'Message\').selectionEnd;
		
		var InsertURL = prompt("Enter URL To Insert:","http://");
		if (InsertURL != "" && InsertURL != null) {			
			document.PostForm.Message.value = document.PostForm.Message.value.substring(0,RangeStart)+"[url="+InsertURL+"]"+document.getElementById(\'Message\').value.substring(RangeStart,RangeEnd)+"[/url]"+document.PostForm.Message.value.substring(RangeEnd);
		}
	}
	else {
		// text range could not be created
		
		var InsertURL = prompt("Enter URL To Insert:","http://");
		if (InsertURL != "" && InsertURL != null) {
			
			var LinkText = prompt("Enter Title For Clickable Link","");
			if (LinkText != "" && LinkText != null) {
				document.PostForm.Message.value += "[url="+InsertURL+"]"+LinkText+"[/url]";
			}
			else {
				document.PostForm.Message.value += "[url]"+InsertURL+"[/url]";
			}
		}
	}
}


</script>


<script>

function ShowMessagePreview() {

	document.forms["PostForm"].elements["ShowPreview"].value = "yes";
	
	document.forms["PostForm"].elements["submit"].click();

}

function ValidateForm() {

	if (document.forms["PostForm"].elements["Message"].value == "") {
		alert("'.$MsgText[2][70].'");
		return false;
	}
	else {
		document.forms["PostForm"].elements["submit"].disabled = true;
		document.forms["PostForm"].elements["preview"].disabled = true;
		
		return true;
	}

}

</script>

		
		<form name="PostForm" action="'.$MainURL.'/forum/message-post" method="post" onSubmit="return ValidateForm();">
		
		<input type="hidden" name="BoardID" value="'.$FormArguments['BoardID'].'">
		<input type="hidden" name="ThreadID" value="'.$FormArguments['ThreadID'].'">
		
		<input type="hidden" name="ShowPreview" value="">
		
		'.$MsgText[2][71].':<br><input type="text" name="Subject" size="40" style="'.$FormStyle.'" value="'.stripslashes(str_replace('"','&#'.'34;',$FormArguments['Subject'])).'">
		
		<br><br>
		
		'.$MsgText[2][72].':<br><textarea name="Message" id="Message" cols="40" rows="8" wrap="virtual" style="width: 500px; height: 200px; '.$FormStyle.'" onSelect="javascript:storeCaret(this);" onClick="javascript:storeCaret(this);" onKeyUp="javascript:storeCaret(this);" onChange="javascript:storeCaret(this);">'.$MessageEditContents.'</textarea>
		
		<br>
				
<br><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="2" alt=""><br>


<table border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td>

<table border="0" cellpadding="1" cellspacing="1" width="100%">
    <tr>
      <td>
	  
	  <table width="20" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:InsertCode(\'b\');" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">&nbsp;<b>B</b>&nbsp;</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>
	  
	  <table width="20" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:InsertCode(\'i\');" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">&nbsp;<i>i</i>&nbsp;</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>
	  
	  <table width="20" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:InsertCode(\'u\');" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">&nbsp;<u>u</u>&nbsp;</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>&nbsp;</td>
	  
	  <td>
	  
	  <table width="20" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:InsertCode(\'hr\');"><img src="'.$ImagesURL.'/admin/fbc_hr.gif" border="0" width="18" height="16" alt="Horizontal Rule"></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>

	  </td>
	  
	  <td>&nbsp;</td>
	  
      <td>
	  
	  <table border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="1" cellspacing="0"><tr><td>

<img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="3" height="1" alt=""><select name="FontFace" style="font-size:12px;">
	<option value="Arial"> Arial</option>
	<option value="Comic Sans MS"> Comic Sans MS</option>
	<option value="Courier New"> Courier New</option>
	<option value="Helvetica"> Helvetica</option>
	<option value="Georgia"> Georgia</option>
	<option value="Impact"> Impact</option>
	<option value="Times New Roman"> Times New Roman</option>
	<option value="Verdana"> Verdana</option>
</select><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="3" height="1" alt=""><input type="button" value="Go" onClick="InsertFontFace();" style="font-size:12px;"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="3" height="1" alt="">


</td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>	    
	  
	  </td>
	  
	  <td align="right">
	  
	  <table border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="1" cellspacing="0"><tr><td>

<img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="3" height="1" alt=""><select name="FontSize" style="font-size:12px;">
	<option value="1"> 1</option>
	<option value="2" selected> 2</option>
	<option value="3"> 3</option>
	<option value="4"> 4</option>
	<option value="5"> 5</option>
	<option value="6"> 6</option>
</select><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="3" height="1" alt=""><input type="button" value="Go" onClick="InsertFontSize();" style="font-size:12px;"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="3" height="1" alt="">

</td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>	    
	  
	  </td>
	  
    </tr>
</table>

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

<table border="0" cellpadding="1" cellspacing="1" width="100%">
    <tr>
      <td>
	  
	  <table width="1" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:ImagePrompt();" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">Image</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>&nbsp;</td>
      <td>
	  
	  <table width="1" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:URLPrompt1();" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">URL</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>
	  
	  <table border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:URLPrompt2();" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">URL&nbsp;w/&nbsp;Contents</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>&nbsp;</td>
      <td>
	  
	  <table width="1" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:EmailPrompt();" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">Email</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>&nbsp;</td>
      <td>
	  
	  <table width="1" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:InsertCode(\'code\');" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">Code</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>&nbsp;</td>
      <td width="20">
	  
	  <table width="1" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0" width="100%"><tr><td><a href="javascript:InsertCode(\'quote\');" style="text-decoration:none;"><font face="Arial" color="#000000" size="2">Quote</font></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table></td>
  
	  
    </tr>
</table>

		
		<img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="2" alt=""><br>
		
<table border="0" cellpadding="1" cellspacing="1" width="100%">
    <tr>
      <td>	
		<table width="1" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
    </tr>
    <tr>
      <td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content -->
		
		<table border="0" cellspacing="0" cellpadding="3"><tr><td bgcolor="#e6e6e6">
<table border="0" cellspacing="1" cellpadding="0" bgcolor="#222222" border="0"><tr>
<td bgcolor="#000000"><A HREF="javascript:InsertColor(\'black\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Black"></A></td>
<td bgcolor="#ffffff"><A HREF="javascript:InsertColor(\'white\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="White"></A></td>
<td bgcolor="#ff0000"><A HREF="javascript:InsertColor(\'red\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Red"></A></td>
<td bgcolor="#ffff00"><A HREF="javascript:InsertColor(\'yellow\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Yellow"></A></td>
<td bgcolor="#008000"><A HREF="javascript:InsertColor(\'green\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Green"></A></td>
<td bgcolor="#888888"><A HREF="javascript:InsertColor(\'grey\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Grey"></A></td>
<td bgcolor="#990000"><A HREF="javascript:InsertColor(\'burgundy\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Burgundy"></A></td>
<td bgcolor="#ff9900"><A HREF="javascript:InsertColor(\'orange\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Orange"></A></td>
<td bgcolor="#9900ff"><A HREF="javascript:InsertColor(\'purple\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Purple"></A></td>
<td bgcolor="#ffffcc"><A HREF="javascript:InsertColor(\'cream\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Cream"></A></td>
<td bgcolor="#008080"><A HREF="javascript:InsertColor(\'teal\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Teal"></A></td>
<td bgcolor="#ffcccc"><A HREF="javascript:InsertColor(\'salmon\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Salmon"></A></td>
<td bgcolor="#0000ff"><A HREF="javascript:InsertColor(\'blue\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Blue"></A></td>
<td bgcolor="#ff33cc"><A HREF="javascript:InsertColor(\'pink\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Pink"></A></td>
<td bgcolor="#003399"><A HREF="javascript:InsertColor(\'navy\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Navy"></A></td>
<td bgcolor="#33ccff"><A HREF="javascript:InsertColor(\'lightblue\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Light Blue"></A></td>
<td bgcolor="#666699"><A HREF="javascript:InsertColor(\'mauve\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Mauve"></A></td>
<td bgcolor="#00ff00"><A HREF="javascript:InsertColor(\'limegreen\')"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="12" height="12" alt="Lime Green"></A></td>
</tr></table> 
</td></tr></table>

</td>
      <td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
    </tr>
    <tr>
      <td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
    </tr>
</table>
</td>
<td>&nbsp;</td>
      <td>
	  
	  <table width="1" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:InsertCode(\'left\');"><img src="'.$ImagesURL.'/admin/fbc_left.gif" border="0" width="18" height="16" alt="Left"></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>
	  
	  <table width="1" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:InsertCode(\'center\');"><img src="'.$ImagesURL.'/admin/fbc_center.gif" border="0" width="18" height="16" alt="Center"></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
      <td>
	  
	  <table width="1" border="0" cellpadding="0" cellspacing="0"><tr><td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content --><table border="0" cellpadding="2" cellspacing="0"><tr><td><a href="javascript:InsertCode(\'right\');"><img src="'.$ImagesURL.'/admin/fbc_right.gif" border="0" width="18" height="16" alt="Right"></a></td></tr></table></td><td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr><tr><td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td><td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td></tr></table>
	  
	  </td>
</tr>
</table>
<img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="2" alt=""><br>
<table border="0" cellpadding="1" cellspacing="1" width="100%">
    <tr>
      <td width="100%">
	  <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
      <td width="1" height="1" bgcolor="#f2f2f2"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="100%" height="1" bgcolor="#f1f1f1"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="1" height="1" bgcolor="#e8e8e8"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
    </tr>
    <tr>
      <td width="1" height="100%" bgcolor="#ebebeb"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="100%" height="100%" bgcolor="#e6e6e6"><!-- content -->'.$SmiliesBlock.'</td>
      <td width="1" height="100%" bgcolor="#929292"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
    </tr>
    <tr>
      <td width="1" height="1" bgcolor="#b4b4b4"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="100%" height="1" bgcolor="#616161"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
      <td width="1" height="1" bgcolor="#5b5b5b"><img src="'.$TemplateImagesURL.'/admin/spacer.gif" border="0" width="1" height="1" alt=""></td>
    </tr>
</table>


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


		<br><br><br>
			
			<input type="submit" name="submit" value="'.$MsgText[2][73].'" style="'.$FormStyle.'">&nbsp;&nbsp;&nbsp;<input type="button" name="preview" value="'.$MsgText[2][74].'" style="'.$FormStyle.'" onClick="ShowMessagePreview();">
							
			</form></td></tr></table>'.$PreviousMessages;
	
	
	
	
?>
