<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC >
<html style="overflow:hidden;">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<title translate="yes" data-res="EML.TITLE"></title>
	
	<!--MqRelPath--><link rel="stylesheet" type="text/css" href="../../theme/css/censusmain.css" ><!--/MqRelPath--><!--MqAbsPath><link rel="stylesheet" type="text/css" href="<BASE_VD>/theme/css/censusmain.css" ></MqAbsPath-->
	<script type="text/javascript" src="../../js/jquery/jquery-1.11.1.min.js"></script>	
	<!--MqRelPath--><script type="text/javascript" src="../../js/mqsysutils.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/mqsysutils.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/cmqsysmsg.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/cmqsysmsg.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/mqformelements.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/mqformelements.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/xml.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/xml.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/mqrecordset.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/mqrecordset.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/mqviewfields.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/mqviewfields.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/mqloaddata.js"></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/mqloaddata.js"></script></MqAbsPath-->
	<!--MqRelPath--><script type="text/javascript" src="../../js/window.js" ></script><!--/MqRelPath--><!--MqAbsPath><script type="text/javascript" src="<BASE_VD>/js/window.js" ></script></MqAbsPath-->
	<script type="text/javascript" src="tmplemailcontenteditor.js" ></script>
	<script type="text/javascript" src="js/cmqlookupitemint.js" ></script>
	<script type="text/javascript" src="cmqescalationint.js" ></script>
	<script type="text/javascript" src="js/initlookupitemint.js" ></script>
	<script type="text/javascript" src="../HTMLEditor/ckeditor.js"></script>
	
	<script type="text/javascript">
	<!--
		var m_objMqButton=new MqButton();
		var m_strCurrentLocation=g_MqRef.MqFS.GetCurrentLocation(window);
		var m_objHTTPRequest;
		var m_objEmailEditor;
		var m_strDefaultFromAddress="EML.DEFAULT_FROM" ;
		var m_objFields=new CMqFieldCol();
		var m_strCurrentCtrlID;
		var m_lngAllowInvalidAddresses=0;
		var m_strUploadPath="<WC@UPLOAD_PATH></WC@UPLOAD_PATH>";
		var m_strMailAttachID="<WC@MAIL_ATTACH_ID></WC@MAIL_ATTACH_ID>";
		var m_objFormElement=new CMqFormElement();
		var m_lngMode=g_MqRef.MqStr.GetQueryStringValue(location.search,"Mode");
		var m_blnLoadAbort = false;
		var CKEditor_loaded = false;
		
		if(m_lngMode==""){
			m_lngMode=6149;
		}
		
		var INVALID_TMPL_ID=-1;
		var BODY_FORMAT_TYPE_HTML="1";
		var BODY_FORMAT_TYPE_TEXT="0";
		var FLD_FORMAT_CONTROL_NAME = "chkHTMLBody";
		var FLD_BODY_CONTROL_NAME = "txtMailBody";
		var FLD_SUBJECT_ID="4";
		var FLD_BODY_ID="5";
		var FLD_HTML_BODY_ID="6";
		var FLD_ATTACH_ID="7";
		
		var MODE_HIDE_TEMPLATES_TAB=1;
		var MODE_HIDE_MACROS_TAB=2;
		var MODE_HIDE_TMPL_NAME_FIELD=4;
		var MODE_HIDE_TO_FIELD=8;
		var MODE_HIDE_CC_FIELD=16;
		var MODE_HIDE_FROM_FIELD=32;
		var MODE_HIDE_SUBJECT_FIELD=64;
		var MODE_HIDE_ATTACH_FIELD=128;
		var MODE_HIDE_BODY_FIELD=256;
		var MODE_HIDE_INDIV_RECIP_CHK=512;
		var MODE_HIDE_HTML_BODY_CHK=1024;
		var MODE_HIDE_SEND_EMAIL_BUTTON=2048;
		var MODE_HIDE_SAVE_TMPL_BUTTON=4096;
		var MODE_HIDE_SAVE_EMAIL_BUTTON=8192;
		var MODE_HIDE_SAVE_CONVQUEUE_ROW=16384;
		var MODE_HIDE_SAVE_QUEUE_CHK = 32768;
		var MODE_HIDE_SAVE_CONV_CHK = 65536;
		var MODE_HIDE_SAVE_CONVQUEUE_CHK = 131072;
		var MODE_HIDE_LINK_ATTACHMENT = 262144;
		
		var MACRO_TYPE_ISSUE=1;
		var QS_MACRO_TYPE="Macro";
				
		var m_blnHasFeatureManageTmpl=<WC@SECURED_FEATURE_102></WC@SECURED_FEATURE_102>;
		var m_blnHasFeatureUseTmpl=<WC@SECURED_FEATURE_103></WC@SECURED_FEATURE_103>;
		var m_blnHasFeatureFromEnabled=<WC@SECURED_FEATURE_121></WC@SECURED_FEATURE_121>;

		var m_objRef;
		if(opener){
				try{
					//IE6-IE7
					if(opener.name){//test that the opener has at least a valid property
						m_objRef=opener;
					}
				}catch(e){
					m_blnLoadAbort = true;
					window.close();
				}
		}else{
			m_blnLoadAbort = true;
			window.close();
		}
		
		if(m_objRef){
			if(m_objRef.parent){
				if(m_objRef.parent.mstrCurrentVDName){
					if (g_MqRef.RESX){
						// Load the localization file within the view
						g_MqRef.ResMgr.LoadViewRes("/" + m_objRef.parent.mstrCurrentVDName + "/" + m_objRef.parent.mstrCurrentViewFolder);
					}
				}
			}
		}

		var MSG_ENTER_TO_ADDRESS =g_MqRef.RESX["EML.MSG_ENTER_TO_ADDRESS"];
		var MSG_ENTER_FROM_ADDRESS = g_MqRef.RESX["EML.MSG_ENTER_FROM_ADDRESS"];
		var MSG_ENTER_TEMPLATE_NAME = g_MqRef.RESX["EML.MSG_ENTER_TEMPLATE_NAME"];
		var MSG_EMPTY_VAL = g_MqRef.RESX["EMPTY_FLD_MACRO_VAL"];
		var MSG_CONFIRM_CLEAR=g_MqRef.RESX["EML.MSG_CONFIRM_CLEAR"];
		var MSG_HTML_EDITOR_MODE_CONFLICT_MACRO = g_MqRef.RESX["EML.MSG_HTML_EDITOR_MODE_CONFLICT_MACRO"];
		var MSG_HTML_EDITOR_MODE_CONFLICT_TEMPLATE = g_MqRef.RESX["EML.MSG_HTML_EDITOR_MODE_CONFLICT_TEMPLATE"];
		var MSG_NAVIGATE_AWAY = g_MqRef.RESX["EML.MSG_NAVIGATE_AWAY"];
		
		var NO_MACROS="<br /><center>" + g_MqRef.RESX["EML.NO_MACROS"] + "</center>";
		
		var CONTENT_DELIM=";";
		
		var m_strXMLMailContentFields="<WC@EMAILCONTENTFIELDS></WC@EMAILCONTENTFIELDS>";
		
		var m_blnHTMLEditorCreated=false;
		
		var m_strMailContentValues="";
		var m_arrMailContentValues;
		var m_objHiddenSrcFld;
		var m_objVisibleSrcFld;
		var m_objHiddenUploadPath;
		var m_objHiddenUploadID;
		
		if(!m_blnLoadAbort){
			if(m_objRef){
				m_objHiddenSrcFld=m_objRef.document.getElementById("<WC@HIDDEN_EMAIL_SRC_FLD_NAME></WC@HIDDEN_EMAIL_SRC_FLD_NAME>");

				m_objVisibleSrcFld=m_objRef.document.getElementById("<WC@VISIBLE_EMAIL_SRC_FLD_NAME></WC@VISIBLE_EMAIL_SRC_FLD_NAME>");

				m_objHiddenUploadID=m_objRef.document.getElementById("<WC@HIDDEN_EMAIL_UPLOAD_ID_FLD_NAME></WC@HIDDEN_EMAIL_UPLOAD_ID_FLD_NAME>");
				
				if(m_objHiddenSrcFld){
						m_strMailContentValues=m_objHiddenSrcFld.value;
				}
				
			}
		}	
		
		var m_arrAvailableMacros=new Array();
		<WC@AVAILABLEFIELDMACROS>"m_arrAvailableMacros[%1]=new Array(%2);"</WC@AVAILABLEFIELDMACROS>
		
		var SEARCH_FIELD_CAPTION_NAME =g_MqRef.RESX["EMLQUEUE.CAPTION_NAME"];
		var SEARCH_FIELD_CAPTION_EMAIL = g_MqRef.RESX["EMLQUEUE.CAPTION_EMAIL"];
		
		var SEARCH_FIELD_NAME_ID = 0;
		var SEARCH_FIELD_EMAIL_ID = 1;
		
		var m_objLookupItemInfoColl=new Array();
		//var m_objAttachmentsInfo=new CMqAttachmentsInfo();
		
		CKEDITOR.on('instanceReady', function(){ CKEditor_loaded = true;resizeEditor();});
		
		function resizeEditor()
		{
			var DLG_PADDING = 77; //bottom buttons, top text, rounded box around contents
			var newHeight;
			var mailBody = document.getElementById(FLD_BODY_CONTROL_NAME);
			var objTDMailBody = document.getElementById("tdMailBody");
			var objMainContentsDiv = document.getElementById('tdMainContents');
			
			if (mailBody) {
				if (objTDMailBody) {
					if (objMainContentsDiv) {
						var mainContentsHeight = objMainContentsDiv.offsetHeight;
						if (mainContentsHeight) {
							newHeight = mainContentsHeight-DLG_PADDING-objTDMailBody.offsetTop;

							if (newHeight) {
								if (CKEditor_loaded) {
									CKEDITOR.instances[FLD_BODY_CONTROL_NAME].resize('100%', newHeight);
								}
								if(newHeight > 0){
									mailBody.style.height = newHeight + "px";
								}
								
							}
						}
					}
				}
			}
		}
	//-->
	</script>
	<script src="../../JS/Escalation/InitLookupItemInt.js" type="text/javascript"></script>	
</head>
<body id="EmailContentEditor" class="RecordBody" style="margin:0;padding:8px;padding-top:12px;" 
	onbeforeunload="return WindowClosing()" onload="Form_OnLoad();resizeEditor();" onunload="OnBeforeNavigate()" onresize="resizeEditor();">	
	<div id="divLoading" class="NormalText" style="display: none;font-size: 10pt;z-index: 10;text-align: center;position: absolute" translate="yes" data-res="LOADING_PLEASE_WAIT"></div>
	<script type="text/javascript">
	var objDivLoading = document.getElementById("divLoading");
	
	if(objDivLoading){
		objDivLoading.style.top = ((GetWinHeight()/2)-20) + "px";
		objDivLoading.style.left = ((GetWinWidth()/2)-85) + "px";
		objDivLoading.style.display = "";
	}
	</script>
	<form name="frmEmailContentEditor">

					<div style="wi-dth:100%;l-eft:1%;margin-right:210px" id="tdMainContents" class="EmailEditorDiv">
							<table id="tblContents" width="100%" height="100%" cellpadding="0" cellspacing="0" border="0" sty-le="table-layout: fixed">
							<!-- Contents -->
								<tr id="trMailTmplName" style="display: none">
									<td width="10%" class="DialogLabel" style="padding-left:15px; padding-right:5px;text-align: left;"
									translate="yes" data-res="EMAIL.TEMPLATE_NAME"></td>
									<td width="85%" align="left">
										<input type="text" class="TextBox" style="width: 97%" onchange="DataChanged()" name="txtMailTemplateName" 
										id="txtMailTemplateName" MqFieldID="9" MqInsertFunc="Insert1ToMValue" onfocus="LoadAvailableMacros(this.id); StoreCursor(this);" 
										onselect="StoreCursor(this);" onclick="StoreCursor(this);" onkeyup="StoreCursor(this);">
									</td>
									<td width="5%">&#160;</td>
								</tr>
								<tr id="trMailTo" style='display: none'>
									<td width="10%" class="DialogLabel" style="padding-left:15px; padding-right:5px;text-align: left;" translate="yes" data-res="EMAIL.TO"></td>
									<td width="85%" align="left">
										<input type="text" class="TextBox" style="width: 97%" onchange="DataChanged()" name="txtMailTo" id="txtMailTo" 
										MqFieldID="1" MqInsertFunc="Insert1ToMValue" onfocus="LoadAvailableMacros(this.id); StoreCursor(this);" onselect="StoreCursor(this);" 
										onclick="StoreCursor(this);" onkeyup="StoreCursor(this);">
									</td>
									<td width="5%" style="padding-right:10px; padding-top:1px" >
										<script type="text/javascript">
											<!--
											m_objMqButton.WriteButtonHTML("Users","ShowNameList('1');","Users",false,m_objMqButton.STATE_1,g_MqRef.RESX["EML.SELECT_RECIPIENTS"]);
											//-->
										</script>
									</td>
								</tr>
								<tr id="trMailCc" style="display: none">	
									<td width="10%" class="DialogLabel" style="padding-left:15px; padding-right:5px;text-align: left;" translate="yes" data-res="EMAIL.CC"></td>
									<td width="85%" align="left">
										<input type="text" class="TextBox" style="width: 97%" onchange="DataChanged();HandleSendIndiv()" name="txtMailCC" 
										id="txtMailCC" MqFieldID="2" MqInsertFunc="Insert1ToMValue" onfocus="LoadAvailableMacros(this.id); StoreCursor(this);" 
										onselect="StoreCursor(this);" onclick="StoreCursor(this);" onkeyup="StoreCursor(this);">
									</td>
									<td width="5%" style="padding-right:10px; padding-top:1px">
										<script type="text/javascript">
											<!--
											m_objMqButton.WriteButtonHTML("Users","ShowNameList('2');","Users",false,m_objMqButton.STATE_1,g_MqRef.RESX["EML.SELECT_RECIPIENTS"]);
											//-->
										</script>	
									</td>
								</tr>
								
								<tr id="trMailBCc" style="display: none">	
									<td width="10%" class="DialogLabel" style="padding-left:15px; padding-right:5px;text-align: left;" translate="yes" data-res="EMAIL.BCC"></td>
									<td width="85%" align="left">
										<input type="text" class="TextBox" style="width: 97%" onchange="DataChanged();HandleSendIndiv()" name="txtMailBCC" 
										id="txtMailBCC" MqFieldID="12" MqInsertFunc="Insert1ToMValue" onfocus="LoadAvailableMacros(this.id); StoreCursor(this);" 
										onselect="StoreCursor(this);" onclick="StoreCursor(this);" onkeyup="StoreCursor(this);">
									</td>
									<td width="5%" style="padding-right:10px; padding-top:1px">
										<script type="text/javascript">
											<!--
											m_objMqButton.WriteButtonHTML("Users","ShowNameList('12');","Users",false,m_objMqButton.STATE_1,g_MqRef.RESX["EML.SELECT_RECIPIENTS"]);
											//-->
										</script>	
									</td>
								</tr>

								<tr id="trMailFrom" style="display: none">
									<td width="10%" class="DialogLabel" style="padding-left:15px; padding-right:5px;text-align: left;" translate="yes" data-res="EMAIL.FROM"></td>
									<td width="85%" align="left">
										<input type="text"  class="TextBox" style="width: 97%" onchange="DataChanged()" name="txtMailFrom" id="txtMailFrom" 
										maxlength="255" MqFieldID="3" MqInsertFunc="Insert1To1Value" onfocus="LoadAvailableMacros(this.id); StoreCursor(this);" 
										onselect="StoreCursor(this);" onclick="StoreCursor(this);" onkeyup="StoreCursor(this);">
									</td>
									<td width="5%" style="padding-right:10px; padding-top:1px">
										<script type="text/javascript">
											<!--
											m_objMqButton.WriteButtonHTML("Users","ShowNameList('3');","Users",false,m_objMqButton.STATE_1,g_MqRef.RESX["EMAIL.FROM"]);
											//-->
										</script>
									</td>
								</tr>
							
								<tr id="trMailSubject" style="display: none">
									<td width="10%" class="DialogLabel" style="padding-left:15px; padding-right:5px;text-align: left;" translate="yes" data-res="EMAIL.SUBJECT"></td>
									<td width="85%" align="left">
										<input type="text"  class="TextBox" style="width: 97%" onchange="DataChanged()" name="txtMailSubject" id="txtMailSubject" 
										maxlength="255" MqFieldID="4" MqInsertFunc="InsertAtCursor" onfocus="LoadAvailableMacros(this.id); StoreCursor(this);" 
										onselect="StoreCursor(this);" onclick="StoreCursor(this);" onkeyup="StoreCursor(this);">
									</td>
									<td width="5%">&#160;</td>
								</tr>
								
								<tr id="trMailAttach" style="display: none">
									<td width="10%" class="DialogLabel" style="padding-left:15px; padding-right:5px;text-align: left;" translate="yes" data-res="EMAIL.ATTACH"></td>
									<td width="85%" align="left">
										<input type="text"  class="TextBox" style="width: 97%" onchange="DataChanged()" name="txtMailAttach" id="txtMailAttach" 
										MqFieldID="7" MqInsertFunc="Insert1ToMValue" onfocus="LoadAvailableMacros(this.id); StoreCursor(this);" onselect="StoreCursor(this);" 
										onclick="StoreCursor(this);" onkeyup="StoreCursor(this);" >
									</td>
									<td width="5%" style="padding-right:10px; padding-top:1px">
										<script type="text/javascript">
											<!--
								m_objMqButton.WriteButtonHTML("Attach","ShowAttachmentsDlg(document.frmEmailContentEditor.txtMailAttach);","Attach",false,m_objMqButton.STATE_1,g_MqRef.RESX["ATT.ATTACH_FILE"]);
											//-->
										</script>	
									</td>
								</tr>
								
								<tr id="trMailBody" style="display: none">
									<td colspan="2" id="tdMailBody" width="100%" height="58%" valign="top" style="padding-top:10px; padding-left:15px;" align="left">
										<div id="mailWrapper" style="position:relative;height:100%;">
											<div id="MailBodyWrapper" name="MailBodyWrapper" style="display:none;width:97%;height:100%;">
												<textarea wrap="physical" class="TextBox" style="width: 100%;resize:none;" rows="18" name="txtMailBody" id="txtMailBody" 
												MqFieldID="5" MqInsertFunc="InsertAtCursor" onfocus="LoadAvailableMacros(this.id); StoreCursor(this);" 
												onselect="StoreCursor(this);" onclick="StoreCursor(this);" onkeyup="StoreCursor(this);DataChanged()"></textarea>
											</div>
										</div>
									</td>
								</tr>
								<tr style="padding-bottom:2px">
									<td colspan="2" width="100%" style="padding-left:15px;height:30px;vertical-align:bottom;">
									<table width="100%"><tr>
									<td width="70%" class="DialogLabel" align="left" style="padding-right:2px;" id="tdMailIndivRecip" style="display:none">
										<input type="checkbox" onchange="DataChanged()" name="chkSendIndiv" id="chkSendIndiv" MqFieldID="8" onfocus="LoadAvailableMacros(this.id)"
										 onclick="HandleSendIndiv()" style="display: none">
											<span id="spnSendIndvLbl" style="display: none" translate="yes" data-res="EMAIL.SEND_INDIV"></span>
									</td>
									<td width="30%" class="DialogLabel" align="right" style="padding-right:2px;display:none" id="tdMailHTMLBody">
										<input type="checkbox" onchange="DataChanged()" name="chkHTMLBody" id="chkHTMLBody" MqFieldID="6" 
										onfocus="LoadAvailableMacros(this.id)" onclick="BodyFormat_OnChange();resizeEditor();">
										<span translate="yes" data-res="EMAIL.HTML_BODY"></span>
									</td>
									</tr>
										<tr id="trSaveConvQueue" style="padding-bottom:2px;display: none">
										<td colspan="2" width="100%" class="DialogLabel" align="left" style="padding-right:2px;" id="tdSaveConvQueue">
											<input type="checkbox" onchange="DataChanged()" checked="checked" name="chkSaveConvQueue" id="chkSaveConvQueue" 
											MqFieldID="8" onfocus="LoadAvailableMacros(this.id)" style="display: none;">
											<span id="spnSaveConvQueueCombo" style="display: none;" translate="yes" data-res="EML.SAVE_TO_CONVER_QUEUE">Save to Conversation/Queue</span>
											<span id="spnSaveConv" style="display: none;" translate="yes" data-res="EML.SAVE_TO_CONVER">Save to Conversation</span>
											<span id="spnSaveQueue" style="display: none;" translate="yes" data-res="EML.SAVE_TO_QUEUE">Save to Queue</span>
										</td>
									</tr>
									</table>
									</td>
								</tr>								
							</table>
					</div>
					<div class="EmailSideBarDiv DialogLabel" style="width:200px; right:2px;top:5" id="tdSidebar">
					<iframe id="fraEmailTabs" name="fraEmailTabs" src="tmplEmailTabContainer.htm" width="100%" height="100%" frameborder="0"></iframe>
					</div>
					<table align="right" style="position:absolute;bottom:0; right:1%;margin-top:8px;">
						<tr>
							<td  width="50%" align="right" id="tdBtnSendEmail" style="display:none">
							       <script type="text/javascript">
							        <!--
					        		m_objMqButton.WriteTextButtonHTML("Send", g_MqRef.RESX["EMAIL.SEND"], "SendEmail();", "", 32, "", g_MqRef.RESX["EMAIL.SEND"], 90);
							        //-->
							       </script>
							</td>
							<td  width="50%" align="right" id="tdBtnSaveTmpl" style="display:none">
								<script type="text/javascript">
									<!--
									m_objMqButton.WriteTextButtonHTML("OK", g_MqRef.RESX["BUTTON_OK"], "SaveTemplate();", "", 32, "", g_MqRef.RESX["BUTTON_OK"], 90);
									//-->
								</script>
							</td>
							<td  width="50%" align="right" id="tdBtnSaveEmail" style="display:none">
								<script type="text/javascript">
									<!--
									m_objMqButton.WriteTextButtonHTML("OK", g_MqRef.RESX["BUTTON_OK"], "Save();", "", 32, "", g_MqRef.RESX["BUTTON_OK"], 90);
									//-->
								</script>
							</td>
							<td width="50%" align="right" id="tdBtnCancel" style="display:none">
								<script type="text/javascript">
									<!--
									m_objMqButton.WriteTextButtonHTML("Cancel", g_MqRef.RESX["BUTTON_CANCEL"], "CancelEmail();", "", 32, "", g_MqRef.RESX["BUTTON_CANCEL"], 90);
									//-->
								</script>				
							</td>
						</tr>
					</table>
	</form>
	<input type="hidden" name="txtUploadDir" id="txtUploadDir" value="">
	<input type="hidden" name="txtUploadPath" id="txtUploadPath" value="">
</body>
</html>
