<form method="post" id ="test" action="index.php?Page=Newsletters&Action=%%GLOBAL_Action%%" onsubmit="return CheckForm()">
	<table cellspacing="0" cellpadding="0" width="100%" align="center">
		<tr>
			<td class="Heading1">
				%%GLOBAL_Heading%%
			</td>
		</tr>
		<tr>
			<td class="body pageinfo">
				<p>
					%%GLOBAL_Intro%%
				</p>
				%%GLOBAL_Message%%
			</td>
		</tr>
		<tr>
			<td>
				<input class="FormButton" type="submit" value="%%LNG_Next%%">
				<input class="FormButton" type="button" value="%%LNG_Cancel%%" onClick='if(confirm("%%GLOBAL_CancelButton%%")) { document.location="index.php?Page=Newsletters" }'>
				<br />
				&nbsp;
				<table border="0" cellspacing="0" cellpadding="2" width="100%" class="Panel">
					<tr>
						<td colspan="3" class="Heading2">
							&nbsp;&nbsp;%%GLOBAL_NewsletterDetails%%
						</td>
					</tr>
					<tr>
						<td width="200" class="FieldLabel">
							{template="Required"}
							%%LNG_NewsletterName%%:
						</td>
						<td>
							<input type="text" name="Name" class="Field250" value="%%GLOBAL_Name%%">&nbsp;%%LNG_HLP_NewsletterName%%
						</td>
						<td rowspan="4" valign="top" style="display:none" id="preview">
							<div class="DisplayTemplateList" id="DisplayTemplateList" style="display: block; width: 255px; text-align: center;">
								<div><a href="javascript:void(0);" onclick="javascript:ShowPreview();"><img id="imgPreview" src="images/nopreview.gif" width="247" height="200" style="border: 1px solid black" onerror="this.src=images/nopreview.gif"></a></div>
								<div style="padding-top: 10px;"><a href="#" onclick="javascript: ShowPreview(); return false;"><img src="images/magnify.gif" border="0" style="padding-right:5px">%%LNG_Preview_Template%%</a></div>
							</div>
						</td> 
					</tr>
					<tr>
						<td width="200" class="FieldLabel">
							{template="Required"}
							%%LNG_NewsletterFormat%%:
						</td>
						<td>
							<select name="Format" id="Format">
								%%GLOBAL_FormatList%%
							</select>
							&nbsp;
							%%LNG_HLP_NewsletterFormat%%
						</td>
						
					</tr>
					<tr>
						<td width="200" class="FieldLabel">						 
							{template="Not_Required"}
							Editor :
								</td>
						</td>
						<td>
								<select name="usewysiwyg" id="usewysiwyg" onchange="ShowTemplate(this.value);">					
											%%GLOBAL_EditorList%% 
								   </select>
						</td>
						
					</tr>
					 <tr class="DisplayTemplateList" id="editorTemplate"  style="display: %%GLOBAL_DisplayTemplateList%%" >
						   
					</tr>
				</table>
				<table width="100%" cellspacing="0" cellpadding="2" border="0" class="PanelPlain">
					<tr>
						<td width="200" class="FieldLabel"></td>
						<td>
							<input class="FormButton" type="submit" value="%%LNG_Next%%" />
							<input class="FormButton" type="button" value="%%LNG_Cancel%%" onClick='if (confirm("%%GLOBAL_CancelButton%%")) { document.location="index.php?Page=Newsletters" }' />
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
	
</form>
 
   
<script>
//function for show templates
 ShowTemplate(%%GLOBAL_editor%%);
function ShowTemplate(editor) { 
  
		    // document.getElementById("preview").style.display = "";
			$.ajax({
			type: "GET",
			url: "index.php?Page=newsletters&Action=getEditor&editor="+editor,
			success: function(data) {
				if(editor == 1){
					document.getElementById("preview").style.display = "%%GLOBAL_DisplayPreview%%";
					document.getElementById("DisplayTemplateList").style.display = "";
					document.getElementById("editorTemplate").innerHTML=data;
				}
				if(editor == 2){
					document.getElementById("preview").style.display = "%%GLOBAL_DisplayPreview%%";
					document.getElementById("DisplayTemplateList").style.display = "";
					document.getElementById("editorTemplate").innerHTML=data;
				}
				if(editor == 3){
					document.getElementById("preview").style.display = "none";
					document.getElementById("editorTemplate").innerHTML=data;
				}
				if(editor == 4){
					document.getElementById("preview").style.display = "none";
					document.getElementById("editorTemplate").innerHTML='';
				}
				if(editor == 0){
					document.getElementById("preview").style.display = "none";
					document.getElementById("editorTemplate").innerHTML=data;
				}
			}
		});	 
	 
	}
	function CheckForm() {
		var f = document.forms[0];
		if (f.Name.value == '') {
			alert("%%LNG_EnterNewsletterName%%");
			f.Name.focus();
			return false;
		}
	}

	$('#Format').change(function() {
		// Hide the template preview if a text campaign was selected
		if($(this).val() == 't') {
			$('.DisplayTemplateList').hide();
		}
		else {
			$('.DisplayTemplateList').show();
		}
	});
 function ShowPreview() {
		Template = document.getElementById('TemplateID');
		selectedTemplate = Template.selectedIndex;
		if (selectedTemplate == -1 || selectedTemplate == 0) {
			alert('%%LNG_SelectTemplate%%');
			document.getElementById('TemplateID').focus();
			return false;
		}
		selectedTemplateID = Template.options[Template.selectedIndex].value;
		url = 'index.php?Page=Templates&Action=View&check=1&id=' + selectedTemplateID;
		window.open(url);
	}
 
	function SetValue(value) {
		document.getElementById('TemplateID').value = '';
		document.getElementById('TemplateID').value =value;
		//alert('You selectd this template and click on next button');
		document.getElementById("test").submit(); 
	}
   
</script>
