<?

/*
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 of message
	// ========================================================================================
	
	
			
				if ($FormArguments['PageType'] == 2) {
					$FormArguments['PageContents'] = $FormArguments['PageContents2'];
				}
				
				$FormArguments['Message'] = $FormArguments['PageContents'];
			
			
				$StrippedTitle = stripslashes($FormArguments['Title']);
				$StrippedMessage = stripslashes($FormArguments['Message']);
				
				$FormatSelected[$FormArguments['MailFormat']] = ' checked';
				
				$PageTypeSelected[$FormArguments['PageType']] = ' selected';
				
				
				if ($FormArguments['MailFormat'] == 'html') {
					$FormatPrint = 'HTML';
					
					$MessagePreview = $StrippedMessage;
				}
				else {
					$FormatPrint = $MsgText[5][18];
					
					$MessagePreview = $StrippedMessage;
					$MessagePreview = str_replace('<','&lt;',$MessagePreview);
					$MessagePreview = str_replace("\n",'<br>',$MessagePreview);
				}
			
				
				
				$FormArguments['PageContents'] = stripslashes($FormArguments['PageContents']);
			
				$FormArguments['PageContents'] = preg_replace("/\&([\#\d\w]{1,5})\;/i", "&amp;\\1;", $FormArguments['PageContents']);
				$FormArguments['PageContents'] = str_replace('<!--', '&lt;!--', $FormArguments['PageContents']);
				$FormArguments['PageContents'] = str_replace('</', '&lt;/', $FormArguments['PageContents']);
			
			
						
				$PageContents = '
				<script>
								
				function ShowMessagePreview() {
					document.forms["NewsletterCompose"].elements["ShowPreview"].value = "yes";
					document.forms["NewsletterCompose"].elements["submit"].click();
				}
				function ValidateForm() {

					if (FCKeditorAPI.GetInstance("PageContents").GetXHTML() == "") {
						alert("'.$MsgText[5][22].'");
						return false;
					}
					if (document.forms["NewsletterCompose"].elements["Title"].value == "") {
						alert("'.$MsgText[5][23].'");
						return false;
					}
					
					document.forms["NewsletterCompose"].elements["submit"].disabled = true;
					document.forms["NewsletterCompose"].elements["preview"].disabled = true;
				
					return true;
				
				}
				
				</script>
				
				
				<br><b>'.$MsgText[5][24].':</b><br>'.$MsgText[5][25].'<br><br><div align="center"><table width="90%" border="0" cellpadding="1" cellspacing="0"><tr><td bgcolor="'.$Colors['Text'].'"><table width="100%" border="0" cellpadding="10" cellspacing="0"><tr><td bgcolor="'.$Colors['BG'].'"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[5][17].': </b>'.$FormatPrint.'<br><br><b>'.$MsgText[5][15].': </b>'.$StrippedTitle.'</td></tr><tr><td bgcolor="'.$Colors['BG'].'"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[5][16].':</b><br>'.$MessagePreview.'</td></tr></table></td></tr></table></div><br><br><br><b>'.$MsgText[5][26].':</b><br><form name="NewsletterCompose" action="'.$MainURL.'/admin/newsletter_send" method="post">
<input type="hidden" name="ShowPreview" value="">
<b>'.$MsgText[5][15].':</b><br><input type="text" name="Title" size="65" value="'.str_replace('"','&#34;',$StrippedTitle).'">
<br><br>
<b>'.$MsgText[5][16].':</b><br>
<script>
var EditorStarted = false;

var BaseURL = "'.$BaseURL.'";

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

			oFCKeditor.BasePath = "'.$BaseURL.'/fckeditor/" ;

			oFCKeditor.Height	= 500 ;
			
			oFCKeditor.Config["BaseURL"] = "'.$BaseURL.'";
			
			//oFCKeditor.Create() ;
			oFCKeditor.ReplaceTextarea();
			
			EditorStarted = true;
		}
	
		document.getElementById("EditorDiv").style.display = "";
		document.getElementById("NonEditorDiv").style.display = "none";
	}
	else if (PageType == 2) {
		document.getElementById("EditorDiv").style.display = "none";
		document.getElementById("NonEditorDiv").style.display = "";
	}
}
</script>

<select name="PageType" id="PageType" size="1" onChange="UpdatePageType();">
<option value="1"'.$PageTypeSelected[1].'> Rich Text / HTML Editor</option>
<option value="2"'.$PageTypeSelected[2].'> Plain Text / HTML Without Editor</option>
</select><br>

<br>


<div id="EditorDiv"><textarea id="PageContents" name="PageContents" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual">'.$FormArguments['PageContents'].'</textarea></div><div id="NonEditorDiv" style="display: none;"><textarea id="PageContents2" name="PageContents2" cols="65" rows="8" style="width: 100%; height: 500px;" wrap="virtual">'.$FormArguments['PageContents'].'</textarea></div>

<br><br>
<b>'.$MsgText[5][17].':</b> <input type="radio" name="MailFormat" value="html"'.$FormatSelected['html'].'> HTML &nbsp;<input type="radio" name="MailFormat" value="text"'.$FormatSelected['text'].'> '.$MsgText[5][18].'<br>
<br><br>
<script>var FlexCMSScriptName="'.$Settings['ScriptName'].'";</script><script type="text/javascript" src="'.$BaseURL.'/fckeditor/fckeditor.js"></script><script>UpdatePageType();</script>
<input type="submit" name="submit" value="'.$MsgText[5][19].'">&nbsp;&nbsp;&nbsp;<input type="button" name="preview" value="'.$MsgText[5][20].'" onClick="ShowMessagePreview();">
</form>';


				


?>
