<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html class="RecordBody">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   	<link rel="stylesheet" type="text/css" href="../../../Theme/css/CensusMain.css"/>
   	<link rel="stylesheet" type="text/css" href="../../../Theme/css/MqWizard.css"/>
   	<script  src="../../../Js/CMqSysMsg.js" type="text/javascript" ></script>
    <script  src="../../../Js/window.js" type="text/javascript"></script>
    <script  src="../../../Js/MqFormElements.js" type="text/javascript"></script>
    <script  src="../../../Js/MqList.js" type="text/javascript"></script>
    <script  src="../../../Js/MqSysUtils.js" type="text/javascript"></script>
    <script  src="../../../Js/MqViewFields.js" type="text/javascript"></script>
    <script  src="../../../Js/MqRecordset.js" type="text/javascript"></script>
    <script  src="../../../Js/MqLoadData.js" type="text/javascript"></script>
    <script  src="../../../Js/xml.js" type="text/javascript"></script>
    
    <title></title>

    <script type="text/javascript">
		var cenSetFieldValueAction = 1;
		var cenSendMailAction=2;
		var cenExternalCommandAction=3;
		var cenSendMailReportAction = 4;  // Shouldn't it just be SendMailAction?
		var cenCreateNewIssueAction = 5;
		var cenLinkToIssueAction = 6;
		var cenDeleteEmailAction = 7;
		var cenUpdateIssueAction = 8;
		
		var m_blnClose = false;//if true, the user decided to close the window(and potentially lose unsaved changes)
		var m_blnSaving = false; //if true, the confirmation prompt won't appear.
		var blnDefault = null;
		var blnContactValue = null;
		var m_blnSaveDefaults = false;
		var m_blnSaveMappings = false;
		var blnCheckbox = true;
		var m_strCurrentCondition = "";
		var m_lngInitialActionSelected;
		var INVALID_PROJ_ID = -1;
		var MSG_SMTP = "4";
		var MSG_MACRO = "3";
		var MSG_ACTION = "2";
		var MSG_EMAIL = "1";
		var MSG_STATE_VISIBLE = 1;
		var MSG_STATE_HIDDEN = 0;
		var m_blnContentIsValid = 0;
		var DELIM = ";";
	<!--
		// always define this object for the system messages
		var objSysMsg = new CMqSysMsg;	
		var m_MqList=new MqList();
		var m_objString=new MqString();
		var m_objViewFields= new CMqFieldCol();
		var m_objLoadDataMgr;
		var m_oFieldValuesRs;
		var m_blnOriginalContactState;
		var m_objFormElement=new CMqFormElement();
		var m_strCurrentLocation=g_MqRef.MqFS.GetCurrentLocation(window);
		var MSG_RULE_REQUIRES_NAME = "You must enter a Rule Name.";
		var m_strCurrentLocation = g_MqRef.MqFS.GetCurrentLocation(window);
		var strCommandLine = parent.location.search;
		var m_objRef;
		var m_blnDataChanged = false;
		var m_blnSaving = false;
		
		if(opener){
			if(opener.opener){
				if(opener.opener.parent){
					m_objRef=opener.opener.parent;
				}
			}
		}
		
		var DISABLED_ESC_RULE_TEXT="(Disabled)";
		var MSG_NAVIGATE_AWAY = "Any unsaved changes will be lost.";
		var DELIM_REGULAR = "*|*";
		var DELIM_ROW = "$|$";

		var m_strEscRuleDataXML="<WC@ESC_RULE_DATA_XML></WC@ESC_RULE_DATA_XML>";
		var m_strEscRuleFields="<WC@ESC_RULE_FIELDS></WC@ESC_RULE_FIELDS>";

		var m_lngAddRule=parseInt(GetRuleID());

		var m_strSelectedRowID="";
		
		//if adding more condition or action rows to the UI, change these numbers
		var MAX_COND_ROWS=7;
		var MAX_ACTION_ROWS=7;
		
	function SetDefaultCheckbox(blnDefaultValue)
	{
		blnDefault = blnDefaultValue;
	}
	
	function GetDefaultCheckbox()
	{
		return blnDefault;
	}
	
    function HandleConditionValueOptions()
    {
    	var objRSHelper = new CMqRSHelper();
		var lngCount;
		var objChk;
		var objTU;
		var objValCbo;
		var lngRowID;
		
		for(lngCount=0; lngCount<MAX_COND_ROWS; lngCount++){
			lngRowID = lngCount+1;
			
			objChk=document.getElementById("CR" + lngRowID + "_En");
		
			if(objChk){
				if(objChk.checked){
					objTU=document.getElementById("CR" + lngRowID + "_P4");
					if(!objTU){
						objValCbo=document.getElementById("CR" + lngRowID + "_P3");
						if(objValCbo){
							LoadListForField("CR" + lngRowID + "_P1", objValCbo)
							m_objLoadDataMgr.SetSingleValueToFields(objRSHelper.GetFieldValue(parseInt(lngRowID + "4"),m_oFieldValuesRs), Array(lngRowID + "4"),false,true);
						}
					}
				}
			}
		}			
    }
    
	function GetRuleID()
	{
			var lngIntegrationID=m_objString.GetQueryStringValue(strCommandLine,"IID");
			var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
			
			if(lngRuleID == 0) 
			{
				lngRuleID = m_lngAddRule; 
			}
			
					var co = m_objRef.m_objHTTPrequest.Get(m_strCurrentLocation + "WCMailInt.ASP?WCI=wciEnsureRuleExists&Proj=" + m_objRef.GetProjectID() +
																									"&RID=" + lngRuleID +"&IID=" + lngIntegrationID, true);
							if (co!=m_objRef.m_objHTTPrequest.CANCEL_PROCESS){
								var objResponse=m_objRef.m_objHTTPrequest.Response(co);
									
									if (objResponse){
										if (objResponse.HasErrors()){
											objResponse.ProcessErrors("",true,window);
										}else{
											return co;
										}
									}
							}
	}
	
	function HasLinkToIssueChecked()
	{	
		var lngReturn = 0;
		var objFormElement = new CMqFormElement();
		var objChk = document.getElementById("AR3_En");
		var objCreateChk = document.getElementById("AR1_En");
		var objCondition = document.getElementById("CR7_En");
		var objControl = document.getElementById("CR7_P1");
		
		
		if(objCreateChk.checked){
			lngReturn = 1;
		}else if(objChk.checked){
			if(objCondition.checked){
				lngReturn = 1;
			}else{
				objCondition.checked = true;
				objFormElement.Initialize(objControl, CTRL_TYPE_MQLIST,null,m_MqAutoList);
				objFormElement.SetValue("Subject or Body",false,objControl,CTRL_TYPE_MQLIST,false,true);
				lngReturn = 0;
			}
		}else{
			lngReturn = 1;
		}
		
		return lngReturn;
	}
	
	function ShowValidateEmailWindow()
	{
		var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
		var lngProjectID=m_objRef.GetProjectID();
		var lngEmail = lngAction = lngMacro = lngSMTP = MSG_STATE_HIDDEN;
		var objCondition = document.getElementById("CR7_En");
		var objCreateChk = document.getElementById("AR1_En");
		
		if(HasLinkToIssueChecked() == 0){
			lngAction = MSG_STATE_VISIBLE;
		}
		
		if(!objCondition.checked && !objCreateChk.checked){
			if(ValidateRule() == true){
				lngMacro = MSG_STATE_VISIBLE;
			}
		}
		
		if(lngRuleID == 0) 
		{
			lngRuleID = m_lngAddRule; 
		}
		
		if(lngSMTP == 1 || lngEmail == 1 || lngMacro == 1 || lngAction == 1){
			if(lngProjectID != INVALID_PROJ_ID){
				OpenChildWindow("WCMailInt.asp?WCI=wciValidateFromEmail" +
																						"&" + MSG_EMAIL + "=" + lngEmail +
																						"&" + MSG_ACTION + "=" + lngAction +
																						"&" + MSG_MACRO  + "=" + lngMacro +
																						"&" + MSG_SMTP + "=" + lngSMTP +
																						"&Proj=" + lngProjectID + "&IID=" + lngRuleID,"ValidateEmail","scrollbars=yes,resizable=yes", true, 600,500, 0);
				return 1;
			}
		}else{
			return 0;
		}
	}

		function ValidateRule()
		{
			var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
			var lngProjectID= m_objRef.GetProjectID();
			var lngIntegrationID=m_objString.GetQueryStringValue(strCommandLine,"IID");
			var objFormElement = new CMqFormElement();
			var objControl = document.getElementById("CR7_P1");
			var blnReturn;
			
			if(lngRuleID == 0) 
			{
				lngRuleID = m_lngAddRule; 
			}
		
								
							var co=m_objRef.m_objHTTPrequest.Get(m_strCurrentLocation + "WCMailInt.ASP?WCI=wciValidateRule&IID=" + lngIntegrationID + "&RID=" + lngRuleID + "&Proj=" + lngProjectID, true);
											if (co!=m_objRef.m_objHTTPrequest.CANCEL_PROCESS){
													
													var objResponse=m_objRef.m_objHTTPrequest.Response(co);
														
														if (objResponse){
															if (objResponse.HasErrors()){
																objResponse.ProcessErrors("",true,window);
															}else{
																if(co == "0"){
																	blnReturn = false;
																}else{
																	blnReturn = true;
																	var objCondition = document.getElementById("CR7_En");
																	objCondition.checked = true;
																	objFormElement.Initialize(objControl, CTRL_TYPE_MQLIST,null,m_MqAutoList);
																	objFormElement.SetValue("Subject or Body",false,objControl,CTRL_TYPE_MQLIST,false,true);
																}
																return blnReturn;
															 }
														 }
											}
		}

	function SaveRule()
    {
		var lngRow;
		for (lngRow=1;lngRow<=5;lngRow++){
			SetCurrentCondition("CR" + lngRow + "_P2");
			EvaluateTxtStates(true);
		}
		
		var strQueryString = m_objLoadDataMgr.GetDataForSave();
		var strRuleName="";
		var lngIntegrationID=m_objString.GetQueryStringValue(strCommandLine,"IID");
		var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
		var strDefaults = GetGridValues();
		var strMappings = GetGridMappings();
		var lngDefault = 0; //works with blnDefault (Default of defaults)
		var lngContactValue = 0;
		var lngSaveDefaults;
		var lngSaveMappings;
		var blnNewRule = false;
		m_blnSaving = true; //this will ensure the confirm alert doesn't appear when attempting to save.
		if(lngRuleID == 0) 
		{
			lngRuleID = m_lngAddRule; 
			blnNewRule = true;
		}
		
		if(blnDefault){
			lngDefault = 1;
		}
		
		if(blnContactValue){
			lngContactValue = 1;
		}
							
        if(m_objRef){
			var objRuleName=document.getElementById("txtRuleName");
			var lngResult = 1;
			if(objRuleName){
				strRuleName=objRuleName.value;
			}
							
			if(strRuleName.length==0){
				alert(MSG_RULE_REQUIRES_NAME);
			}else{
				m_blnSaving = true;
						
				if(m_blnContentIsValid == 0){
					lngResult = ShowValidateEmailWindow();
				}else{
					lngResult = 0;
				}
				if(lngResult == 0){
					if(m_blnSaveDefaults){
						lngSaveDefaults = 1;
					}else{
						lngSaveDefaults = 0;
					}
						
					if(m_blnSaveMappings){
						lngSaveMappings = 1;
					}else{
						lngSaveMappings = 0;
					}

					var co=m_objRef.m_objHTTPrequest.Post(m_strCurrentLocation + 
						"WCMailInt.ASP?WCI=wciSaveRule", "Proj=" + m_objRef.GetProjectID() + 
						"&Name=" + g_MqRef.MqStr.MqEncodeURIComponent(strRuleName) +
						"&RID=" + lngRuleID + "&IID=" + lngIntegrationID +
						"&Data=" + g_MqRef.MqStr.MqEncodeURIComponent(strQueryString) +
						"&MCondR=" + MAX_COND_ROWS + "&MActR=" + MAX_ACTION_ROWS + "&Defaults=" + strDefaults +
						"&Def=" + lngDefault + "&Con=" + lngContactValue + "&Bln=" + lngSaveDefaults +
						"&Mappings=" + strMappings + "&SaveMappings=" + lngSaveMappings, true);
											
					if (co!=m_objRef.m_objHTTPrequest.CANCEL_PROCESS){
																				
						var objResponse=m_objRef.m_objHTTPrequest.Response(co);
						if (objResponse){
							if (objResponse.HasErrors()){
								objResponse.ProcessErrors("",true,window);
							}else{
								if(opener){
									opener.UpdateRowCount();
									if(blnNewRule){
										opener.m_lngRowCount = opener.m_lngRowCount+1;
										opener.m_lngRowToSelect=(opener.m_lngRowCount-1);
									}else{
										opener.m_lngRowToSelect=(parseInt(opener.m_lngSelectedRowID));
									}
									opener.Initialize();
									opener.Refresh();
									window.close();
									opener.focus();

								}
							}
						}
					}
				}
			}
		}        
	}
	function SetGridValues(strGridVals)
	{
		var objGridValues = document.getElementById("txtGridValues");
		objGridValues.value = strGridVals;
	}
	
	function GetGridValues()
	{
		var objGridValues = document.getElementById("txtGridValues");
		return objGridValues.value;
	}
	
	function SetChangedValues(strChangedVals)
	{
		var objChangedValues = document.getElementById("txtChangedValues");
		objChangedValues.value = strChangedVals;
	}
	
	function GetChangedValues()
	{
		var objChangedValues = document.getElementById("txtChangedValues");
		return objChangedValues.value;
	}
    
    function SetGridMappings(strGridMappings)
	{
		var objGridMappings = document.getElementById("txtGridMappings");
		objGridMappings.value = strGridMappings;
	}
	
	function GetGridMappings()
	{
		var objGridMappings = document.getElementById("txtGridMappings");
		return objGridMappings.value;
	}
	
	function SetChangedMappings(strChangedMappings)
	{
		var objChangedMappings = document.getElementById("txtChangedMappings");
		objChangedMappings.value = strChangedMappings;
	}
	
	function GetChangedMappings()
	{
		var objChangedMappings = document.getElementById("txtChangedMappings");
		return objChangedMappings.value;
	}
	
    function SelectRow(tdSelected)
    {

        var objTable=document.getElementById("tblConditions");
        
        UnSelectTableRows(objTable);
    		        
        
        objTable=document.getElementById("tblActions");
        UnSelectTableRows(objTable);
        
        m_strSelectedRowID = tdSelected.id;
        
        SelectCell (tdSelected);       
    }
    
    function UnSelectTableRows(objTable)
    {
        if (objTable){
    		var oRows=objTable.rows;			
    		
    		if (oRows){
    			var intColumn=0;
    				
    			for (j=0; j < oRows.length; j++) {
    				objRow=oRows.item(j);	
    
    			    UnselectCell(objRow.cells.item(intColumn));
    			}
       		}	
    	} 
    }
    function UnselectCell(tdCell)
    {
        tdCell.style.backgroundColor='';
        tdCell.style.borderColor='#F7F9FF';
    }
    
    function SelectCell(tdCell)
    {
        tdCell.style.backgroundColor='#d6dbe7';
        tdCell.style.borderColor='#336699';
    }

    
      function OpenEmailContentEditor(lngRowID)
    {
		var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
		var objHdnTxt = document.getElementById("txtHiddenEmailSrc_" + lngRowID);
		var objHdnMailIDTxt = document.getElementById("txtHiddenMailID_" + lngRowID);
		var lngMailID=0;
		
		if(lngRuleID == 0) 
		{
			lngRuleID = m_lngAddRule; 
		}

		if(objHdnTxt.value.length <= 1 ){
			objHdnTxt.value = "1="+g_MqRef.MqStr.PropStringEncode("<Reply To Sender>") + 
								"&2=" + g_MqRef.MqStr.PropStringEncode("<Reply To CC>") + 
								"&3=" + g_MqRef.MqStr.PropStringEncode("<Integration E-mail>") + "&";
		}
		
		if(objHdnMailIDTxt){
			lngMailID=objHdnMailIDTxt.value;
		}
		
		OpenChildWindow("../../../HTML/EmailEditor/WCMqEmailEditor.ASP?WCI=wciEmailContentEditor&Proj=" + m_objRef.GetProjectID() + 
							"&EscID=" + lngRuleID + "&Lvl=3&Mode=366597&Type=1&Macro=7&Row=" + lngRowID + "&MID=" + lngMailID, "EmailContent", "toolbar=no,directories=no,resizable=yes,scrollbars=yes,width=800,height=600", true, 800, 600);
	}

    function LoadListForField(strFieldCbo, objValCbo)
    {
		var objFieldCbo=document.getElementById(strFieldCbo);
		var objFormElem=new CMqFormElement();
		
		if(objFieldCbo){
			if(objValCbo){
				var strFieldCboVal=objFormElem.GetValue(false, objFieldCbo, CTRL_TYPE_MQLIST);
				var strFieldValSrc=strFieldCboVal + "_List";
				objValCbo.setAttribute("mqlist", strFieldValSrc);
			}
		}
    }
    
    function EnsureCurrentRowIsEnabled()
    {
		var objChk=document.getElementById(m_strSelectedRowID + "_En");
		
		if(objChk){
			if(!objChk.checked){
				objChk.checked=true;
			
				if(objChk.onclick){
					objChk.onclick();
				}
			}
		}
    }
    
	function GetCurrentRowCheckboxState()
	{
		var objChk=document.getElementById(m_strSelectedRowID + "_En");
		if(objChk){
			return objChk.checked;
		}
	}
	
	function KeyPressed(e)
	{
		if(!e){
			e = window.event;
		}
		if(typeof(e.keyCode)== 'number'){
				if(e.keyCode == 13){
					SaveRule();
				}else if(e.keyCode == 27){
					window.close();
				}
		}
	}

	function OpenNewIssueWindow()
	{
		var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
		var lngIntegrationID=m_objString.GetQueryStringValue(strCommandLine,"IID");
		var strChanged = GetGridValues();
		
		if(lngRuleID == 0) 
		{
			lngRuleID = m_lngAddRule; 
		}
		
		OpenChildWindow("WCMailInt.ASP?WCI=wciEditDefaults&Proj=" + m_objRef.GetProjectID() + 
							"&RID=" + lngRuleID + "&IID=" + lngIntegrationID + "&Ac=1",  "EditDefaults", "toolbar=no,directories=no,resizable=yes,scrollbars=yes", true, 700, 600);
	}
	
	function EditUpdateMapping()
	{
		var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
		var lngProjectID= m_objRef.GetProjectID();
		var lngIntegrationID=m_objString.GetQueryStringValue(strCommandLine,"IID");
		
		if(lngIntegrationID==0)
		{
			lngIntegrationID = m_lngAddIntegration;
		}
		
		OpenChildWindow("WCMailInt.asp?wci=wciEditMapping&IID="+ lngIntegrationID + "&Proj=" + m_objRef.GetProjectID() + "&RID=" + lngRuleID + "&Delim=" + 
									DELIM + "&Ac=3","EditUpdateMapping","scrollbars=yes,resizable=yes", true, 700, 600, 0);
	}
	
	function EditUpdateDefaults()
	{
		var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
		var lngProjectID= m_objRef.GetProjectID();
		var lngIntegrationID=m_objString.GetQueryStringValue(strCommandLine,"IID");
		
		if(lngIntegrationID==0){
			lngIntegrationID = m_lngAddIntegration;
		}
		
		OpenChildWindow("WCMailInt.asp?wci=wciEditDefaults&IID="+ lngIntegrationID + "&Proj=" + m_objRef.GetProjectID() +  "&RID=" + lngRuleID + "&Delim=" + 
									DELIM + "&Ac=3","EditUpdateDefaults","scrollbars=yes,resizable=yes", true, 700, 600, 0);
	}
	
	
	function Form_OnLoad()
    {
		//Disable MqList mouse monitoring.
		//We're going to register an onmousedown event within the body instead.
		m_MqList.ToggleOnMouseDownMonitoring(false);
		
		var objHeader=document.getElementById("HeaderText");
		var lngIntegrationID=m_objString.GetQueryStringValue(strCommandLine,"IID");
		var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
		var lngProjectID=m_objRef.GetProjectID();
		
		if(objHeader){
			if(lngRuleID > 0){
				document.title="Edit Rule";
				objHeader.innerHTML="Edit Rule";
			}else{
				document.title="Add Rule";
				objHeader.innerHTML="Add Rule";
			}
		}			
		
		if(lngRuleID == 0)
		{
			lngRuleID = m_lngAddRule;
			
		}

		var objRecordset=new CMqRecordset(m_strEscRuleFields,m_objViewFields.GetFieldIDName()); 
    	m_objViewFields.Load(objRecordset);

		m_oFieldValuesRs=new CMqRecordset(m_strEscRuleDataXML,m_objViewFields.GetFieldIDName());	
		
        m_objLoadDataMgr= new CMqLoadDataMgr(m_objViewFields,"document");
        m_objLoadDataMgr.SetUnescapeData(true);	
    	m_objLoadDataMgr.Load(m_oFieldValuesRs);
    	
    	HandleConditionValueOptions();
		
    	var objTxtName=document.getElementById("txtRuleName");
		
			var co = m_objRef.m_objHTTPrequest.Get(m_strCurrentLocation + "WCMailInt.ASP?WCI=wciGetRuleName&IID=" + lngIntegrationID 
																			+ "&Proj=" + lngProjectID + "&RID=" + lngRuleID, true);
			if (co!=m_objRef.m_objHTTPrequest.CANCEL_PROCESS){
				
				var objResponse=m_objRef.m_objHTTPrequest.Response(co);
					
					if (objResponse){
						if (objResponse.HasErrors()){
							objResponse.ProcessErrors("",true,window);
						}else{
					
							objTxtName.value = co;
						}
					}
			}
			
    	
    	if(objTxtName){
    		objTxtName.focus();
    	}
		
		var objRdo1 = document.getElementById("AR1_En");
		var objRdo2 = document.getElementById("AR2_En");
		var objRdo3 = document.getElementById("AR3_En");
		var objRdo7 = document.getElementById("AR7_En");
		
		var objChkMain = document.getElementById("chkMain");
		if(objRdo1.checked || objRdo2.checked || objRdo3.checked || objRdo7.checked){
			objChkMain.checked = true;
			
			if(objRdo1.checked){
				m_lngInitialActionSelected = 1;
			}else if(objRdo2.checked){
				m_lngInitialActionSelected = 2;
			}else if(objRdo3.checked){
				m_lngInitialActionSelected = 3;
			}else if(objRdo7.checked){
				m_lngInitialActionSelected = 7;
			}
		}else{
			objChkMain.checked = false;
			objRdo1.disabled = true;
			objRdo2.disabled = true;
			objRdo3.disabled = true;
			objRdo7.disabled = true;
		}
		
		var lngRow;
		for (lngRow=1;lngRow<=5;lngRow++){
			SetCurrentCondition("CR" + lngRow + "_P2");
			EvaluateTxtStates();
		}
		
		SetContactCheckbox(Boolean(<WC@RULE_CREATES_NEW_CONTACT></WC@RULE_CREATES_NEW_CONTACT>));
    }
    
	
	function CloseWindow()
	{
		if(!m_blnSaving)
		{
			var lngRuleID=m_objString.GetQueryStringValue(strCommandLine,"RID");
			
			//if this was a new integration, delete the new record.
			if(lngRuleID==0)
			{
				if(opener){
				opener.DeleteRule(m_lngAddRule, true);
				}
			}
			
		}
	}
	
	function ToggleRadioButtons()
	{
		var objRdo1 = document.getElementById("AR1_En");
		var objRdo2 = document.getElementById("AR2_En");
		var objRdo3 = document.getElementById("AR3_En");
		var objRdo7 = document.getElementById("AR7_En");
		var objChkMain = document.getElementById("chkMain");
		
		if(objChkMain.checked){
			objRdo1.checked = false;
			objRdo2.checked = false;
			objRdo3.checked = false;
			objRdo7.checked = false;
			objRdo1.disabled = false;
			objRdo2.disabled = false;
			objRdo3.disabled = false;
			objRdo7.disabled = false;
		}else{
			objRdo1.checked = false;
			objRdo2.checked = false;
			objRdo3.checked = false;
			objRdo7.checked = false;
			objRdo1.disabled = true;
			objRdo2.disabled = true;
			objRdo3.disabled = true;
			objRdo7.disabled = true;
		}
	}
		
	function SetContactCheckbox(blnContactVal)
	{
		blnContactValue = blnContactVal;
	}
	
	function GetContactCheckbox()
	{
		return blnContactValue;
	}
	
	function EvaluateTxtStates(blnClearTextBoxes)
	{
		var objAnchor = document.getElementById(m_strCurrentCondition);
		var objTxt
		var strTextboxID;
		var lngLocation;
		
		lngLocation = m_strCurrentCondition.length;
		strTextboxID = m_strCurrentCondition.substring(0, lngLocation-1);
		strTextboxID = strTextboxID + "3";
			
		objTxt = document.getElementById(strTextboxID);

		if(objAnchor.mqvalue == 5){
			objTxt.disabled = true;
			if(blnClearTextBoxes){
				objTxt.value = "";
			}
		}else{
			objTxt.disabled = false;
		}
		
	}
	
	function SetCurrentCondition(strID)
	{
		m_strCurrentCondition = strID;
	}
	
	 function WindowClosing()
	 {
		if(m_blnDataChanged && !m_blnSaving){
			return MSG_NAVIGATE_AWAY;
		}
	 }
	 
	 function DataChanged()
	 {
		m_blnDataChanged = true;
	 }
	 
	 function EvaluateRadioDataState(lngActionRow)
	 {		
		if(lngActionRow != m_lngInitialActionSelected){
			DataChanged();
		}
	 }
//-->
</script>
</head>
<body class="RecordBody ToolbarBody" style="margin:0px;overflow:auto" onload="Form_OnLoad()" onbeforeunload="return WindowClosing()" onunload="CloseWindow()" onkeypress="KeyPressed(event)" onmousedown="Document_OnMouseDown()">
   <style type="text/css">
		<!--
		    .SectionTitle{
		        color:white;
		        background-color:#94a6bd;
		        padding-top:5px;
		        padding-bottom:5px;
		        padding-left:5px;
		        font-family: tahoma, sans-serif;
		        font-weight:bold;
		        width:100%;
		        border: #336699 1px solid;
		        filter: progid:DXImageTransform.Microsoft.Gradient(gradientType=1,startColorStr=#94a6bd,endColorStr=white);
		                       b-order: #000080 1px groove;
		    }
		-->
	</style>
	<table width="100%" height="30" class="HeaderTop" marginwidth="0" cellpadding="0" cellspacing="0" border="0">	
		<tr>
			<td width="100%" align="left">
				<div id="HeaderText" class="SmallHeaderText"></div>
			</td>
		</tr>
	</table>				
	<input type="hidden" name="txtGridValues" id="txtGridValues" />
	<input type="hidden" name="txtChangedValues" id="txtChangedValues" />
	<input type="hidden" name="txtGridMappings" id="txtGridMappings" />
	<input type="hidden" name="txtChangedMappings" id="txtChangedMappings" />
	
			<div style="padding: 5px"> 	
	<table width="98%">		
	<tr><td>				
			   <div class="DialogLabelRequired" style="font-size:8pt;padding-bottom:5px">Rule Name: <input type="text" style="border:1px solid #336699;width:350px;padding-left:3px" id="txtRuleName" name="txtRuleName" onchange="DataChanged()" /></div>
                <div class="SectionTitle" style="font-size: 10pt;padding: 0px; margin: 0px;"><span style="margin-left: 3px;padding: 1px">When all these conditions are met...</span></div>
          <table summary="" id="tblConditions" class="DialogLabel" style="margin:3px;font-size:8pt;" cellspacing="1" border="0" width="90%">
				<tr style="border:blue 1px solid;">
				    <td onclick="SelectRow(this);" id="CR1td" style="border:1px solid #F7F9FF;" >
						<input id="CR1_En" name="CR1_En" title="Enabled" type="checkbox" onchange="DataChanged()" />
						<span class="actuator">
							<a id="CR1_P1" onclick="MqActuator_OnClick(this);" class="actuator" mqvalue="-1" mqlist="EmailFields">&lt;Field&gt;</a>&nbsp;
							<a id="CR1_P2" onclick="MqActuator_OnClick(this);SetCurrentCondition(this.id);" class="actuator" mqvalue="1" mqlist="EmailOperators">Is Equal To</a>&nbsp;
						</span>
						<input id="CR1_P3" name="CR1_P3" type="text" style="border:1px solid #336699;width:200px;padding-left:3px;" onchange="EnsureCurrentRowIsEnabled();DataChanged()" />
				    </td>
				</tr> 
				<tr style="border:blue 1px solid;">
				    <td onclick="SelectRow(this);" id="CR2" style="border:1px solid #F7F9FF;" >
						<input id="CR2_En" name="CR2_En" title="Enabled" type="checkbox" onchange="DataChanged()" />
				        <span class="actuator">
							<a id="CR2_P1" onclick="MqActuator_OnClick(this);" class="actuator" mqvalue="-1" mqlist="EmailFields">&lt;Field&gt;</a>&nbsp;
							<a id="CR2_P2" onclick="MqActuator_OnClick(this);SetCurrentCondition(this.id);" class="actuator" mqvalue="1" mqlist="EmailOperators">Is Equal To</a>&nbsp;
						</span>
						<input  id="CR2_P3" name="CR2_P3"  type="text" style="border:1px solid #336699;width:200px;padding-left:3px;" onchange="EnsureCurrentRowIsEnabled();DataChanged()" />
				    </td>
				</tr> 
				<tr style="border:blue 1px solid;">
				    <td onclick="SelectRow(this);" id="CR3" style="border:1px solid #F7F9FF;" >
						<input id="CR3_En" name="CR3_En" title="Enabled" type="checkbox" onchange="DataChanged()"/>
				        <span class="actuator">
							<a id="CR3_P1" onclick="MqActuator_OnClick(this);" class="actuator" mqvalue="-1" mqlist="EmailFields">&lt;Field&gt;</a>&nbsp;
							<a id="CR3_P2" onclick="MqActuator_OnClick(this);SetCurrentCondition(this.id);" class="actuator" mqvalue="1" mqlist="EmailOperators">Is Equal To</a>&nbsp;
				        </span>
						<input id="CR3_P3" name="CR3_P3" type="text" style="border:1px solid #336699;width:200px;padding-left:3px;" onchange="EnsureCurrentRowIsEnabled();DataChanged()" />
				    </td>
				</tr> 
				<tr style="border:blue 1px solid;">
				    <td onclick="SelectRow(this);" id="CR4" style="border:1px solid #F7F9FF;" >
					    <input id="CR4_En" name="CR4_En" title="Enabled" type="checkbox" onchange="DataChanged()" />
				        <span class="actuator">
							<a id="CR4_P1" onclick="MqActuator_OnClick(this);" class="actuator" mqvalue="-1" mqlist="EmailFields">&lt;Field&gt;</a>&nbsp;
							<a id="CR4_P2" onclick="MqActuator_OnClick(this);SetCurrentCondition(this.id);" class="actuator" mqvalue="1" mqlist="EmailOperators">Is Equal To</a>&nbsp;
				        </span>
						<input id="CR4_P3" name="CR4_P3" type="text" style="border:1px solid #336699;width:200px;padding-left:3px;" onchange="EnsureCurrentRowIsEnabled();DataChanged()" />
				    </td>
				</tr> 
				<tr style="border:blue 1px solid;">
				    <td onclick="SelectRow(this);" id="CR5" style="border:1px solid #F7F9FF;" >
						<input id="CR5_En" name="CR5_En" title="Enabled" type="checkbox" onchange="DataChanged()" />
				        <span class="actuator">
							<a id="CR5_P1" onclick="MqActuator_OnClick(this);" class="actuator" mqvalue="-1" mqlist="EmailFields">&lt;Field&gt;</a>&nbsp;
							<a id="CR5_P2" onclick="MqActuator_OnClick(this);SetCurrentCondition(this.id);" class="actuator" mqvalue="1" mqlist="EmailOperators">Is Equal To</a>&nbsp;
				        </span>
						<input id="CR5_P3" name="CR5_P3" type="text" style="border:1px solid #336699;width:200px;padding-left:3px;" onchange="EnsureCurrentRowIsEnabled();DataChanged()" />
				    </td>
				</tr> 
				  <tr style="border:blue 1px solid;">
                    <td onclick="SelectRow(this);" id="CR6" style="border:1px solid #F7F9FF;">
                        <input id="CR6_En" name="CR6_En" title="Enabled" type="checkbox" onchange="DataChanged()" />
                        Has Attachments
                    </td>
                </tr>   
			  <tr style="border:blue 1px solid;">
                    <td onclick="SelectRow(this);" id="CR7" style="border:1px solid #F7F9FF;">
                        <input id="CR7_En" name="CR7_En" title="Enabled" type="checkbox"  onchange="DataChanged()" />
					   E-mail contains number identifier <b>(<WC@LINK_TAG></WC@LINK_TAG>)</b> of existing issue in <span class="actuator"><a id="CR7_P1" onclick="MqActuator_OnClick(this);" class="actuator" mqvalue="-1" mqlist="LinkToIssueFields">&lt;Field&gt;</a></span> field
                    </td>
                </tr>   
            </table>
				            
         <div class="SectionTitle" style="font-size: 10pt; padding: 0px; margin: 0px;">
           <span style="margin-left: 3px;padding: 1px">Perform the following actions...</span>
        </div>
                         
              <table summary="" id="tblActions" class="DialogLabel" style="font-size:8pt;margin-left: 3px; margin-right: 3px; margin-top: 3px;" cellspacing="1" border="0" width="90%">
              				 <tr style="border:blue 1px solid;">
                    <td colspan="2" onclick="SelectRow(this);" id="MainTD" style="border:1px solid #F7F9FF;">
                      <input id="chkMain" name="chkMain" title="Enabled" type="checkbox" onclick="ToggleRadioButtons()" onchange="DataChanged()"/>
                      Integrate e-mail with the Vector system:
                    </td>
                </tr>        
                <tr style="border:blue 1px solid;">
                    <td colspan="2" onclick="SelectRow(this);" id="AR1" style="padding-left:25px;border:1px solid #F7F9FF;">
                        <input id="AR1_En" name="rdoMain" title="Enabled" onclick="EvaluateRadioDataState(1)" type="radio" />
                        Create New Issue using 
					   <span class="actuator">
						   <a id="AR1_P1" onclick="OpenNewIssueWindow()" class="actuator" style="text-decoration: underline;" mqvalue="1">
								these values </a>
						</span>
                    </td>
                </tr>        
                <tr style="border:blue 1px solid;">
                    <td colspan="2" onclick="SelectRow(this);" id="AR2" style="padding-left:25px;border:1px solid #F7F9FF;">
                        <input id="AR2_En" name="rdoMain" title="Enabled" onclick="EvaluateRadioDataState(2)" type="radio" />
                         Send to Queue
                    </td>
                </tr>   
				<tr style="border:blue 1px solid;">
                    <td colspan="2" onclick="SelectRow(this);" id="AR3" style="padding-left:25px;border:1px solid #F7F9FF;">
                      <input id="AR3_En" name="rdoMain" title="Enabled" onclick="EvaluateRadioDataState(3)" type="radio" />
					Link to issue   
                    </td>
                </tr> 
                <tr style="border:blue 1px solid;">
                    <td colspan="2" onclick="SelectRow(this);" id="AR7" style="padding-left:25px;border:1px solid #F7F9FF;">
                      <input id="AR7_En" name="rdoMain" title="Enabled" onclick="EvaluateRadioDataState(7)" type="radio" />
					Link to Issue and Update it using <a id="AR7_P1" onclick="EditUpdateMapping()" class="actuator" style="text-decoration: underline;" href="#" mqvalue="1">
                            these mappings</a> and <a id="AR7_P2" onclick="EditUpdateDefaults()" class="actuator" style="text-decoration: underline;" href="#" mqvalue="1">
                            these values </a>
                    </td>
                </tr> 
				<tr style="border:blue 1px solid;">
                    <td colspan="2" onclick="SelectRow(this);" id="AR4" style="border:1px solid #F7F9FF;">
                        <input id="AR4_En" name="AR4_En" title="Enabled" type="checkbox" onchange="DataChanged()" />
						<span id="AR4_P0" name="AR4_P0" class="actuator" style="text-decoration: underline;" onclick="OpenEmailContentEditor(4)" onmouseover="this.className='actuator_hover'" onmouseout="this.className='actuator'">Send an e-mail</span> to
						<span id="AR4_P1">&lt;None&gt;</span>                               
                    </td>
                </tr>
				<tr style="border:blue 1px solid;">
                    <td colspan="2" onclick="SelectRow(this);" id="AR5" style="border:1px solid #F7F9FF;">
                        <input id="AR5_En" name="AR5_En" title="Enabled" type="checkbox" onchange="DataChanged()" />
                        <span id="AR5_P0" name="AR5_P0" class="actuator" style="text-decoration: underline;" onclick="OpenEmailContentEditor(5)" onmouseover="this.className='actuator_hover'" onmouseout="this.className='actuator'">Send an e-mail</span> to
						<span id="AR5_P1">&lt;None&gt;</span>                               
                    </td>
                </tr>
				<tr style="border:blue 1px solid;">
                    <td onclick="SelectRow(this);" id="AR6" style="border:1px solid #F7F9FF;">
                        <input id="AR6_En" name="AR6_En" title="Enabled" type="checkbox" onchange="DataChanged()" />
                         Run program <input type="text" style="border:1px solid #336699;width:70%;padding-left:3px" id="AR6_P1" name="AR6_P1" onchange="EnsureCurrentRowIsEnabled();DataChanged()" />                          
                    </td>
                </tr>
            </table>
                </div>  		
			<div class="DialogLabel" style="border:darkblue 1px ridge;padding: 4px;margin-left:10px;margin-top:0px;margin-right:10px;margin-bottom:2px;font-size: 8pt;width:95%;background-color: #fafad2;">
           Once an e-mail matches a Rule's conditions, that Rule's actions are executed.  
Afterwards, the next e-mail in the list is considered - without evaluating the remaining Rules.
			</div>
			<input type="hidden" id="txtHiddenEmailSrc_4" />
			<input type="hidden" id="txtHiddenEmailSrc_5" />   
			<input type="hidden" id="txtHiddenMailID_4" />
			<input type="hidden" id="txtHiddenMailID_5" /> 
</td></tr>
<tr>
	<td align="right">
		<script type="text/javascript">document.write(writeImageAlt("Ok","../../../Theme/images/buttons/","js:SaveRule();",78,27,false,"OK"));</script>&nbsp;&nbsp;&nbsp;&nbsp;
		<script type="text/javascript">document.write(writeImageAlt("Cancel","../../../Theme/images/buttons/","js:window.close()",78,27,false,"Cancel"));</script>
	</td>
</tr>
</table>
</div>
		  <select id="EmailFields" class="mqselect" size="3"  
			onmouseover="m_blnOverMenu=true;" onmouseout="m_blnOverMenu=false;"
			onclick="m_MqList.OnClick(this)" onkeypress="m_MqList.OnKeyPress(event,this)" 
			onblur="m_MqList.OnBlur()">
				<option value="Body" >Body</option>
				<option value="From" >From</option>
				<option value="Subject" >Subject</option>
		</select>
		
		  <select id="LinkToIssueFields" class="mqselect" size="3"  
			onmouseover="m_blnOverMenu=true;" onmouseout="m_blnOverMenu=false;"
			onclick="m_MqList.OnClick(this)" onkeypress="m_MqList.OnKeyPress(event,this)" 
			onblur="m_MqList.OnBlur()" onchange="EnsureCurrentRowIsEnabled()">
				<option value="Subject or Body">Subject or Body</option>
				<option value="Subject" >Subject</option>
				<option value="Body" >Body</option>
		</select>
		
		
		  <select id="EmailOperators" class="mqselect" size="3"  
			onmouseover="m_blnOverMenu=true;" onmouseout="m_blnOverMenu=false;"
			onclick="m_MqList.OnClick(this);EvaluateTxtStates();" onkeypress="m_MqList.OnKeyPress(event,this)" 
			onblur="m_MqList.OnBlur()">
				<option value="1" >Is Equal To</option>
				<option value="2" >Is Not Equal To</option>
				<option value="3" >Contains</option>
				<option value="4">Doesn't Contain</option>
				<option value="5">Is Empty</option>
		</select>
</body>
</html>