<html>
<head>
<title>Data Loss Prevention - Add Policy</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--BASE HREF="$$BASE_URL$$"-->
<link href="css/trend-style-new.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="javascripts/TmCube_Common.js"></script>
<script language="JavaScript" src="javascripts/TmCube_Tree.js"></script>
<script language="JavaScript" src="javascripts/policy.js"></script>
<script language="JavaScript" src="javascripts/localization.js"></script>
<script language="JavaScript" src="javascripts/trend-ui-new.js"></script>
<script language="JavaScript" src="javascripts/OLH_Mapping.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--

var nStep = 1;		      // record the current step
var N_TOTALSTEP = 5;      // record the total step
var TOTAL_TITLE_COUNT = N_TOTALSTEP; // for title display
var bHideExcption = false;  // flag for hide the exception setting

var bInitialList = false; // flag the whether listbox initiallized for the step 1

var objRule = new CRule(); //store the Rule info
var addExceptionIndex = -1; //store the current add exception index in objRule.exceptionList
var vRecordPerPage = 10;
var bIsRealTime = $$IS_REALTIME$$;
var IsSharePoint2007 = $$IS_SHAREPOINT2007$$;
var IsFromTemplatePage = $$IS_FROM_TEMPLATE_PAGE$$;
// for Account String join
var lenLength = 6;
var lenType = 2;
var AddRuleSubmitFlag = false;
// for add/edit exception page change
var gbLastIsAnySiteToAccount = false;
var gstrLastSiteId = "";
var gExcetpionOperate = "";
var OPER_ADD = "ADD";
var OPER_EDIT = "EDIT";
// Change other step title 
// Note:should do it before jsInitPage
if (bIsRealTime && IsSharePoint2007)TOTAL_TITLE_COUNT = 4;
function jsInitPage() 
{
  if (!bIsRealTime)
  {
     document.getElementById('docForManuAction').style.display = "";
     document.getElementById('QuarantineAction').style.display = "";
     // show notify to violator
     document.getElementById('notifyViolatorDIV1').style.display = "";
     document.getElementById('notifyViolatorDIV2').style.display = "";

     document.getElementById('optPassAction').checked = true;
     document.getElementById('txtDeleteAction').innerText = STR_ACTION_DELETE;
     document.getElementById('SelectActionToolTipIcon').style.display = "";       
  }
  else
  {
      if (IsSharePoint2007)
      {
          // Hide Exception
          // 1, Hide step 2 title
          document.getElementById("_step2").style.display = "none";
          document.getElementById("step2").style.display = "none";
         
          //2, Hide exception
          bHideExcption = true; 
      }
  }

  SeletctPage(); 
 
  setOptionValueEx(document.fmMain.optAdminMessageType,STR_DLP_NOTIFY_MSG,STR_DLP_NOTIFY_MSG); 
  setOptionValueEx(document.fmMain.optViolatorMessageType,STR_DLP_NOTIFY_MSG,STR_DLP_NOTIFY_MSG); 
  setOptionValueEx(document.fmMain.optSNMPMessageType,STR_DLP_NOTIFY_MSG,STR_DLP_NOTIFY_MSG);

   var vPage = "10,20,50,100,All";
   if(document.fmMain.optRecordPerPage.length == 0)
   {
       setOptionValue(document.fmMain.optRecordPerPage,vPage,false);
   } 
   if(IsFromTemplatePage)
   {
      RecoveryFromTempData();
   }
   else
   {
      //add default priority value
      var existlistTable = document.getElementById("tabExistPolicyList");
      var row=existlistTable.getElementsByTagName('tr');
      var rLen=row.length;
      document.getElementById("RuleOrder").value=rLen;
   }
   setListboxUI(document.getElementById("lstAvailableTemplate"),document.getElementById("divAvailableTemplateInner"),document.getElementById("divAvailableTemplateOuter"));
   setListboxUI(document.getElementById("lstSelectedTemplate"),document.getElementById("divSelectedTemplateInner"),document.getElementById("divSelectedTemplateOuter"));
   setListboxUI(document.getElementById("lstAvailableAccount"),document.getElementById("divAvailableAccountInner"),document.getElementById("divAvailableAccountOuter"));
   setListboxUI(document.getElementById("lstSelectedAccount"),document.getElementById("divSelectedAccountInner"),document.getElementById("divSelectedAccountOuter"));
   jsAnysiteCheck();
   jsAnyoneCheck();
   jsUIDependency();
   //jsAllSite(true);
}
function jsCancel() 
{
    window.location.href = "$$REDIRECT_TO_PAGE$$";
}
function jsShowExceptionStep()
{
    nStep = 2;
    SeletctPage();
}
function jsShowFirstStep()
{
    nStep = 1;
    SeletctPage();
}
function jsCheckInput()
{
    //1. Keyword should not be null
    if (nStep == 1)
    {
      if (document.fmMain.lstSelectedTemplate.options.length <= 0)
      {
        alert(STR_WARN_DLP_TEMPLATE);
        return false; 
      }
    }   

    if (nStep == N_TOTALSTEP -1)
    {

    //2. Notification step = N_TOTALSTEP -1
    if(document.getElementById("chkNotifyAdmin").checked){
	    if(document.fmMain.txtNotifyAdminTo1.value == ""){
	        alert(STR_ERR_NOTIFY_ADMIN_ACCOUNT);
		    jsFocus(document.fmMain.txtNotifyAdminTo1);
		    return false;
	    }	
    }
  	if(document.getElementById("chkNotifySNMP").checked){
	    if (!document.fmMain.txtSNMPIP.value.length){
	            alert(STR_ERR_BLANK_IPADDRESS);
	            jsFocus(document.fmMain.txtSNMPIP);
	            return false;
	    }
	    if (!checkIPAddressFormat(document.fmMain.txtSNMPIP.value,STR_ERR_INVALID_IPADDRESS,false)) {
		    if(document.getElementById("tabSNMP_items").style.display=="none")
	                document.getElementById("tabSNMP").onclick();
		    jsFocus(document.fmMain.txtSNMPIP);
		    return false;
	    }
	    if (!checkNumberRange(document.fmMain.txtSNMPCommunity.value.length,INT_NMIN_SNMP,INT_NMAX_SNMP,STR_WARN_SNMP,false)) {
		    if(document.getElementById("tabSNMP_items").style.display=="none")
	                document.getElementById("tabSNMP").onclick();
		    jsFocus(document.fmMain.txtSNMPCommunity);
		    return false;
	    }
 		if (document.getElementById("txtSNMPMessage").value.length == 0)
		{
			alert(STR_ERR_BLANK_MESSAGE);
			jsFocus(document.fmMain.txtSNMPMessage);
			return false;
		}       
    }
	if (!checkNumberRange(document.fmMain.txtNotifyAdminSettingsPeriod.value,INT_NMIN_NOTI_PERIOD,INT_NMAX_NOTI_PERIOD,STR_WARN_NOTI_PERIOD,false)) {
		if (document.getElementById("tabNotifyAdmin_items").style.display == "none") setUIMoreDisplay(document.getElementById("tabNotifyAdmin"));
		jsFocus(document.fmMain.txtNotifyAdminSettingsPeriod);
		return false;	
	}
	if (!checkNumberRange(document.fmMain.txtNotifyAdminSettingsOccurence.value,INT_NMIN_NOTI_OCCUR,INT_NMAX_NOTI_OCCUR,STR_WARN_NOTI_OCCUR,false)) {
		setUITagDisplay(3,3,'Notification');
		if (document.getElementById("tabNotifyAdmin_items").style.display == "none") setUIMoreDisplay(document.getElementById("tabNotifyAdmin"));
		jsFocus(document.fmMain.txtNotifyAdminSettingsOccurence);
		return false;	
	}
	if (!checkMultiEmailPatternFormat(document.fmMain.txtNotifyAdminTo1.value,STR_ERR_INVALID_EMAIL) ||
		!checkNumberRange(document.fmMain.txtNotifyAdminTo1.value.length,1,INT_LMAX_EM_ADDR_M,STR_WARN_EM_ADDR_M)) {
		setUITagDisplay(3,3,'Notification');
		if (document.getElementById("tabNotifyAdmin_items").style.display == "none") setUIMoreDisplay(document.getElementById("tabNotifyAdmin"));
		jsFocus(document.fmMain.txtNotifyAdminTo1);
		return false;
	}
	if (!checkNumberRange(document.getElementById("txtNotifyAdminMessage").value.length,0,INT_LMAX_EM_CONTENT,STR_WARN_EM_CONTENT)) {
		if (document.getElementById("tabNotifyAdmin_items").style.display == "none") setUIMoreDisplay(document.getElementById("tabNotifyAdmin"));
		jsFocus(document.getElementById("txtNotifyAdminMessage"));
		return false;
	}
    if (!checkNumberRange(document.getElementById("txtNotifyViolatorMessage").value.length,0,INT_LMAX_EM_CONTENT,STR_WARN_EM_CONTENT)) {
		if (document.getElementById("tabNotifyViolator_items").style.display == "none") setUIMoreDisplay(document.getElementById("tabNotifyViolator"));
		jsFocus(document.getElementById("txtNotifyViolatorMessage"));
		return false;
	}
	if (!checkNumberRange(document.getElementById("txtSNMPMessage").value.length,0,INT_LMAX_EM_CONTENT,STR_WARN_EM_CONTENT)) {
		if (document.getElementById("tabSNMP_items").style.display == "none") setUIMoreDisplay(document.getElementById("tabSNMP"));
		jsFocus(document.getElementById("txtSNMPMessage"));
		return false;
	}
    }
    //3. Name
    if (nStep == N_TOTALSTEP)
    {
    if (!checkNumberRange(document.getElementById("RuleName").value.length,0,INT_LMAX_CF_NAME,STR_WARN_RULE_NAME,false))
    {
        jsFocus(document.getElementById("RuleName"));
        return false;
    }
    if (document.getElementById("RuleOrder").value.length == 0)
    {
        alert(STR_ALERT_NO_PRIORITY);
        return false;
    }
    }
    return true;
}
function jsNext() 
{
   if(!jsCheckInput())return;
   nStep++;
   if (nStep == 2 && bHideExcption)nStep++;
   SeletctPage();
}
function jsBack() 
{
    nStep--;
    if (nStep == 2 && bHideExcption)nStep--;
    SeletctPage();
}
function jsSubmit() 
{
    // check last step
	var strRuleName = document.getElementById("RuleName").value;
    if (!checkNumberRange(strRuleName.length,0,INT_LMAX_CF_NAME,STR_WARN_RULE_NAME,false))
    {
        jsFocus(document.getElementById("RuleName"));
        return false;
    }
	var re = /^\s*$/;
	if(re.test(strRuleName))
	{
	   alert(STR_WARN_RULE_NAME_IS_SPACE);
	   jsFocus(document.getElementById("RuleName"));
       return false;
	}
	// description
	var strDescription = document.getElementById("RuleDescription").value;
	if(strDescription.length >= INT_LMAX_CF_DESCRIPTION)
	{
		alert(STR_WARN_RULE_DESCRIPTION);
		jsFocus(document.getElementById("RuleDescription"));
		return false;
	}
    if (document.getElementById("RuleOrder").value.length == 0)
    {
        alert(STR_ALERT_NO_PRIORITY);
        return false;
    }
	var iPriority  = parseInt(document.getElementById("RuleOrder").value);
    setOption2Selected(document.fmMain.lstSelectedTemplate);
    document.getElementById("ExceptionsString").value = objRule.ToString();
    document.getElementById("DelExceptionIds").value = objRule.deleteExceptions;
    document.getElementById("FormAction").value = "finish";
	
    if( AddRuleSubmitFlag == false )
	{
		jsAddCSRFToken(document.fmMain);
    document.fmMain.submit(); 
		AddRuleSubmitFlag = true;
	}
}
function SeletctPage() 
{
    HideAllPage();
    var tabStep_n = document.getElementById("tabStep" + nStep);
    tabStep_n.style.display = "";

    for (var t=1; t<= N_TOTALSTEP; t++)
    {        
        if (t == nStep)
        {
            var step_n =  document.getElementById("step" + t);
            step_n.style.display = "";         
        }
        else
        {
            var _step_n = document.getElementById("_step" + t);
            if (bHideExcption && t == 2)
            {
                _step_n.style.display = "none";
            }
            else
                _step_n.style.display = ""; 
            
       
            var _step_n_img = document.getElementById("_step"+t+"_img");
            if (t!=1 && t<nStep)
            {               
                _step_n_img.src = "images/arrow_icons_passed.gif";
            }
            else if (t > nStep)
            {
                _step_n_img.src = "images/arrow_icons_grey.gif";
            }
        }
    }
    var backButton = document.getElementById("backButton");
    var submitButton = document.getElementById("submitButton");
    var nextButton = document.getElementById("nextButton");
    
    if (nStep != 1)
    {
        backButton.disabled = false;
    }
    else
    {
        backButton.disabled = true;
    }
    
    if (nStep < N_TOTALSTEP )
    {
        submitButton.style.display = "none";
        nextButton.style.display = "";
    } 
    else
    {
        nextButton.style.display = "none";
        submitButton.style.display = "";
    }
}
function HideAllPage() 
{
     for (var t=1; t<= N_TOTALSTEP; t++)
     {
         var step_n =  document.getElementById("step" + t);
         var _step_n =  document.getElementById("_step" + t);
         var tabStep_n = document.getElementById("tabStep" + t);
         step_n.style.display = "none";
         _step_n.style.display = "none";
         tabStep_n.style.display = "none";   
     }
}

function jsClearList(oTarget) {
	// Clear List
	for (var i=oTarget.length;i>0;i--) {
		oTarget.remove(i-1);
	}
}

function jsCheckLength(strTemp) // <= 255
{    
	var i,total;    
	total=0;    
	for(i=0;i<strTemp.length;i++)    
	{    
  		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))    
    		total=total+1;    
  		else   
    		total=total+2;    
	}    
	if(total > 255){
		return false;	
	}
	return true;   
}

function jsAddTemplate()
{
	var lstAvailTemp = document.getElementById("lstAvailableTemplate");
	var lstSelectTemp = document.getElementById("lstSelectedTemplate");
	var iLength =lstAvailTemp.options.length;
	var bDuplicate = false;
	for(var i=0;i<iLength;i++)
	{
	   if(lstAvailTemp.options[i].selected)
	   {
		  var index = setUIAddItemWithValue(lstAvailTemp.options[i].text, lstAvailTemp.options[i].value, lstSelectTemp)
	      if(index+1<lstSelectTemp.options.length)
		     bDuplicate = true;
	   }
	}
	setListboxUI(lstSelectTemp,document.getElementById("divSelectedTemplateInner"),document.getElementById("divSelectedTemplateOuter"));
}
function jsLinkToEditTemplatePage(lstName)
{
   var lstTemplate = document.getElementById(lstName);
   var TemplateId="";
   var iLength = lstTemplate.options.length;
   for(var i = 0;i<iLength;i++)
   {
      if(lstTemplate.options[i].selected)
	     TemplateId =lstTemplate.options[i].value;
   }
   jsSaveTempData(TemplateId);
   document.location.href = "$$FILTER_DLP_EDIT_TEMPLATE_PAGE$$&TemplateId="+ TemplateId+"&RedirectPage=scan/DLP_Rule_Add.htm";
}
function jsLinkToAddTemplatePage()
{
	jsSaveTempData("");
	document.location.href = "$$FILTER_DLP_ADD_TEMPLATE_PAGE$$&RedirectPage=scan/DLP_Rule_Add.htm";
}
function jsSaveTempData(TemplateId)
{
   var TempDataFrame = window.parent.frames["TempDataFrame"];
   var lstSelectedTemplate = document.getElementById("lstSelectedTemplate");
   var selectedtemplateid=[];
   
   if(null !=lstSelectedTemplate)
   {
      var iLength = lstSelectedTemplate.options.length;
	  var tarObj = TempDataFrame.document.getElementById("TempSelectedTemplateId");
	  var tarObjtxt=TempDataFrame.document.getElementById("TempTemplateId");
      for(var i=0;i<iLength;i++){
	    setUIAddItemWithValue(lstSelectedTemplate.options[i].text, lstSelectedTemplate.options[i].value, tarObj);
		selectedtemplateid.push(lstSelectedTemplate.options[i].text+"@@@@"+lstSelectedTemplate.options[i].value);
	  }
	  tarObjtxt.value=selectedtemplateid.join(";");
   }
   if(TemplateId!="")
        TempDataFrame.document.getElementById("TempEditTemplateId").value = TemplateId;
   TempDataFrame.document.getElementById("TempExceptions").value = objRule.DeserializeString();;
   TempDataFrame.document.getElementById("TempDelExceptionIds").value = objRule.deleteExceptions;
   if(document.getElementById("optQuarantine").checked)
      TempDataFrame.document.getElementById("TempAction").value = "quarantine";
   else if(document.getElementById("rdoDeleteAll").checked)
      TempDataFrame.document.getElementById("TempAction").value = "block";
   else
       TempDataFrame.document.getElementById("TempAction").value = "pass";
   if(document.getElementsByName("optActionNotify")[0].checked)
        TempDataFrame.document.getElementById("TempchkNotify").value = "notify";
   //notification
   if(document.getElementById("chkNotifyAdmin").checked)
      TempDataFrame.document.getElementById("TempchkAdmin").value = "checked";
   TempDataFrame.document.getElementById("TempAdminTo").value = document.getElementById("txtNotifyAdminTo1").value;
   TempDataFrame.document.getElementById("TempAdminSubject").value = document.getElementById("txtNotifyAdminSubject").value;
   TempDataFrame.document.getElementById("TempAdminMsg").value = document.getElementById("txtNotifyAdminMessage").value;  
   var sendArray = document.getElementsByName("optNotifyAdminSettings");
   if(sendArray[0].checked)
   {
      TempDataFrame.document.getElementById("TempSendOption").value = 0;
	  var temp = document.getElementById("txtNotifyAdminSettingsPeriod").value;
	  var obj = document.getElementById("optNotifyAdminSettingsPeriodUnit");
	  temp+=String.fromCharCode(9);
	  temp+=obj.options[obj.selectedIndex].value;
	  TempDataFrame.document.getElementById("TempSendPeriod").value = temp;
   }
   else if(sendArray[1].checked)
   {
     TempDataFrame.document.getElementById("TempSendOption").value = 1;
	 TempDataFrame.document.getElementById("TempSendPeriod").value = document.getElementById("txtNotifyAdminSettingsOccurence").value;
   }
   else
     TempDataFrame.document.getElementById("TempSendOption").value = 2;
   
   if(document.getElementById("chkNotifySNMP").checked)
      TempDataFrame.document.getElementById("TempchkSNMP").value = "checked";
   TempDataFrame.document.getElementById("TempSNMPIP").value = document.getElementById("txtSNMPIP").value;
   TempDataFrame.document.getElementById("TempSNMPCommunity").value = document.getElementById("txtSNMPCommunity").value;
   TempDataFrame.document.getElementById("TempSNMPMsg").value = document.getElementById("txtSNMPMessage").value;
   
   if(document.getElementById("chkNotifyEventLog").checked)
      TempDataFrame.document.getElementById("TempchkEventLog").value = "checked";
	  
	TempDataFrame.document.getElementById("TempName").value = document.getElementById("RuleName").value;
	TempDataFrame.document.getElementById("TempDesc").value = document.getElementById("RuleDescription").value;
	TempDataFrame.document.getElementById("TempOrder").value = document.getElementById("RuleOrder").value;
	if(document.getElementById("optPolicyEnabled").checked)
	   TempDataFrame.document.getElementById("TempEnable").value = "checked";
}

function setTempTemplates()
{
	var TempDataFrame = window.parent.frames["TempDataFrame"];
    var SelectedTemplate=TempDataFrame.document.getElementById("TempTemplateId").value;
	var lstTempSelectedTemplate=document.getElementById("__lstSelectedTemplate");
	var _temps=[];
	if(SelectedTemplate) _temps=SelectedTemplate.split(";");
	for(var i=0,ilen=_temps.length;i<ilen;i++){
		var _item=_temps[i].split("@@@@");
		setUIAddItemWithValue(_item[0], _item[1], lstTempSelectedTemplate);
	}
	
}

function RecoveryFromTempData()
{
   setTempTemplates();  
   var TempDataFrame = window.parent.frames["TempDataFrame"];
   var lstTempSelectedTemplate = document.getElementById("__lstSelectedTemplate");
   var tarObj = document.getElementById("lstSelectedTemplate");
   setOption2Selected(tarObj);
   setUIDelfromList(tarObj);
   if(null !=lstTempSelectedTemplate)
   { 
      var iLength = lstTempSelectedTemplate.options.length;
	  var tempalteId  = TempDataFrame.document.getElementById("TempEditTemplateId").value;
      for(var i=0;i<iLength;i++)
	  {
	    if(tempalteId!=lstTempSelectedTemplate.options[i].value)
		   setUIAddItemWithValue(lstTempSelectedTemplate.options[i].text, lstTempSelectedTemplate.options[i].value, tarObj);
	     else
		 {
		    var availTemplate = document.getElementById("lstAvailableTemplate");
			for(var j = 0;j<availTemplate.length;j++)
			{
			   if(availTemplate.options[j].value == tempalteId)
			   {
			      setUIAddItemWithValue(availTemplate.options[j].text, availTemplate.options[j].value, tarObj);
				  break;
			   }
			}
		 }
	  }
	  setListboxUI(tarObj,document.getElementById("divSelectedTemplateInner"),document.getElementById("divSelectedTemplateOuter"));
   }
   var strValue="";
   strValue = TempDataFrame.document.getElementById("TempExceptions").value;
   if(strValue!="")
   {
	  objRule.parseString(strValue);
	  jsPage(1);
   }
   strValue = TempDataFrame.document.getElementById("TempDelExceptionIds").value;
   if(strValue!="")
      objRule.deleteExceptions = strValue;
   strValue = TempDataFrame.document.getElementById("TempAction").value;
   if(strValue=="quarantine")
      document.getElementById("optQuarantine").checked = true;
   else if(strValue=="block")	
      document.getElementById("rdoDeleteAll").checked = true;
   else
      document.getElementById("optPassAction").checked = true; 
	  
   strValue = TempDataFrame.document.getElementById("TempchkNotify").value;
   if(strValue!="") 
      document.getElementsByName("optActionNotify")[0].checked = true;
   else
	  document.getElementsByName("optActionNotify")[1].checked = true;
	  
   //notification
    strValue = TempDataFrame.document.getElementById("TempchkAdmin").value;
    if(strValue!="") 
      document.getElementById("chkNotifyAdmin").checked = true;
	else
	  document.getElementById("chkNotifyAdmin").checked = false;
	strValue = TempDataFrame.document.getElementById("TempAdminTo").value;
    if(strValue!="")
      document.getElementById("txtNotifyAdminTo1").value = strValue;
    strValue = TempDataFrame.document.getElementById("TempAdminSubject").value;
    if(strValue!="")
      document.getElementById("txtNotifyAdminSubject").value = strValue;
	strValue = TempDataFrame.document.getElementById("TempAdminMsg").value;
    if(strValue!="")
      document.getElementById("txtNotifyAdminMessage").value = strValue;  
    strValue = TempDataFrame.document.getElementById("TempSendOption").value;
    if(strValue==0)
    {
      var strValue = TempDataFrame.document.getElementById("TempSendPeriod").value;
	  var ValueArray = strValue.split(String.fromCharCode(9));
	  document.getElementById("txtNotifyAdminSettingsPeriod").value = ValueArray[0];
      document.getElementById("optNotifyAdminSettingsPeriodUnit").options[ValueArray[1]].selected = true;
   }
   else if(strValue==1)
   {
	 var strOccur = TempDataFrame.document.getElementById("TempSendPeriod").value;
	 document.getElementById("txtNotifyAdminSettingsOccurence").value = strOccur;
     document.getElementsByName("optNotifyAdminSettings")[1].checked= true;
   }
   else
     document.getElementsByName("optNotifyAdminSettings")[2].checked= true;
	 
    strValue = TempDataFrame.document.getElementById("TempchkSNMP").value;
    if(strValue!="") 
      document.getElementById("chkNotifySNMP").checked = true;
	else
	  document.getElementById("chkNotifySNMP").checked = false;
	strValue = TempDataFrame.document.getElementById("TempSNMPIP").value;
    if(strValue!="")
      document.getElementById("txtSNMPIP").value = strValue;
    strValue = TempDataFrame.document.getElementById("TempSNMPCommunity").value;
    if(strValue!="")
      document.getElementById("txtSNMPCommunity").value = strValue;
	strValue = TempDataFrame.document.getElementById("TempSNMPMsg").value;
    if(strValue!="")
      document.getElementById("txtSNMPMessage").value = strValue;
    strValue = TempDataFrame.document.getElementById("TempchkEventLog").value;
    if(strValue!="") 
      document.getElementById("chkNotifyEventLog").checked = true;
	else
      document.getElementById("chkNotifyEventLog").checked = false;	
    strValue = TempDataFrame.document.getElementById("TempName").value;
    if(strValue!="")
      document.getElementById("RuleName").value = strValue;
	strValue = TempDataFrame.document.getElementById("TempDesc").value;
    if(strValue!="")
      document.getElementById("RuleDescription").value = strValue;
	strValue = TempDataFrame.document.getElementById("TempOrder").value;
    if(strValue!="")
      document.getElementById("RuleOrder").value = strValue;
	strValue = TempDataFrame.document.getElementById("TempEnable").value;
    if(strValue!="")
      document.getElementById("optPolicyEnabled").checked = true;
	
	ClearTempData();
}
function ClearTempData()
{
   var TempDataFrame = window.parent.frames["TempDataFrame"];
   var lstSelectedTemplate = TempDataFrame.document.getElementById("TempSelectedTemplateId");
   if(null !=lstSelectedTemplate.options)
   {
      var iLength = lstSelectedTemplate.options.length;
      for(var i=iLength-1;i>-1;i--)
	    lstSelectedTemplate.remove(i);
   }
   TempDataFrame.document.getElementById("TempExceptions").value = "";
   TempDataFrame.document.getElementById("TempDelExceptionIds").value = "";
   TempDataFrame.document.getElementById("TempAction").value = "";
   TempDataFrame.document.getElementById("TempchkNotify").value = "";
   TempDataFrame.document.getElementById("TempchkAdmin").value = "";
   TempDataFrame.document.getElementById("TempAdminTo").value = "";
   TempDataFrame.document.getElementById("TempAdminSubject").value ="";
   TempDataFrame.document.getElementById("TempAdminMsg").value ="";
   TempDataFrame.document.getElementById("TempchkSNMP").value = "";
   TempDataFrame.document.getElementById("TempSNMPIP").value ="";
   TempDataFrame.document.getElementById("TempSNMPCommunity").value = "";
   TempDataFrame.document.getElementById("TempSNMPMsg").value = "";
   TempDataFrame.document.getElementById("TempchkEventLog").value = "";
   TempDataFrame.document.getElementById("TempName").value = "";
   TempDataFrame.document.getElementById("TempDesc").value = "";
   TempDataFrame.document.getElementById("TempOrder").value = "";
   TempDataFrame.document.getElementById("TempEnable").value="";
   TempDataFrame.document.getElementById("TempSendPeriod").value="";
   TempDataFrame.document.getElementById("TempSendOption").value="";
   TempDataFrame.document.getElementById("TempEditTemplateId").value = "";
}
function jsRemoveTemplate() {
	setUIDelfromList(document.fmMain.lstSelectedTemplate);
	document.getElementById("lstSelectedTemplate").style.width = null;
	setListboxUI(document.getElementById("lstSelectedTemplate"),document.getElementById("divSelectedTemplateInner"),document.getElementById("divSelectedTemplateOuter"));
}

function jsImportTemplate() {
	var rv = window.open("$$IMPORT_DLP_TEMPLATE_LIST_PAGE$$","CF_Import","width=600,height=250");
	rv.opener = self;
}

function jsImportCGI(importAvailTemplate,importAvailTemplateDesc)
{
	 var objAvailTemp = document.getElementById("lstAvailableTemplate");
     var objAvailTempDesc = document.getElementById("lstTemplateDes");
	 setOption2Selected(objAvailTemp);
	 setUIDelfromList(objAvailTemp);
	 setOption2Selected(objAvailTempDesc);
	 setUIDelfromList(objAvailTempDesc);
	 for(var i=0;i<importAvailTemplate.options.length;i++)
	 {
		setUIAddItemWithValueNoSort(importAvailTemplate.options[i].text,importAvailTemplate.options[i].value,objAvailTemp);	 
	    var desc = importAvailTemplateDesc.options[i].value;
		//if desc is emply, function setUIAddItemWithIndex wiil not add this option
		if(desc=="")
		   desc=" ";  
		setUIAddItemWithIndex(i,desc, objAvailTempDesc);
	 }
	setListboxUI(document.getElementById("lstAvailableTemplate"),document.getElementById("divAvailableTemplateInner"),document.getElementById("divAvailableTemplateOuter"));
}
function jsAddListItem(){
    var insertKeyword;
	var existKeywordNum = 0;
    for (var i=0;i<1000;i++) {
		if(vLoopCount == vTemp.length) break;
		if (!checkNumberRange(document.fmMain.lstKeyword.length+1,INT_NMAX_CF_KEYWORD,INT_NMIN_CF_KEYWORD,STR_WARN_CF_KEYWORD,false))
		{
		    vLoopCount = vTemp.length;
		    break;
		}
		insertKeyword = setTrim(vTemp[i]);
		if(insertKeyword.length > INT_LMAX_CF_KEYWORD){
		    alert(STR_WARN_CF_KEYWORD);
		    vLoopCount = vTemp.length;
		    break;
		}
		
		var exist=0;         //used to check whether the keyword is already in the list 
		for(var j=0;j<document.fmMain.lstKeyword.length;j++)
		{
		    if(insertKeyword==document.fmMain.lstKeyword.options[j].value)
		    {    exist=1;
			     existKeywordNum++;
		    }
     	}
	
		if(exist==0)
		{
		    insertSynonym = setTrim(vSynonymTemp[i]);
		    if(insertKeyword.length > INT_LMAX_CF_KEYWORD){
		        alert(STR_WARN_CF_KEYWORD);
		        vLoopCount = vTemp.length;
		        break;
		    }	
            var lstMatchLen=document.fmMain.lstMatch.length;
            var  index=setUIAddItem(insertSynonym, document.fmMain.lstMatch);
		    document.getElementById("lstKeyword").style.width = null;
		    if(document.fmMain.lstMatch.length!=lstMatchLen)
		        setUIAddItemWithIndex(index,insertKeyword,document.fmMain.lstKeyword);
			else 
                existKeywordNum++;   //keyword has exist			
		}
		
		vLoopCount++;
	}
	
	if(vLoopCount < vTemp.length){
	    id_setTimeOut = window.setTimeout("jsAddListItem()",30);
	}
	else{
	    clearTimeout(id_setTimeOut);
	    vTemp = null;
	    vLoopCount = 0;
	    setListboxUI(document.getElementById("lstKeyword"),document.getElementById("lstKeywordInner"),document.getElementById("lstKeywordOuter"));
	    jsHideImportMask();
	}
	if(existKeywordNum!=0)
	  alert(STR_WARN_KEYWORD_EXIST_IMPORT);
}
function jsShowImportMask(){
    var oDiv = document.getElementById("import_mask");
    
    if(vBrowser == "IE"){
        document.fmMain.lstAvailableTemplate.style.display = "none";
        oDiv.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='images/opaque.png');";
    } 
    else{oDiv.style.background = "url(images/opaque.png)";}
    
    oDiv.style.width = (window.innerWidth)?window.innerWidth:document.body.clientWidth;
    oDiv.style.height = (window.innerHeight)?window.innerHeight:document.body.clientHeight;
    document.getElementById("import_wording").style.display = ""; 
}

function jsHideImportMask(){
    var oDiv = document.getElementById("import_mask");
    document.getElementById("import_wording").style.display = "none";
    oDiv.style.width = 0;
    oDiv.style.height = 0;
    document.fmMain.lstAvailableTemplate.style.display = ""; 
}
function jsChangeTemplate() 
{	
   var lstAvailTemplate = document.getElementById("lstAvailableTemplate");
   var lstTempDesc = document.getElementById("lstTemplateDes");
   var iLength = lstAvailTemplate.options.length;
   for(var i = 0;i<iLength;i++)
   {
      if(lstAvailTemplate.options[i].selected)
	  {
	     //document.getElementById("tdTemplateDes").innerHTML = lstTempDesc.options[i].value;
		 document.getElementById("tdTemplateDes").innerHTML = (lstTempDesc.options[i].value).replace(/<(.+?)>/gi,"&lt;$1&gt;");
		 break;
      }
   }
}
//for step 2
function jsAddException()
{
    gExcetpionOperate = OPER_ADD;
    addExceptionIndex = objRule.AddException();
    currentEditException = objRule.getException(addExceptionIndex);
    
    TmCube_Tree.isPolicyTree = true;
    TmCube_Tree.onload(); //initialize the site tree
    jsShowSpecifySites();
}
function jsChgRate(nRate,nIndex)
{
   if(nRate == "All"){nRate = objRule.length();}
   document.fmMain.optRecordPerPage.options[nIndex].selected = true;
   vRecordPerPage = nRate;
   jsPage(1); 
}
function jsShowSpecifySites()
{
    HideAllPage();
    //Hide step navigation
   // var stepNav = document.getElementById("stepNav");
   // stepNav.style.display = "none";
   for (var t=1; t<= N_TOTALSTEP; t++)
    {        
        if (t == 2)
        {
            var step2 =  document.getElementById("step2");
            var _step2 = document.getElementById("_step2");
             step2.style.display = "none";
            _step2.style.display = "none";       
        }
        else
        {
            var _step_n = document.getElementById("_step" + t);
            _step_n.style.display = "";
        }
    }
    
     var step2a =  document.getElementById("step2a");
     var _step2a =  document.getElementById("_step2a");
      var _step2b =  document.getElementById("_step2b");
       var step2b =  document.getElementById("step2b");
     step2a.style.display = "";
     _step2b.style.display = ""; 
     _step2a.style.display = "none"; 
     step2b.style.display = "none";  
    //Hide add Policy button
    var addPolicyButton = document.getElementById("addPolicyButton");
    addPolicyButton.style.display = "none";

    //change subTitle
    var subTitle_newPolicy = document.getElementById("subTitle_newPolicy");
    var subTitle_specifySites = document.getElementById("subTitle_specifySites");
    var subTitle_specifyAccounts = document.getElementById("subTitle_specifyAccounts");
    subTitle_newPolicy.style.display = "none";
    subTitle_specifyAccounts.style.display = "none";
    subTitle_specifySites.style.display = "";

    //hidden add Exception button
    var addExceptionButton = document.getElementById("addExceptionButton");
    addExceptionButton.style.display = "none";//show page
    var specifyAccounts = document.getElementById("specifyAccounts");
    var specifySites = document.getElementById("specifySites");
    specifySites.style.display = "";
    specifyAccounts.style.display = "none";

    //show add/edit Exception button
    if(gExcetpionOperate == OPER_ADD)
    {
        var addExceptionButton = document.getElementById("addExceptionButton");
        addExceptionButton.style.display = "";
        var backButton = document.getElementById("exception_backButton");
        var submitButton = document.getElementById("exception_submitButton");
        var nextButton = document.getElementById("exception_nextButton");
        backButton.disabled = true;
        submitButton.style.display = "none";
        nextButton.style.display = "";
    }
    if(gExcetpionOperate == OPER_EDIT)
    {
        //show edit Exception button
        var editExceptionButton = document.getElementById("editExceptionButton");
        editExceptionButton.style.display = "";

        var editBackButton = document.getElementById("editBackButton");
        var editSubmitButton = document.getElementById("editSubmitButton");
        var editNextButton = document.getElementById("editNextButton");
        editBackButton.disabled = true;
        editSubmitButton.style.display = "none";
        editNextButton.style.display = "";
    }
}
function jsShowSpecifyAccounts()
{
 // Is any site to specify account
    var objAnysite = document.getElementsByName("rdAnysite");
    var bIsAnysite = objAnysite[0].checked;
    
    var ftADAccount = document.getElementById("ftADAccount");
    var lstSearchType = document.getElementById("lstSearchType");
    
    if(bIsAnysite) //only show ad search
    {        
        ftADAccount.style.display = "";
        lstSearchType.style.display = "none";

        if (!gbLastIsAnySiteToAccount && gstrLastSiteId!="")
        {
            if (confirm(STR_CONFIRM_ALL_SITE))
            {clearSPAccountSelected();}
            else return;
        }
    }
    else  //show ad & sp search
    {
        if(TmCube_Tree.currentSiteId == "")
        {
            alert(STR_ALERT_EXCEPTION_NO_SITE);
            return;
        }
        if(TmCube_Tree.currentSiteId != gstrLastSiteId)
        {
            clearSPAccountSelected();
        }
        ftADAccount.style.display = "none";
        lstSearchType.style.display = "";
    }
    gbLastIsAnySiteToAccount = bIsAnysite;
    gstrLastSiteId = TmCube_Tree.currentSiteId;

    
    HideAllPage();
    //Hide step navigation
 //   var stepNav = document.getElementById("stepNav");
  //  stepNav.style.display = "none";
      for (var t=1; t<= N_TOTALSTEP; t++)
    {        
        if (t == 2)
        {
            var step2 =  document.getElementById("step2");
            var _step2 = document.getElementById("_step2");
             var step2a =  document.getElementById("step2a");
            var _step2a = document.getElementById("_step2a");
             step2.style.display = "none";
            _step2.style.display = "none"; 
             step2a.style.display = "none";
            _step2a.style.display = "";        
        }
        else
        {
            var _step_n = document.getElementById("_step" + t);
            _step_n.style.display = "";
        }
    }  
     var step2b =  document.getElementById("step2b");
      var _step2b =  document.getElementById("_step2b");
     step2b.style.display ="";
     _step2b.style.display ="none";
    //Hide add Policy button
    var addPolicyButton = document.getElementById("addPolicyButton");
    addPolicyButton.style.display = "none";

    //change subTitle
    var subTitle_newPolicy = document.getElementById("subTitle_newPolicy");
    var subTitle_specifySites = document.getElementById("subTitle_specifySites");
    var subTitle_specifyAccounts = document.getElementById("subTitle_specifyAccounts");
    subTitle_newPolicy.style.display = "none";
    subTitle_specifyAccounts.style.display = "";
    subTitle_specifySites.style.display = "none";

    //show page
    var specifyAccounts = document.getElementById("specifyAccounts");
    var specifySites = document.getElementById("specifySites");
    specifySites.style.display = "none";
    specifyAccounts.style.display = "";

    //show add/edit Exception button
    if(gExcetpionOperate == OPER_ADD)
    {
        var addExceptionButton = document.getElementById("addExceptionButton");
        addExceptionButton.style.display = "";
        var backButton = document.getElementById("exception_backButton");
        var submitButton = document.getElementById("exception_submitButton");
        var nextButton = document.getElementById("exception_nextButton");
        backButton.disabled = false;
        submitButton.style.display = "";
        nextButton.style.display = "none";
    }
    if(gExcetpionOperate == OPER_EDIT)
    {
        //show edit Exception button
        var editExceptionButton = document.getElementById("editExceptionButton");
        editExceptionButton.style.display = "";

        var editBackButton = document.getElementById("editBackButton");
        var editSubmitButton = document.getElementById("editSubmitButton");
        var editNextButton = document.getElementById("editNextButton");
        editBackButton.disabled = false;
        editSubmitButton.style.display = "";
        editNextButton.style.display = "none";
    }

   setListboxUI(document.getElementById("lstAvailableAccount"),document.getElementById("divAvailableAccountInner"),document.getElementById("divAvailableAccountOuter"));
   setListboxUI(document.getElementById("lstSelectedAccount"),document.getElementById("divSelectedAccountInner"),document.getElementById("divSelectedAccountOuter"));

}
function jsAddExceptionFinished()
{
     // Save Account
    var strAccountDisplayOld = currentEditException.strAccountDisplay;
    var strAccountGuidsOld = currentEditException.strAccountGuids;
    getAccountResult(currentEditException);
    if(currentEditException.strAccountGuids == "")
    {
        // Rollback
        currentEditException.strAccountDisplay = strAccountDisplayOld;
        currentEditException.strAccountGuids = strAccountGuidsOld;
        alert(STR_ALERT_EXCEPTION_NO_ACCOUNT);
        return;
    }

    gbLastIsAnySiteToAccount = false;
    gstrLastSiteId = "";
    gExcetpionOperate = "";
    
    var objException = currentEditException;
    
    getTreeResult(objException);           //.........
    
    clearSpecialSitesPage();               //.........
    clearSpecialAccountPage();             //.........
    
    //show step navigation
  //  var stepNav = document.getElementById("stepNav");
  //  stepNav.style.display = "";
     var step2 =  document.getElementById("step2");
      var _step2b = document.getElementById("_step2b");
      var step2b=  document.getElementById("step2b");
      var step2a =  document.getElementById("step2a");
      var _step2a = document.getElementById("_step2a");
       step2.style.display = "";
       _step2a.style.display = "none"; 
       step2a.style.display = "none";
        _step2b.style.display = "none";
        step2b.style.display = "none";
    //show add Policy button
    var addPolicyButton = document.getElementById("addPolicyButton");
    addPolicyButton.style.display = "";

    //change subTitle
    var subTitle_newPolicy = document.getElementById("subTitle_newPolicy");
    var subTitle_specifySites = document.getElementById("subTitle_specifySites");
    var subTitle_specifyAccounts = document.getElementById("subTitle_specifyAccounts");
    subTitle_newPolicy.style.display = "";
    subTitle_specifyAccounts.style.display = "none";
    subTitle_specifySites.style.display = "none";
    //Hide page
    var specifyAccounts = document.getElementById("specifyAccounts");
    var specifySites = document.getElementById("specifySites");
    specifySites.style.display = "none";
    specifyAccounts.style.display = "none";

    //Hide add Exception button
    var addExceptionButton = document.getElementById("addExceptionButton");
    addExceptionButton.style.display = "none";


    jsPage(1);
    jsShowExceptionStep();
}
function jsAddExceptionCanceled()
{
    gbLastIsAnySiteToAccount = false;
    gstrLastSiteId = "";
    gExcetpionOperate = "";

    objRule.RemoveException(addExceptionIndex);
    currentEditException = null;
    
    clearSpecialSitesPage();               //.........
    clearSpecialAccountPage();             //.........

    //show step navigation
 //   var stepNav = document.getElementById("stepNav");
 //   stepNav.style.display = "";
     var step2 =  document.getElementById("step2");
      var _step2b = document.getElementById("_step2b");
      var step2b=  document.getElementById("step2b");
      var step2a =  document.getElementById("step2a");
      var _step2a = document.getElementById("_step2a");
       step2.style.display = "";
       _step2a.style.display = "none"; 
       step2a.style.display = "none";
        _step2b.style.display = "none";
        step2b.style.display = "none"; 
    //show add Policy button
    var addPolicyButton = document.getElementById("addPolicyButton");
    addPolicyButton.style.display = "";

    //change subTitle
    var subTitle_newPolicy = document.getElementById("subTitle_newPolicy");
    var subTitle_specifySites = document.getElementById("subTitle_specifySites");
    var subTitle_specifyAccounts = document.getElementById("subTitle_specifyAccounts");
    subTitle_newPolicy.style.display = "";
    subTitle_specifyAccounts.style.display = "none";
    subTitle_specifySites.style.display = "none";
    //Hide page
    var specifyAccounts = document.getElementById("specifyAccounts");
    var specifySites = document.getElementById("specifySites");
    specifySites.style.display = "none";
    specifyAccounts.style.display = "none";

    //Hide add Exception button
    var addExceptionButton = document.getElementById("addExceptionButton");
    addExceptionButton.style.display = "none";

    jsShowExceptionStep();
}
function getTreeResult(objException)
{
    var rdAnysite = document.getElementsByName("rdAnysite");
 
    objException.vcGuidStore = new Array; //clearn the result;
    if (rdAnysite[0].checked)
    {
        objException.vcGuidStore.push(STR_ANYSITE);
        objException.strSiteDisplay = STR_ANYSITE;
    }
    else
    {
        var strDisplay = TmCube_Tree_getTreeResult(objException.vcGuidStore);
        objException.strSiteDisplay = strDisplay;
    }
}
function getAccountResult(objExcetpion)
{
    var strAccountIds = "";         //    32 08478a42db8cf3140a5ff23c95c1aa65f    32 06e27fdf8b64b0647af939fc30b567555
    var strsAccoutDisplay = "";     //testAccount1;testAccount2
    var rdAnyone = document.getElementsByName("rdAnyone");
    if(rdAnyone[0].checked)
    {
        strAccountIds = STR_ANYONE;
        strsAccoutDisplay = STR_ANYONE;
    }
    else
    {
        var lstSelectedAccount = document.getElementById("lstSelectedAccount");

        for (var i=0; i<lstSelectedAccount.options.length; ++i)
        {
            var opt = lstSelectedAccount.options[i];
            strAccountIds += opt.value;
            strsAccoutDisplay += opt.innerText;
            strsAccoutDisplay +=";"
         }
    }
    objExcetpion.strAccountDisplay = strsAccoutDisplay;
    objExcetpion.strAccountGuids = strAccountIds;
    
}
function clearSpecialSitesPage()
{
    var treepanel = document.getElementById("Tree__treepanel");
    treepanel.innerHTML = "";

    var rdAnysite = document.getElementsByName("rdAnysite");
    var objInputSearch = document.getElementById("siteSearchInput");
    
    rdAnysite[1].checked = true;
    objInputSearch.value = "";
    jsAnysiteCheck();
    
}
function clearSPAccountSelected()
{
    var objInputSearch = document.getElementById("txtSearch");
    var lstSearchType = document.getElementById("lstSearchType");
    var lstAvailableAccount = document.getElementById("lstAvailableAccount");
    var lstSelectedAccount =  document.getElementById("lstSelectedAccount");

    objInputSearch.value="";
    lstSearchType.options[0].checked = true;
    
    jsClearList(lstAvailableAccount);
    for (var i=document.getElementById("tabAvailableAccountList").rows.length;i>0;i--) {
		    document.getElementById("tabAvailableAccountList").deleteRow(i-1);
	}

    var i=document.getElementById("tabSelectedAccountList").rows.length;
    while(i>0)
    {

        var objRow = document.getElementById("tabSelectedAccountList").rows[i-1];
        var objCell =  objRow.cells[0];
        var objImg = objCell.getElementsByTagName("img")[0];
        
        if (objImg.src.indexOf("SP_user.gif") !=-1 ||
            objImg.src.indexOf("sp_group.gif") !=-1 ) //ad user group
        {
            lstSelectedAccount.remove(i-1);
            document.getElementById("tabSelectedAccountList").deleteRow(i-1);
        }
        i--;
    }
   //setListboxUI(document.getElementById("lstAvailableAccount"),document.getElementById("divAvailableAccountInner"),document.getElementById("divAvailableAccountOuter"));
   //setListboxUI(document.getElementById("lstSelectedAccount"),document.getElementById("divSelectedAccountInner"),document.getElementById("divSelectedAccountOuter")); 
}

function clearSpecialAccountPage()
{
    var rdAnyone = document.getElementsByName("rdAnyone");
    var objInputSearch = document.getElementById("txtSearch");
    var chkUser = document.getElementById("chkUser");
    var chkGroup = document.getElementById("chkGroup");
    var lstSearchType = document.getElementById("lstSearchType");
    var lstAvailableAccount = document.getElementById("lstAvailableAccount");
    var lstSelectedAccount =  document.getElementById("lstSelectedAccount");

 rdAnyone[1].checked = true;
    objInputSearch.value="";
    chkUser.checked = true;
    chkGroup.checked = true;
    lstSearchType.options[0].checked = true;
    jsClearList(lstAvailableAccount);
    for (var i=document.getElementById("tabAvailableAccountList").rows.length;i>0;i--) {
		    document.getElementById("tabAvailableAccountList").deleteRow(i-1);
	}
    
    jsClearList(lstSelectedAccount);
    for (var i=document.getElementById("tabSelectedAccountList").rows.length;i>0;i--) {
		    document.getElementById("tabSelectedAccountList").deleteRow(i-1);
	}
    
   setListboxUI(document.getElementById("lstAvailableAccount"),document.getElementById("divAvailableAccountInner"),document.getElementById("divAvailableAccountOuter"));
   setListboxUI(document.getElementById("lstSelectedAccount"),document.getElementById("divSelectedAccountInner"),document.getElementById("divSelectedAccountOuter"));
   jsAnyoneCheck(); 
    
}

function jsPage(pageNum)
{
    var nTotalCount = objRule.length();
    var nTotalPage = Math.ceil(nTotalCount/vRecordPerPage);
    if (pageNum == -1|| pageNum > nTotalPage)
        pageNum =  nTotalPage;
	if (pageNum < 1) { pageNum=1; }
	if (!checkNumberRange(pageNum,nTotalPage,1,STR_ERR_INVALID_LOG_PAGE_NUM)){return;}
    nCurrentPage = pageNum;
    var countStart = vRecordPerPage * (nCurrentPage-1) + 1;
    var countEnd = vRecordPerPage * nCurrentPage > nTotalCount ? nTotalCount : vRecordPerPage * nCurrentPage  ;
    //set delete button status
    if (!objRule.hasChecked())
    {
        setUIFunctionLink(false,"cmdDelItem1");
        setUIFunctionLink(false,"cmdDelItem2");
    }
    else 
    {
        setUIFunctionLink(true,"cmdDelItem1");
        setUIFunctionLink(true,"cmdDelItem2");
    }
    if (nTotalCount == 0)
    {
        countStart = 0;
        countEnd = 0;
        nTotalPage = 0;
        nCurrentPage = 0;
    }
    //set countStart, countEnd, nTotalCount, nCurrentPage, nTotalPage to the page
    var labRecordS = document.getElementById("labRecordS1");
    var labRecordE = document.getElementById("labRecordE1");
    var labTotalRec =  document.getElementById("labTotalRec1");
    var txtPageNum = document.getElementById("txtPageNum1");
    var labTotalPage = document.getElementById("labTotalPage1");
    labRecordS.innerText = countStart;
    labRecordE.innerText = countEnd;
    labTotalRec.innerText = nTotalCount;
    txtPageNum.value = nCurrentPage;
    labTotalPage.innerText = nTotalPage;
    labRecordS = document.getElementById("labRecordS2");
    labRecordE = document.getElementById("labRecordE2");
    labTotalRec =  document.getElementById("labTotalRec2");
    txtPageNum = document.getElementById("txtPageNum2");
    labTotalPage = document.getElementById("labTotalPage2");
    labRecordS.innerText = countStart;
    labRecordE.innerText = countEnd;
    labTotalRec.innerText = nTotalCount;
    txtPageNum.value = nCurrentPage;
    labTotalPage.innerText = nTotalPage;
   //show exceptions of current page
    var tableExplist = document.getElementById("tabList");
    clearTable(tableExplist); //clear the exception list table, reserve the head
    var style = "data2b";
    if (countStart <= 0)return;
    for (var i = countStart; i<= countEnd; i++)
    {   
        var objExp = objRule.getException(i -1);
        if(0 == (i % 2))
        {
            style = "data2b";
        }
        else 
        {
            style = "data1b";
        }
        var trExp = tableExplist.insertRow(-1);
        var tdCheck = trExp.insertCell(-1);
        var tdSites = trExp.insertCell(-1);
        
        tdCheck.setAttribute("width","4%");
        TmCube_Tree_setClassName(tdCheck,style);
		var chkAllChecked = true;
        if (objExp.bIsChecked)
        {
            tdCheck.innerHTML = "<input type=\"checkbox\" name=\"chkItems\" value=\""+objExp.id+"\" onclick='jsItem_Check(fmMain.chkSelectAll,\""+objExp.id+"\")' checked >";
        }
        else
        {
		    chkAllChecked = false;
            tdCheck.innerHTML = "<input type=\"checkbox\" name=\"chkItems\" value=\""+objExp.id+"\" onclick='jsItem_Check(fmMain.chkSelectAll,\""+objExp.id+"\");'>";
        }
        fmMain.chkSelectAll.checked = chkAllChecked;	
		TmCube_Tree_setClassName(tdSites, style);
        var sep = (objExp.IsAnySite() ? ";":"");
        tdSites.innerHTML = "<a href=\"javascript:jsEditException('"+objExp.id+"');\">"+wrapStr(objExp.strSiteDisplay,INT_SITE_DISPLAY_LEN)+sep+wrapStr(objExp.strAccountDisplay,INT_ACCOUNT_DISPLAY_LEN)+"</a>";
    }
}
function jsItem_Check(oAll, exceptionId)
{
    objRule.checked(exceptionId);
    oAll.checked = objRule.allChecked();
    jsPage(nCurrentPage);
}

function jsSelectAll()
{
    var bCheckedAll = fmMain.chkSelectAll.checked;
    var exceplength = objRule.length();
	if(exceplength==0)
	  {
	     setUIFunctionLink(false,"cmdDelItem1");
		 setUIFunctionLink(false,"cmdDelItem2");
		 return;
	  }
	var countStart = vRecordPerPage * (nCurrentPage-1);
    var countEnd = vRecordPerPage * nCurrentPage > exceplength ? exceplength : vRecordPerPage * nCurrentPage;
	objRule.checkRange(countStart,countEnd,bCheckedAll);	
    jsPage(nCurrentPage);
}

function jsDelItem()
{
    objRule.actionDelete();
    jsPage(1);
    fmMain.chkSelectAll.checked = false;
}
function jsKeyPressEvent(e,nValue){
    var key = window.event ? e.keyCode : e.which;
    if(key == 13)
        jsPage(nValue);
}
function wrapStr(str, len)
{
    var ret = str;
    if (str.length > len)
        ret = str.substring(0,len-3) + "...";
    return ret;
}
//clear the table data, reserve the head
function clearTable(table)
{
    while(table.rows.length >1)
    {
        var tr = table.rows[1];
        tr.parentNode.removeChild(tr);
    }
}

//for edit exception sites/account
function jsEditException(exceptionId)
{
    gExcetpionOperate = OPER_EDIT;
    currentEditException = objRule.searchException(exceptionId);
    // initialize sites  
    var rdAnysite = document.getElementsByName("rdAnysite");
    if (currentEditException.IsAnySite())
    {   
        gbLastIsAnySiteToAccount = true;
        gstrLastSiteId = "";
        rdAnysite[0].checked = true;
    }
    else
    {
        gbLastIsAnySiteToAccount = false;
        gstrLastSiteId = currentEditException.getCurrentSiteId();
        rdAnysite[1].checked = true;
    }
    jsAnysiteCheck();
    TmCube_Tree.isPolicyTree = true;
    TmCube_Tree.onload(); //initialize the site tree  
    
    // initialize account
    var rdAnyone = document.getElementsByName("rdAnyone");
    if (currentEditException.IsAnyone())
    {   
        rdAnyone[0].checked = true;
    }
    else
    {
        rdAnyone[1].checked = true;
            
        var vecAccountStr = new Array;
        var vecAccountDisplay = new Array;
        currentEditException.getAccountArray(vecAccountStr, vecAccountDisplay);
        var lstExistAccount = document.getElementById("lstExistAccount");
        jsClearList(lstExistAccount);
        for (var i=0; i<vecAccountStr.length && i<vecAccountDisplay.length; i++)
        {
            var strAccount = vecAccountStr[i];
            var strName = vecAccountDisplay[i];
            var strType = setTrim(strAccount.substr(lenLength, lenType));
            lstExistAccount.options[lstExistAccount.options.length] = new Option(strName, parseInt(strType) + "\t" + strAccount);
        }
        jsAddExistAccount();
    }
    jsAnyoneCheck();


    jsShowSpecifySites();
}


function jsEditExceptionFinished()
{
     // Save Account
    var strAccountDisplayOld = currentEditException.strAccountDisplay;
    var strAccountGuidsOld = currentEditException.strAccountGuids;
    getAccountResult(currentEditException);
    if(currentEditException.strAccountGuids == "")
    {
        // Rollback
        currentEditException.strAccountDisplay = strAccountDisplayOld;
        currentEditException.strAccountGuids = strAccountGuidsOld;
        alert(STR_ALERT_EXCEPTION_NO_ACCOUNT);
        return;
    }
     
    gbLastIsAnySiteToAccount = false;
    gstrLastSiteId = "";
    gExcetpionOperate = "";

    // Save Site
    getTreeResult(currentEditException);
    
    
    currentEditException = null; 
    
    //show step navigation
     var step2 =  document.getElementById("step2");
      var _step2b = document.getElementById("_step2b");
      var step2b=  document.getElementById("step2b");
      var step2a =  document.getElementById("step2a");
      var _step2a = document.getElementById("_step2a");
       step2.style.display = "";
       _step2a.style.display = "none"; 
       step2a.style.display = "none";
        _step2b.style.display = "none";
        step2b.style.display = "none";

    //show add Policy button
    var addPolicyButton = document.getElementById("addPolicyButton");
    addPolicyButton.style.display = "";

    //change subTitle
    var subTitle_newPolicy = document.getElementById("subTitle_newPolicy");
    var subTitle_specifySites = document.getElementById("subTitle_specifySites");
    var subTitle_specifyAccounts = document.getElementById("subTitle_specifyAccounts");
    var subTitle_editSites = document.getElementById("subTitle_editSites");
    var subTitle_editAccounts = document.getElementById("subTitle_editAccounts");
    subTitle_newPolicy.style.display = "";
    subTitle_specifyAccounts.style.display = "none";
    subTitle_specifySites.style.display = "none";
    subTitle_editSites.style.display = "none";
    subTitle_editAccounts.style.display = "none";

    //Hide page
    var specifyAccounts = document.getElementById("specifyAccounts");
    var specifySites = document.getElementById("specifySites");
    specifySites.style.display = "none";
    specifyAccounts.style.display = "none";

    //Hide edit Exception button
    var addExceptionButton = document.getElementById("editExceptionButton");
    addExceptionButton.style.display = "none";

    //show add Policy button
    var addPolicyButton = document.getElementById("addPolicyButton");
    addPolicyButton.style.display = "";
    
    clearSpecialSitesPage();               //.........
    clearSpecialAccountPage(); 
    jsPage(1);
    jsShowExceptionStep();
}

function jsEditExceptionCancel()
{
    currentEditException = null; 

    gbLastIsAnySiteToAccount = false;
    gstrLastSiteId = "";
    gExcetpionOperate = "";
      
    
    //show step navigation
    var step2 =  document.getElementById("step2");
      var _step2b = document.getElementById("_step2b");
      var step2b=  document.getElementById("step2b");
      var step2a =  document.getElementById("step2a");
      var _step2a = document.getElementById("_step2a");
       step2.style.display = "";
       _step2a.style.display = "none"; 
       step2a.style.display = "none";
        _step2b.style.display = "none";
        step2b.style.display = "none"; 

    //show add Policy button
    var addPolicyButton = document.getElementById("addPolicyButton");
    addPolicyButton.style.display = "";

    //change subTitle
    var subTitle_newPolicy = document.getElementById("subTitle_newPolicy");
    var subTitle_specifySites = document.getElementById("subTitle_specifySites");
    var subTitle_specifyAccounts = document.getElementById("subTitle_specifyAccounts");
    var subTitle_editSites = document.getElementById("subTitle_editSites");
    var subTitle_editAccounts = document.getElementById("subTitle_editAccounts");
    subTitle_newPolicy.style.display = "";
    subTitle_specifyAccounts.style.display = "none";
    subTitle_specifySites.style.display = "none";
    subTitle_editSites.style.display = "none";
    subTitle_editAccounts.style.display = "none";

    //Hide page
    var specifyAccounts = document.getElementById("specifyAccounts");
    var specifySites = document.getElementById("specifySites");
    specifySites.style.display = "none";
    specifyAccounts.style.display = "none";

    //Hide edit Exception button
    var addExceptionButton = document.getElementById("editExceptionButton");
    addExceptionButton.style.display = "none";

    //show add Policy button
    var addPolicyButton = document.getElementById("addPolicyButton");
    addPolicyButton.style.display = "";
    
    clearSpecialSitesPage();            
    clearSpecialAccountPage();             

    jsPage(1);
    jsShowExceptionStep();
}

function jsSearchSite(inputId)
{
    var str=document.getElementById(inputId).value;
    TmCube_Tree_UrlSearch(str);
}
/*
function jsAllSite(bflag)
{
    TmCube_Tree_Enable(bflag);
    document.getElementById('btnSearchSite').disabled = bflag;
    document.getElementById('siteSearchInput').disabled = bflag;
}
*/
//step4 notification page
function jsUIDependency()
{
	 //Violator Notification
	 if(!bIsRealTime)
	 {
	    document.getElementById("txtNotifyViolatorSubject").disabled = (!document.getElementById("chkNotifyViolator").checked);
	    document.getElementById("optViolatorMessageType").disabled = (!document.getElementById("chkNotifyViolator").checked);
	    document.getElementById("txtNotifyViolatorMessage").disabled = (!document.getElementById("chkNotifyViolator").checked);
	 }
	//Administrator Notification
	document.getElementById("txtNotifyAdminTo1").disabled = (!document.getElementById("chkNotifyAdmin").checked);
	document.getElementById("txtNotifyAdminSubject").disabled = (!document.getElementById("chkNotifyAdmin").checked);
	document.getElementById("optAdminMessageType").disabled = (!document.getElementById("chkNotifyAdmin").checked);
	document.getElementById("txtNotifyAdminMessage").disabled = (!document.getElementById("chkNotifyAdmin").checked);
	var settingRadio = document.getElementsByName("optNotifyAdminSettings");
	for(var i = 0;i<settingRadio.length;i++)
	    settingRadio[i].disabled= (!document.getElementById("chkNotifyAdmin").checked);	
	document.getElementById("txtNotifyAdminSettingsPeriod").disabled = (!document.getElementById("chkNotifyAdmin").checked);
	document.getElementById("optNotifyAdminSettingsPeriodUnit").disabled = (!document.getElementById("chkNotifyAdmin").checked);
	document.getElementById("txtNotifyAdminSettingsOccurence").disabled = (!document.getElementById("chkNotifyAdmin").checked);
	//SNMP Notification
	document.getElementById("txtSNMPIP").disabled = (!document.getElementById("chkNotifySNMP").checked);
	document.getElementById("txtSNMPCommunity").disabled = (!document.getElementById("chkNotifySNMP").checked);
	document.getElementById("optSNMPMessageType").disabled = (!document.getElementById("chkNotifySNMP").checked);
	document.getElementById("txtSNMPMessage").disabled =!document.getElementById("chkNotifySNMP").checked ;  
}
function jsshowToolTip(ttFrame,ttObject,ttWidth,ttHeight,ttTitle,ttContent){
		showToolTip(ttFrame,ttObject,ttWidth,ttHeight,ttTitle,ttContent);	
}
// For account search
function jsAddSelectedAccount() {
    var oSourceList = document.getElementById("lstAvailableAccount");
    var oList = document.getElementById("lstSelectedAccount");
    var oTable = document.getElementById("tabSelectedAccountList");

	var nCount = 0;
	for (var i=0;i<oSourceList.options.length;i++) {
		if (oSourceList.options[i].selected) 
		{
		    nCount++;
		    for(var j=0;j<oList.options.length;j++)
		    {
		       var LItem = oList.options[j].value.split(String.fromCharCode(9));
		       var SItem = oSourceList.options[i].value.split(String.fromCharCode(9));
		       var Lguid=LItem[1];
		       var Sguid=SItem[1];
		       if(Lguid==Sguid)
		       {   
		           oSourceList.options[i].selected=false;
		       }
		    }
		}
	}
	if (nCount==0) return;
	
	for (i=0;i<oSourceList.options.length;i++) {
		if (oSourceList.options[i].selected) 
		{
		   jsAddItemOnce(oList,oTable,oSourceList.options[i].value);
		}
	}
    setListboxUI(document.getElementById("lstAvailableAccount"),document.getElementById("divAvailableAccountInner"),document.getElementById("divAvailableAccountOuter"));
    setListboxUI(document.getElementById("lstSelectedAccount"),document.getElementById("divSelectedAccountInner"),document.getElementById("divSelectedAccountOuter"));

}

function jsRemoveSelectedAccount()
{
   jsRemove();
   setListboxUI(document.getElementById("lstSelectedAccount"),document.getElementById("divSelectedAccountInner"),document.getElementById("divSelectedAccountOuter"));
}
function jsRemove()
{
    var oList = document.getElementById("lstSelectedAccount");
    var oTable = document.getElementById("tabSelectedAccountList");

    for (var i=0;i<oList.options.length;i++) 
	{
		if (oList.options[i].selected)
		{
			oList.remove(i);
			oTable.deleteRow(i);
		//    setListboxUI(document.getElementById("lstSelectedAccount"),document.getElementById("divSelectedAccountInner"),document.getElementById("divSelectedAccountOuter"));

            jsRemove();
		}
	}
   
}

function jsSearchAccount(txtKeyword) {
    var strKeyword = document.getElementById(txtKeyword).value;	
	document.getElementById("btnSearchAccount").disabled = true;
    var bUser = document.getElementById("chkUser").checked;
    var bGroup = document.getElementById("chkGroup").checked;
    if (!bUser &&  !bGroup) 
    {
        alert(STR_ALERT_SEARCHACCOUNT_NO_TYPE);
       	document.getElementById("btnSearchAccount").disabled = false;
        return;
    }
    var searchType = document.getElementById("lstSearchType").value;
    if(searchType == "1") //search AD
    {
        ifmAccount.jsGetAccount(strKeyword, bUser, bGroup);
    }
    else
    {
         ifmAccount.jsGetAccount(strKeyword, 0, 0, bUser, bGroup, TmCube_Tree.currentSiteId);
    }
}

function jsAddSearch() {
	if (window.ifmAccount.document.fmMain.txtResultCount.value > INT_NMAX_SEARCH_RESULT) {
		alert(STR_WARN_SEARCH_RESULT_OVER);
		window.ifmAccount.document.fmMain.lstResult.options.length = INT_NMAX_SEARCH_RESULT;
	}
	//alert(window.ifmAccount.document.fmMain.txtResultCount.value);
	// empty the list box
	document.getElementById("btnSearchAccount").disabled = false;
	jsClearList(document.getElementById("lstAvailableAccount"));
	
    for (var i=document.getElementById("tabAvailableAccountList").rows.length;i>0;i--) {
		    document.getElementById("tabAvailableAccountList").deleteRow(i-1);
	}
	document.getElementById("lstAvailableAccount").style.width = "";
	document.getElementById("lstAvailableAccount").style.height= "";
    	
	// Add Search List, [NAME][GUID][TYPE]
	var vItem;
	var vTemp;
	var vIndex;
    var sDetail="";

	for (var i=0;i<window.ifmAccount.document.fmMain.lstResult.options.length;i++) {
		vTemp = window.ifmAccount.document.fmMain.lstResult.options[i].value;
		vItem = vTemp.split(String.fromCharCode(9));
		var vName = vItem[0];
        
		vIndex = setUIAddItemWithValue(vName,vTemp,document.getElementById("lstAvailableAccount"));
		sDetail = setHTMLString(sDetail);
		switch(vItem[2])                                       //Account type:ad user,ad group,special group,smtp address
		{
		     case "0":
		       vTemp= "<img src='images/ad_user.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
		       break;
		    case "1":
		       vTemp = "<img src='images/ad_group.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
		       break;
		    case "2":case "4":
		       vTemp= "<img src='images/SP_user.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
               break;
            case "3":
		       vTemp= "<img src='images/sp_group.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
		       break;
		}
		insertTableRowByIndex(document.getElementById("tabAvailableAccountList"),vTemp,"",vIndex);
	}
	//jsContactListUI(document.getElementById("lst"+oSearchlocal),document.getElementById("div"+oSearchlocal),document.getElementById("div"+oSearchlocal+"List"));
    setListboxUI(document.getElementById("lstAvailableAccount"),document.getElementById("divAvailableAccountInner"),document.getElementById("divAvailableAccountOuter"));
}
function insertTableRowByIndex(oTable,sText,sValue,nIndex) {
	if (oTable == null || sText == "" || nIndex < 0) { return; }
	
	var oRow = oTable.insertRow(nIndex);
	var oCell = oRow.insertCell(0);
	oCell.className = "listNormal";
	oCell.innerHTML = sText;
	oCell.title = sValue;
}
// like "    32 08478a42db8cf3140a5ff23c95c1aa65f"
function joinAccountString(vtype,vguid)
{
    var iLen = vguid.length;
    var retValue="";
        
    //the first 6 bytes used to recode the lenght of each item.   
	var nLen=iLen;
	var j=0;
    if (nLen == 0)j =1;
    else
    {
	    while(parseInt(nLen)/10!=0) 
        {
            nLen=parseInt(nLen)/10;
            j++;
        }
    }
    for(;j<lenLength;j++)       
        retValue+=" ";
    retValue+=iLen;
    
    j=0;
    nLen = vtype;
    if (nLen == 0)j =1;
    else
    {
	    while(parseInt(nLen)/10!=0) 
        {
            nLen=parseInt(nLen)/10;
            j++;
        }
    }
    for(;j<lenType;j++)       
        retValue+=" ";
    retValue+=vtype;

    retValue+=vguid;
    return retValue; 
}
function jsAddItemOnce(oList, oTable, ItemValue)
{
    var vItem;
    var vTemp;
    var vIndex;
    var sDetail="";
    
    vTemp = ItemValue;
    vItem = vTemp.split(String.fromCharCode(9));
    var vName = vItem[0];
	var vGuid = vItem[1];
    var vType = vItem[2];
    var vValue = joinAccountString(vType,vGuid);
    vIndex = setUIAddItemWithValue(vName,vValue,oList);
   
    sDetail = setHTMLString(sDetail);
    switch(vItem[2])                                       //Account type:ad user,ad group,special group,smtp address
	{
	    case "0":
	       vTemp = "<img src='images/ad_user.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>"; // \"Detail\",\""+sDetail+"\");'> ";
	       break;
	    case "1":
	       vTemp = "<img src='images/ad_group.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>"; // \"Detail\",\""+sDetail+"\");'> ";
	       break;
	    case "2":case "4":
		       vTemp= "<img src='images/SP_user.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
               break;
        case "3":
		       vTemp= "<img src='images/sp_group.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
		       break;
	} 
    insertTableRowByIndex(oTable,vTemp,"",vIndex); 

}
function jsClearList(oTarget) {
	// Clear List
	for (var i=oTarget.length;i>0;i--) {
		oTarget.remove(i-1);
	}
}
function jsAnysiteCheck()
{
    var objAnysite = document.getElementsByName("rdAnysite");
    
    var inputSearch = document.getElementById("siteSearchInput");
    var btnSearchSite = document.getElementById("btnSearchSite"); 
    if(objAnysite[0].checked)
    {
        btnSearchSite.disabled = true;
        inputSearch.disabled = true;
        TmCube_Tree.disabled = true;
    }
    else
    {
        btnSearchSite.disabled = false;
        inputSearch.disabled = false;
        TmCube_Tree.disabled = false;
    }
}
function jsAnyoneCheck()
{
    var objAnyone = document.getElementsByName("rdAnyone");
    var tableAnyone = document.getElementById("tabAnyone");
    var btnSearchAccount = document.getElementById("btnSearchAccount");
    var btnAddAccount = document.getElementById("btnAddAccount");
    var btnRemoveAccount = document.getElementById("btnRemoveAccount");
    var lstAvailableAccount = document.getElementById("lstAvailableAccount");
    var lstSelectedAccount = document.getElementById("lstSelectedAccount");
    var inputSearch = document.getElementById("txtSearch"); 
    if(objAnyone[0].checked)
    {
        btnSearchAccount.disabled = true;    
        tableAnyone.disabled = true;    
        btnAddAccount.disabled = true;    
        btnRemoveAccount.disabled = true;    
        lstAvailableAccount.disabled = true;    
        lstSelectedAccount.disabled = true;    
        inputSearch.disabled = true;    
    }
    else
    {
        btnSearchAccount.disabled = false;    
        tableAnyone.disabled = false;    
        btnAddAccount.disabled = false;    
        btnRemoveAccount.disabled = false;    
        lstAvailableAccount.disabled = false;    
        lstSelectedAccount.disabled = false;
        inputSearch.disabled = false;
    }
}
function jsAddExistAccount()
{
    var srcList = document.getElementById("lstExistAccount");
    var sDetail="";
	for (var i=0;i<srcList.options.length;i++) {
		vTemp = srcList.options[i].value;    //type\tAccountstring
		vItem = vTemp.split(String.fromCharCode(9));
		var vName = srcList.options[i].innerText;
        var vValue = vItem[1];
		vIndex = setUIAddItemWithValue(vName,vValue,document.getElementById("lstSelectedAccount"));
		
        sDetail = setHTMLString(sDetail);
		switch(vItem[0])                                       //Account type:ad user,ad group,special group,smtp address
		{
		     case "0":
		       vTemp= "<img src='images/ad_user.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
		       break;
		    case "1":
		       vTemp = "<img src='images/ad_group.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
		       break;
		    case "2":case "4":
		       vTemp= "<img src='images/SP_user.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
               break;
        case "3":
		       vTemp= "<img src='images/sp_group.gif' onmouseout='hideToolTip(\"ifmToolTip\");' onmouseover='showToolTip1(event,\"ifmToolTip\",300,100,\"Detail\",\"\");'>";//\"Detail\",\""+sDetail+"\");'> ";
		       break;
		}
		insertTableRowByIndex(document.getElementById("tabSelectedAccountList"),vTemp,"",vIndex);
    }
    
}
function jsRefresh()
{
   TmCube_Tree.isPolicyTree = true;
    TmCube_Tree.onload();
}

function jsOpenOnlineHelp()
{
	var helppage="";
	if (!bIsRealTime) 
	{		
		if(window.location.search.indexOf("&",window.location.search.indexOf("Subject=")+8)>-1)
		{
			winSubject = window.location.search.substring((window.location.search.indexOf("Subject=")+8),window.location.search.indexOf("&",window.location.search.indexOf("Subject=")+8));
		}
		else
		{
			winSubject = window.location.search.substring((window.location.search.indexOf("Subject=")+8),window.location.search.length);
		}
				
		if (winSubject.indexOf("SS") > 0)
		{
			switch(nStep)                                       
			{
				case 1:
				   helppage="Step-1_-Specify-Rule_001.html";
				   break;
				case 2:
				   helppage="Step-2_-Exceptions-(.html";
				   break;
				case 3:
				   helppage="Step-3_-Specify-Acti_001.html";
				   break;
				case 4:
				   helppage="Step-4_-Specify-Noti_001.html";
				   break;
				case 5:
				   helppage="Step-5_-Name-and-Pri_001.html";
				   break;
			}
		}
		else		
		{
			helppage="Configuring-a-Manual_002.html";
		}
	}
	else
	{
		if (IsSharePoint2007)
		{
			if (!bHideExcption && nStep==2)
				helppage="configuring_manual_scan_dp.htm";
			else
				switch(nStep)                                       
				{
					case 1:
					   helppage="step_1_specify_rules_dp_moss_2007.htm";
					   break;		    				
					case 3:
					   helppage="step_2_specify_action_dp_moss_2007.htm";
					   break;
					case 4:
					   helppage="step_3_specify_notification_dp_moss_2007.htm";
					   break;
					case 5:
					   helppage="step_4_name_priority_dp_moss_2007.htm";
					   break;
				}
		}
		else
		{
			switch(nStep)                                       
			{
				case 1:
				   helppage="Step-1_-Specify-Rule_001.html";
				   break;
				case 2:
				   helppage="Step-2_-Exceptions-(.html";
				   break;
				case 3:
				   helppage="Step-3_-Specify-Acti_001.html";
				   break;
				case 4:
				   helppage="Step-4_-Specify-Noti_001.html";
				   break;
				case 5:
				   helppage="Step-5_-Name-and-Pri_001.html";
				   break;
			}
		}
	}
	jsOpenOLHelp(helppage);
	//jsMapOnlineHelp(helppage);
}
function jsCheckRuleDescriptionLength(obj, eve)
{
	if(obj.value.length >= INT_LMAX_CF_DESCRIPTION)
	{
		if(window.event) 
			event.returnValue = false; // IE
		else {			
			// if firefox, you must deliver 'event' as a parameter
			eve.preventDefault(); // firefox
		}
	}	
}

//-->
</script>
<style id="CompCSS" type="text/css">

.tabbedPane
{
 position : relative;
 padding : 10px;
 border : 1px solid #666666;
}
/* Compnent : Tree */
div.lineIE
{
	margin-top:-3px;
	height : 18px;
	FONT-SIZE: 10px;
	FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif";
	word-wrap: normal;
	white-space : nowrap;
}
div.lineNS
{
	height : 18px;
	FONT-SIZE: 10px;
	FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif";
	word-wrap: normal;
	white-space : nowrap;
}
div.subitems
{
    padding-left: 16px;
    FONT-SIZE: 10px;
    FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif";
	background-image:url(./images/tree_line2.gif);
    background-repeat:repeat-y;
}
div.bottomsubitems
{
    padding-left: 16px;
    FONT-SIZE: 10px;
	FONT-FAMILY: "Verdana", "Arial", "Helvetica", "sans-serif";
}

div.root
{
	overflow : auto;
	border : 1px solid;
	padding:2px;
}
.iconbutton
{
	cursor : hand;
}
</style>

</head>
<body onLoad="jsInitPage();">
<form id="fmMain" name="fmMain" action="$$FORM_ACTION$$" method="POST">
<!--Page Title-->
<input type="hidden" id="ExceptionsString" name="ExceptionsString" value=""/>
<input type="hidden" id="DelExceptionIds" name="DelExceptionIds" value=""/>
<input type="hidden" id="FormAction" name="FormAction" value=""/>
<input type="hidden" id="txtSSTaskName" name="txtSSTaskName" value="$$SS_TASK_NAME$$" />
<input type="hidden" id="txtSSTaskBehavior" name="txtSSTaskBehavior" value="$$SS_TASK_BEHAVIOR$$" />
<select id="lstTemplateDes" name="lstTemplateDes" style="display:none">$$TEMPALTE_DESC$$</select>
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr><td class="content-title">$$DLP_TITLE$$: Add Policy</td>
	<td align="right" valign="bottom">
		<a href="javascript:jsOpenOnlineHelp();" class="moretestblue">
		<img src="images/question.gif" border="0"> Help</a></td></tr>
<tr><td colspan="2" height="4"></td></tr>
<tr><td colspan="2" height="1" background="images/dot.gif"></td></tr>
<tr><td colspan="2" height="10"></td></tr>
</table>
<!--/Page Title-->

<table width="650" border="0" cellpadding="0" cellspacing="0">
   <tr id="subTitle_newPolicy"><td  class="data1"><a href="javascript:jsCancel();"><u>Policy List </u></a>&gt; New policy</td></tr>

   <tr id="subTitle_specifySites" style="display:none"><td  class="data1"><a href="javascript:jsCancel();"><u>Policy List </u></a>&gt; <a href="javascript:jsAddExceptionCanceled();"><u>Exceptions</u></a>&gt; Specify Sites</td></tr>
   <tr id="subTitle_specifyAccounts" style="display:none"><td  class="data1"><a href="javascript:jsShowFirstStep();"><u>Policy List </u></a>&gt; <a href="javascript:jsAddExceptionCanceled();"><u>Exceptions</u></a>&gt; Specify Accounts</td></tr>
   
   <tr id="subTitle_editSites" style="display:none"><td  class="data1"><a href="javascript:jsShowFirstStep();"><u>Policy List </u></a>&gt; <a
   href="javascript:jsEditExceptionCancel();"><u>Exceptions</u></a>&gt; Edit Sites</td></tr>
   <tr id="subTitle_editAccounts" style="display:none"><td  class="data1"><a href="javascript:jsShowFirstStep();"><u>Policy List </u></a>&gt; <a
   href="javascript:jsEditExceptionCancel();"><u>Exceptions</u></a>&gt; Edit Accounts</td></tr>
   
   <tr><td  height="10"></td></tr>
   <tr><td>
   <!--setp navigation-->
       <table id="stepNav" border="0" cellpadding="0" cellspacing="0"> 
	        <tr><td valign="bottom" style="width: 10px; height: 3px;"><img src="images/gray_top_left.gif" width="13" height="7" /></td>
                <td width="98%" valign="bottom" style="height: 3px"><img src="images/gray_top_bar.gif" width="100%" height="7" /></td>
                <td width="1%" valign="bottom" style="height: 3px"><img src="images/gray_top_right.gif" width="13" height="7" /></td>
            </tr>
			<tr><td bgcolor="#EFEFEF" class="sideborderleft" >&nbsp;</td>
			    <td bgcolor="#EFEFEF"  >
			        <table  border="0" align="left" cellpadding="0" cellspacing="0">
			            <tr height="9"><td><img id="_step1_img" src="images/arrow_icons_red.gif"/></td>
			                <td nowrap  id="_step1" class="WizardSteps"  title="Specify Rules" style="display:none;">&nbsp;Step 1</td> 
			                <td id="step1" nowrap  class="WizardSelectedStep">&nbsp;Step 1: Specify Rules </td> 
                            <td id="_step2" nowrap  class="WizardSteps"  title="Exceptions (Exclude these accounts and sites)"><table border="0" cellspacing="0" cellpadding="0"><tr><td><img id="_step2_img" src="images/arrow_icons_grey.gif" /></td><td class="WizardSteps" >&nbsp;Step 2</td></tr></table></td>
                            <td id="step2" nowrap  class="WizardSelectedStep"   style="display:none;"><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/arrow_icons_active.gif"  /></td><td class="WizardSelectedStep" >&nbsp;	Step 2: Exceptions</td></tr></table></td>
                            <td id="_step2a" nowrap  class="WizardSteps"  style="display:none;" title="Exceptions (Exclude sites)"><table border="0" cellspacing="0" cellpadding="0"><tr><td><img id="_step2a_img"  src="images/arrow_icons_grey.gif" /></td><td nowrap class="WizardSteps" >&nbsp;Step 2.a</td></tr></table></td>
                            <td id="step2a" nowrap  class="WizardSelectedStep" style="display:none;"><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/arrow_icons_active.gif"  /></td><td nowrap class="WizardSelectedStep">&nbsp;Step 2.a: Specify sites to be excluded</td></tr></table></td> 
                             <td id="_step2b" nowrap  class="WizardSteps"  style="display:none;" title="Exceptions (Exclude these accounts)"><table border="0" cellspacing="0" cellpadding="0"><tr><td><img id="_step2b_img" src="images/arrow_icons_grey.gif" /></td><td nowrap class="WizardSteps">&nbsp;Step 2.b</td></tr></table></td>
                            <td id="step2b" nowrap  class="WizardSelectedStep"  style="display:none;"><table border="0" cellspacing="0" cellpadding="0"><tr><td><img src="images/arrow_icons_active.gif"  /></td><td nowrap class="WizardSelectedStep">&nbsp;Step 2.b: Specify accounts to be excluded</td></tr></table></td>  
                            <td  id="_step3" nowrap  class="WizardSteps" title="Specify Action"><table border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;<img id="_step3_img" src="images/arrow_icons_grey.gif"
                            /></td><td nowrap class="WizardSteps">&nbsp;Step <script>document.write(TOTAL_TITLE_COUNT - 2);</script></td></tr></table></td>
                            <td id="step3" nowrap  class="WizardSelectedStep"  style="display:none;" ><table border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;<img src="images/arrow_icons_active.gif"  /></td><td nowrap class="WizardSelectedStep">&nbsp;Step <script>document.write(TOTAL_TITLE_COUNT - 2);</script>: Specify Action</td></tr></table></td>
                            
                            <td  id="_step4" nowrap  class="WizardSteps" title="Specify Notification"><table border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;<img id="_step4_img" src="images/arrow_icons_grey.gif" /></td><td nowrap class="WizardSteps">&nbsp;Step <script>document.write(TOTAL_TITLE_COUNT - 1);</script></td></tr></table></td>
                            <td id="step4" nowrap  class="WizardSelectedStep" style="display:none;"><table border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;<img src="images/arrow_icons_active.gif"/></td><td nowrap class="WizardSelectedStep">&nbsp;Step <script>document.write(TOTAL_TITLE_COUNT - 1);</script>: Specify Notification</td></tr></table></td>
                            <td  id="_step5" nowrap  class="WizardSteps" title="Name and priority"><table border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;<img id="_step5_img" src="images/arrow_icons_grey.gif" /></td><td nowrap class="WizardSteps">&nbsp;Step <script>document.write(TOTAL_TITLE_COUNT);</script></td></tr></table></td>
                            <td id="step5" nowrap  class="WizardSelectedStep" style="display:none;"><table border="0" cellspacing="0" cellpadding="0"><tr><td>&nbsp;<img src="images/arrow_icons_active.gif"/></td><td nowrap class="WizardSelectedStep">&nbsp;Step <script>document.write(TOTAL_TITLE_COUNT);</script>: Name and Priority</td></tr></table></td>
                	   </tr>
                	 </table>
			    <td bgcolor="#EFEFEF" class="sideborderright" style="height: 9px">&nbsp;</td>
            </tr>
            <tr>
                <td valign="top" style="width: 10px; height: 5px;"><img src="images/gray_bottom_left.gif" width="13" height="7" /></td>
                <td valign="top" style="height: 5px"><img src="images/gray_bottom_bar.gif" width="100%" height="7" /></td>
                <td valign="top" style="height: 5px"><img src="images/gray_bottom_right.gif" width="13" height="7" /></td>
            </tr>
        </table>
    </td></tr>
    <tr> 
      <td colspan="2"><img src="images/1space_cui.gif" width="1" height="10"> </td> 
    </tr> 
    
    <tr> 
      <td colspan="2"><img src="images/1space_cui.gif" width="1" height="10"></td> 
    </tr>
    

<!--step 1 -->
    <tr><td>
        <table id="tabStep1"  style="display:none" width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
	    <!--||Add Template(s)||-->
		<tr><td width="100%" class="tableheadergreyS">Templates</td></tr>
		<tr><td height="6px"></td></tr>
		<tr>
		 <td style="padding-left:6px"><table width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr><td valign="top"><table width="90%" border="0" cellpadding="0" cellspacing="0" class="border">
					    <tr>
                            <td class="data2" height="22">
                                <a class="databutton" href="javascript:jsLinkToAddTemplatePage();"><img id="Import_icon" class="vAlignMid" src="images/icon_add_rule.gif" />Add</a>
                                <a class="databutton" href="javascript:jsImportTemplate();" ><img id="Import_icon" class="vAlignMid" src="images/icon_import.gif" />Import</a>     
                            </td>
                        </tr>
						<tr><td class="grey2-end" height="22">Available DLP Template(s)</td></tr>
                        <tr><td>						
					      <table width="100%" cellpadding="0" cellspacing="0" >
						    <tr><td><div id="divAvailableTemplateOuter" name="divAvailableTemplateOuter" style="width:260px;height:180px;overflow:auto">
						          <table border="0" cellpadding="0" cellspacing="0">
						             <tr>
								         <td>
								            <div id="divAvailableTemplateInner" name="divAvailableTemplateInner" style="position:relative;overflow:hidden">								         
								                 <select class="text" id="lstAvailableTemplate" name="lstAvailableTemplate"  style="position:relative" multiple ondblclick="jsLinkToEditTemplatePage('lstAvailableTemplate');" onChange="jsChangeTemplate();">
												 $$AVAILABLE_COMPLIANCE_TEMPLATE_LIST$$
												 </select>
								            </div>
								         </td>
								     </tr>
								  </table>
							   </div>
							  </td>
						    </tr>
						  </table>
						</td></tr>
					 </table>
				    </td>
				    <td valign="top" style="padding-top:29px">
					    <table border="0" cellpadding="0" cellspacing="0">							    
							<tr><td><input type=button class="text" value="Add &gt;&gt;" style="width:76" onClick="jsAddTemplate();"></td></tr>
			                <tr><td height="10px"></td></tr>
							<tr><td><input type=button class="text" value="&lt;&lt; Remove" style="width:76" onClick="jsRemoveTemplate();"></td></tr>							           
						</table>
					</td>
				    <td style="padding-left:10">
					<table width="100%" cellpadding="0" cellspacing="0">
					<tr><td height="30"  class="data1" style="padding-left:6px">Match any of selected templates</td></tr>
					  <tr><td height="140px">
					  <table width="90%" border="0" cellpadding="0" cellspacing="0" class="border">
						<tr><td class="grey-end" height="22">Selected DLP Template(s)</td></tr>
                        <tr><td>						
					      <table width="100%" cellpadding="0" cellspacing="0" >
						    <tr><td><div id="divSelectedTemplateOuter" name="divSelectedTemplateOuter" style="width:260px;height:120px;overflow:auto">
						          <table border="0" cellpadding="0" cellspacing="0">
						             <tr>
								         <td>
								            <div id="divSelectedTemplateInner" name="divSelectedTemplateInner" style="position:relative;overflow:hidden">								         
								                 <select class="text" id="lstSelectedTemplate" name="lstSelectedTemplate"  style="position:relative" multiple ondblclick="jsLinkToEditTemplatePage('lstSelectedTemplate');"></select>
								            </div>
											<select class="text" id="__lstSelectedTemplate" name="__lstSelectedTemplate"  style="position:relative; background:yellow;display:none;">
												  
										    </select>
								         </td>
								     </tr>
								  </table>
							   </div>
							  </td>
						    </tr>
						  </table>
						</td></tr>
					 </table>
					 </td></tr>
                     <tr><td height="10px"></td></tr>					
					<tr><td  height="10px"><span style="font-weight:bold">Description:</span></td></tr>
			        <tr><td id="tdTemplateDes" name="tdTemplateDes"  width ="280px" height="40px"></td></tr>						 
					</table></td>
				</tr>
				<tr><td colspan="3" height="10px"></td></tr>
				<tr><td colspan="3"><span style="font-weight:bold">Notes: </span>Double-click a template's name to edit it.</td></tr>
				<tr><td colspan="3" height="6px"></td></tr>
               </table>
			 </td>
		  </tr>
        </table> 
    </td></tr>
     
<!--step 2-->
    <tr><td>
        <table id="tabStep2"  style="display:none" width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
        <!--||Exceptions||-->
        <tr><td width="50%" class="tableheadergreyS">Exclude these sites and accounts</td></tr>
        <tr><td>
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
		    <tr><td>
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
                    <td class="data2">
                    <table border="0" cellspacing="0" cellpadding="0">
					    <tr height="25">
							<td nowrap><a id="cmdAddItem1" href="javascript:jsAddException();" class="databutton"><img id="cmdAddItem1_img" src="images/icon_add_rule.gif" class="vAlignMid"> Add </a></td>
							<td>&nbsp;</td>
							<td nowrap><a id="cmdDelItem1" href="javascript:jsDelItem();" class="databutton"><img id="cmdDelItem1_img" src="images/icon_delete.gif" class="vAlignMid">Delete</a></td>
					        <td>&nbsp;</td>
					 
							<td>&nbsp;</td>
                        </tr>
					</table>
                    </td>
					<td class="data2" align="right">
                    <table border="0" cellspacing="0" cellpadding="0">
						<tr><td nowrap align="right"><table border="0" cellspacing="0" cellpadding="0"><tr>
							<td nowrap><font id="labRecordS1" name="labRecordS1">0</font> - <font id="labRecordE1" name="labRecordE1">0</font> of <font id="labTotalRec1" name="labTotalRec1">0</font></td>
							
							<td><img src="images/pagination-beginning.gif" style="cursor:pointer" onClick="jsPage(1);" class="vAlignMid"></td>
							<td><img src="images/pagination-previous.gif" style="cursor:pointer" onClick="jsPage(parseInt(nCurrentPage)-1);" class="vAlignMid"></td>							
							<td>&nbsp;Page&nbsp;</td>
							<td><input type="text" size="3" class="text" id="txtPageNum1" name="txtPageNum1" value="0" onKeyPress="jsKeyPressEvent(event,this.value);" /></td>
							<td>&nbsp;of&nbsp;</td>
							<td><font id="labTotalPage1" name="labTotalPage1">0</font></td>
							<td><img src="images/pagination-next.gif" style="cursor:pointer" onClick="jsPage(parseInt(nCurrentPage)+1);" class="vAlignMid"></td>
							<td><img src="images/pagination-end.gif" style="cursor:pointer" onClick="jsPage(-1);" class="vAlignMid"></td></tr></table>
					    </td></tr>
				    </table>
                    </td>
                </tr>
			    </table>
            </td></tr>
		    <tr><td>
                <table width="100%" border="0" cellpadding="0" cellspacing="0" id="tabList" name="tabList">				
				<tr>
                    <td class="grey2" width="4%"><input type="checkbox" name="chkSelectAll" onClick="javascript:jsSelectAll();"></td>
		  		    <td class="grey2-end" align="center">Exceptions</td>	
                </tr>
                
		        </table>
            </td></tr>
		    <tr><td class="border3">
                <table width="100%" border="0" cellspacing="0" cellpadding="0">
				    <tr>
                    <td class="data2">
                    <table border="0" cellspacing="0" cellpadding="0">
						<tr height="25">
							<td nowrap><a id="cmdAddItem2" href="javascript:jsAddException();" class="databutton"><img id="cmdAddItem2_img" src="images/icon_add_rule.gif" class="vAlignMid"> Add </a></td>
							<td>&nbsp;</td>
							<td nowrap><a id="cmdDelItem2" href="javascript:jsDelItem();" class="databutton"><img id="cmdDelItem2_img" src="images/icon_delete.gif" class="vAlignMid">Delete</a></td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
                        </tr>
				    </table>
                    </td>
					<td class="data2" align="right">
                    <table border="0" cellspacing="0" cellpadding="0">
						<tr><td nowrap align="right"><table border="0" cellspacing="0" cellpadding="0"><tr>
							<td nowrap><font id="labRecordS2" name="labRecordS2">0</font> - <font id="labRecordE2" name="labRecordE2">0</font> of <font id="labTotalRec2" name="labTotalRec2">0</font></td>
							
							<td><img src="images/pagination-beginning.gif" style="cursor:pointer" onClick="jsPage(1);" class="vAlignMid"></td>
							<td><img src="images/pagination-previous.gif" style="cursor:pointer" onClick="jsPage(parseInt(nCurrentPage)-1);" class="vAlignMid"></td>
							<td>&nbsp;Page&nbsp;</td>
							<td><input type="text" size="3" class="text" id="txtPageNum2" name="txtPageNum2" value="0" onKeyPress="jsKeyPressEvent(event,this.value);" /></td>
							<td>&nbsp;of&nbsp;</td>
							<td><font id="labTotalPage2" name="labTotalPage2">0</font></td>
							<td><img src="images/pagination-next.gif" style="cursor:pointer" onClick="jsPage(parseInt(nCurrentPage)+1);" class="vAlignMid"></td>
							<td><img src="images/pagination-end.gif" style="cursor:pointer" onClick="jsPage(-1);" class="vAlignMid"></td></tr></table></td></tr>
				    </table>
                    </td>
                    </tr>	
			    </table>
            </td></tr>
			<tr><td class="data2c" align="right">Rows per page: 
			    <select id="optRecordPerPage" name="optRecordPerPage" class="text" onChange="jsChgRate(this.options[this.selectedIndex].text,this.selectedIndex);"></select>
            </td></tr>
		    </table>
            </td></tr>
        </table>
    </td></tr>
<!--step 3-->
    <tr><td>
        <table id="tabStep3"  style="display:none" width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
        <tr><td width="50%" class="tableheadergreyS">Action Settings <img id="SelectActionToolTipIcon" name ="SelectActionToolTipIcon" src="images/info_mark.gif" style="cursor:pointer;position:relative;display:none"
        onmouseout="hideToolTip('ifmToolTip');" onMouseOver="jsshowToolTip('ifmToolTip',this,200,70,TIP_CF_TITEL,$$TIP_DLP_CONTENT$$);" ></td></tr>
        <tr><td>
            <table width="100%" border="0" cellpadding="0" cellspacing="2">
            <tr id="docForManuAction" style="display:none"><td colspan="2">&nbsp;<b>For document</b></td></tr>
            <tr id="QuarantineAction" style="display:none">
                <td width="2%"><input id="optQuarantine" type=radio name="optActionType" value="quarantine" onClick="jsUIDependency();"></td>
			    <td width="15%">Quarantine</td>
                <td width="90%"></td></tr>
			<tr id="DeleteAction">
                <td id="radioDeleteAllAction" height="20" width="2%">
				<input type=radio id="rdoDeleteAll"  name="optActionType" value="delete" onClick="jsUIDependency();"></td>
				<td width="15%" id="txtDeleteAction">Block</td>
                <td width="90%"></td></tr>					
            <tr id="PassAction">
                <td width="2%">
				<input type=radio id="optPassAction" name="optActionType" value="pass"   onClick="jsUIDependency();" checked></td>
			    <td width="15%">Pass</td>
                <td width="90%"></td></tr>                 
		    <tr height="5"><td colspan="2"></td></tr>
		    <tr><td colspan="2">&nbsp;<b>AND</b></td></tr>
		    <tr height="5"><td colspan="2"></td></tr>
		    <tr><td height="20"><input type=radio name="optActionNotify" value="notify_enabled" ></td>
		        <td>Notify</td></tr>
		    <tr><td height="20"><input type=radio name="optActionNotify" value="notify_disabled" checked></td>
			    <td>Do not notify</td></tr>				
			</table>
        </td></tr>
        
        </table>
    </td></tr>
<!--step 4-->
    <tr><td>
        <table id="tabStep4"  style="display:none" width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
        <!--Notification.htm_partial-->
		$$NOTIFICATION_PAGE$$
        </table>
    </td></tr>
<!--step 5-->
    <tr><td>
        <table id="tabStep5"  style="display:none" width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
        <tr><td class="tableheadergreyE">Name and Priority</td></tr>
        <tr><td>
            <table>
            <tr><td width="20"><input type=checkbox id="optPolicyEnabled" name="optPolicyEnabled" ></td>
                <td class="data1">Enable this policy</td></tr>
            <tr><td></td>
                <td>
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr><td class="data1" width="155">Policy name<font class="highlight-red">*</font>: </td>
		        	<td class="data1"><input type="text" class="text" id="RuleName" name="RuleName" value="" size="80" maxlength="64"></td></tr>
		        <tr><td class="data1" valign="top">Description:</td> 
                    <td class="data1"><textarea name="RuleDescription" id="RuleDescription" cols="80" rows="4" class="button" onKeyUp="jsCheckRuleDescriptionLength(this,event);"></textarea></td></tr>
                <tr><td class="data1">Priority<font class="highlight-red">*</font>:</td>
			        <td class="data1"><input type="text" class="text" id="RuleOrder" name="RuleOrder"  value="" style="width:42" onKeypress="if(window.event)    {if(event.keyCode<48||event.keyCode>57)   event.returnValue= false;} else {if(!((event.which>=48&&event.which<=57)||event.which==8))   return false;}"></td></tr>
		        </table>
                </td>
            </tr> 
            </table>
        </td></tr>
                        
        <tr height="10"><td> </td></tr>
        <tr><td> Review the existing policies below to determine the priority of this new policy</td></tr>
         
        <tr><td>
           <table width="100%" border="0" cellpadding="0" cellspacing="0" id="tabExistPolicyList" name="tabExistPolicyList">
            <tr height="22">
                <td class="grey2" nowrap>Policy</td>  
                <td class="grey2">Description</td>
                <td class="grey2" nowrap>Action</td>
	            <td class="grey2" align="center">Priority</td>
            	<td class="grey2" align="center">Status</td></tr>

               $$EXISTED_RULES$$ 
            </table>
        </td></tr>
        </table>
    </td></tr>

<!--step2 specify sites (default:display=none)-->
    <tr><td>
        <table id="specifySites" style="display:none" width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
        <tr><td class="tableheadergreyS">Specify sites</td><td width="20%" align="right" class="tableheadergreyS"><a  href="javascript:jsRefresh();" class="moretestblue"><img src="images/icon_refresh.gif" class="vAlignMid"> Refresh</a></td></tr>
        <tr><td class="data1"><input type="radio" name="rdAnysite" value="1" onClick="jsAnysiteCheck()" >All sites</td><td></td></tr>
        <tr><td class="data1"> <input type="radio" name="rdAnysite" value="0" onClick="jsAnysiteCheck()" checked>Specify a site's URL:<span class="data1"> 
        
                      <input type="text" class=button size=30 name="siteSearchInput" id="siteSearchInput"> 
                      <input name="btnSearchSite" type="button" class="button" value="Search" id="btnSearchSite" onClick="jsSearchSite('siteSearchInput');" style="width:50px"> 
                     </span></td><td></td></tr> 
        <tr><td></td><td></td></tr>
        <tr><td class="data1">&nbsp;&nbsp;&nbsp;&nbsp;Select sites:</td></tr>
        <tr><td>
              <div id="Tree__treepanel" style="position:relative;left:20px;width:550; height:380;border :1px solid Silver;; overflow:auto;height:252px">Please
                  wait...</div>
        </td><td>
        </td></tr>
        <tr height="10"><td></td><td></td></tr>
        </table>
    </td></tr>
<!--step2 specify accounts (default:display=none)-->
    <tr><td>
        <table id="specifyAccounts" style="display:none" width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
        <tr><td class="tableheadergreyS" >Select Accounts</td></tr>
		<tr><td height="5" ></td></tr>
						        <tr><td>
        <table  border="0" cellpadding="0" cellspacing="0">
        <tr><td colspan="2"><input name="rdAnyone" type="radio" value="1"  onclick="jsAnyoneCheck()">Anyone</td></tr>
        <tr><td colspan="2"><input name="rdAnyone" type="radio" value="0" onClick="jsAnyoneCheck()" checked="checked">Specific Accounts</td></tr>		
		
        <tr>
            <td width="40"></td>
            <td>
            <table id="tabAnyone" style="margin-left:20px;">
            <tr><td colspan="2" class="data1">Search target: <font id="ftADAccount">AD user(s)/group(s):</font> 
                                <select class="button" name="lstSearchType" id="lstSearchType"> 
                                  <option value="1">AD user(s)/group(s)</option> 
                                  <option value="0">SharePoint user(s)/group(s)</option> 
                                </select> 
                <input type=text class="text" id="txtSearch" name="txtSearch" style="width:220" ><input type=button class="text" value="Search" id="btnSearchAccount" name="btnSearchAccount" onClick="jsSearchAccount('txtSearch');"></td></tr>
		    <tr><td colspan="2"><table border="0" cellpadding="0" cellspacing="0" style="margin-left:2px;"><tr><td nowrap>Search type:</td>
                <td><input type=checkbox id="chkUser" name="chkUser" CHECKED></td><td> Users</td>
	            <td><input type=checkbox id="chkGroup" name="chkGroup" CHECKED></td><td> Groups</td></tr></table>
	        </td></tr>
            <tr><td>&nbsp;</td>
		        <td>
                <table id="tabSpecial" width="100%" border="0" cellpadding="0" cellspacing="0">					
		        <tr><td class="data1">
                    <table  id="tab1" width="280" height="240" class="border" cellpadding="0" cellspacing="0" >
					<tr><td class="grey-end" height="18">Available Account(s)</td></tr>
					<tr><td>
                        <div id="divAvailableAccountOuter" style="overflow:auto;width:280;height:240">
						<table  border="0" cellpadding="0" cellspacing="0">
						<tr><td valign="top">
                            <table id="tabAvailableAccountList" border="0" cellpadding="0" cellspacing="0">
                            </table>
                            </td>
							<td valign="top" width="100%">
                            <div id="divAvailableAccountInner" style="position:relative;overflow:hidden;width:100%">
							<select id="lstAvailableAccount" name="lstAvailableAccount" multiple style="position:relative;top:-3;left:-3;font-size:13px;">
							</select>
                            </div>
                            </td>
                        </tr>
						</table>
                        </div>
                    </td></tr>
					</table>
					</td> 
					<td>
                    <table id="tab1_button">
                    <tr>
                    <td class="data1" valign="middle">
						<input type=button id="btnAddAccount" class="text" value="Add &gt;&gt;"  style="width:80px" onClick="jsAddSelectedAccount();"><br/>
						<input type=button id="btnRemoveAccount"class="text" value="&lt;&lt; Remove" style="width:80px" onClick="jsRemoveSelectedAccount();">
                    </td></tr>
					</table>
					</td>      
					<td>
                    <table width="280" height="240" border="0" cellpadding="0" cellspacing="0" class="border">
					<tr><td class="grey-end" height="18">Selected Account(s)</td></tr>
					<tr><td valign="top">
                        <div id="divSelectedAccountOuter" style="overflow:auto;width:280;height:240;position:relative">
					    <table  border="0" cellpadding="0" cellspacing="0">
					    <tr><td  valign="top">
                            <table id="tabSelectedAccountList" border="0" cellpadding="0" cellspacing="0" valign="top">
                            </table>
                            </td>								                     
					    	<td valign="top" width="100%">
							<div id="divSelectedAccountInner" style="position:relative;overflow:hidden;width:100%">	
                            <select id="lstSelectedAccount" name="lstSelectedAccount" style="position:relative;top:-3;left:-3;font-size:13px;" multiple>
                            
                            </select>
                            <select id="lstExistAccount" style="display:none"></select>
                            </div>
                            </td>
					    </tr>
                        </table>
					    </div>
                    </td></tr>
					</table>
					</td>
					<td>&nbsp;</td>
			    </tr>
				</table>
            </td></tr>
			</table>
        </td></tr>
		</table></td></tr>  
		<tr><td height="10" ></td></tr>
		<tr><td height="1"  background="images/dot.gif"></td></tr>
		
	 	<tr><td>
            <table>
            <tr>
                <td nowrap><img src="images/ad_user.gif" alt="AD Users" align="absmiddle"></td>
                <td nowrap class="data1"><span>-AD User</span></td>
                <td width="22" align="right" nowrap><img src="images/ad_group.gif" alt="AD Groups" align="absmiddle"></td>
                <td nowrap class="data1"><span>-AD Group</span></td>
                <td width="22" align="right" nowrap><img src="images/SP_user.gif" alt="SharePoint User" align="absmiddle"></td>
                <td nowrap class="data1"><span>-SharePoint User</span></td>
                <td width="22" align="right" nowrap><img src="images/sp_group.gif" alt="SharePoint Group" align="absmiddle"></td>
                <td nowrap class="data1"><span>-SharePoint Group</span></td>
            </tr>	
	 	    </table>
        </td></tr>
        
        </table>
    </td></tr>
</table>

<!--add Exception button-->
<table id="addExceptionButton"  style="display:none" width="540" border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
    <td height="28" valign="bottom">
      <input name="exception_backButton" id="exception_backButton" type="button" class="button" value="&lt; Back" onClick="jsShowSpecifySites()" style="width:50px">
      <input name="exception_submitButton" id="exception_submitButton" type="button" class="button" onClick="jsAddExceptionFinished()" value="Finish" style="width:50px">  
      <input name="exception_nextButton" id="exception_nextButton" type="button" class="button" onClick="jsShowSpecifyAccounts()" value="Next &gt" style="width:50px"> 
&nbsp;
      <input id="btnExpAddCancel" name="btnExpAddCancel" type="button" class="button" onClick="jsAddExceptionCanceled()" value="Cancel" style="width:50px">
    </td> 
  </tr> 
</table>

<!--edit Exception button-->
<table id="editExceptionButton"  style="display:none" width="540" border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
    <td height="28" valign="bottom">
      <input name="editBackButton" id="editBackButton" type="button" class="button" onClick="jsShowSpecifySites()" value="&lt; Back" style="width:50px">
      <input name="editSubmitButton" id="editSubmitButton" type="button" class="button" onClick="jsEditExceptionFinished()" value="Finish" style="width:50px">  
      <input name="editNextButton" id="editNextButton" type="button" class="button" onClick="jsShowSpecifyAccounts()" value="Next &gt" style="width:50px">
      <!--
      <input name="editSiteSaveButton" id="editSiteSaveButton" type="button" class="button" onClick="jsEditSiteSave()" value="Save" style="width:50px">  
      <input name="editAccountSaveButton" id="editAccountSaveButton" type="button" class="button" onClick="jsEditAccountSave()" value="Save" style="width:50px">  
      -->
&nbsp;
      <input id="btnExpEditCancel" name="btnExpEditCancel" type="button" class="button" onClick="jsEditExceptionCancel()" value="Cancel" style="width:50px">
    </td> 
  </tr>
</table>

<!--add Policy button-->
<table id="addPolicyButton" width="540" border="0" cellspacing="0" cellpadding="0"> 
  <tr> 
    <td height="28" valign="bottom">
      <input name="backButton" id="backButton" type="button" class="button" value="&lt; Back" onClick="jsBack()" style="width:50px">
      <input name="btnSubmit" value="Finish"  id="submitButton" type="button" class="button" onClick="jsSubmit()" value="Finish" style="width:50px">  
      <input name="nextButton" id="nextButton" type="button" class="button" onClick="jsNext()" value="Next &gt" style="width:50px"> 
&nbsp;
      <input id="btnCancel" name="btnCancel" type="button" class="button" onClick="jsCancel()" value="Cancel" style="width:50px">
    </td> 
  </tr> 
</table>
<input type=hidden id="ReturnValue" name="ReturnValue">
<input type=hidden id="ReturnSynonym" name="ReturnSynonym">
</form>

<form action="$$EXPORT_FORM_ACTION$$" method="POST" id="fmExport" name="fmExport" target="iFrameForExportWBList">
<input type="hidden" name="export_content" id="export_content">
</form>
<div id="import_mask" style= "z-index:1000;position:absolute;width:0;height:0p; top:0; left: 0;padding-top:30;float:left;">
    <div id="import_wording" style=" text-align:center; margin-top:160px;display:none">
    <font size="1" color="#0000FF"><b>Importing...</b></font><br/>
    <img src="images/icon_loading.gif" style="margin-top:5px;" /> 
    </div>
</div>
<iframe id="ifmToolTip" name="ifmToolTip" src="html/ToolTip.htm" frameborder="0" style="z-index:10000;position:absolute;width:0;height:0;scrolling:no"/>
<iframe id="iFrameForExportWBList" name="iFrameForExportWBList" src="html/UntitledFrame-1.htm" frameborder="0" style="width:0;height:0"></iframe>
<iframe id="ifmAccount" name="ifmAccount" src="$$ACCOUNT_SEARCH_CGI_URL$$" frameBorder="0" width="0" height="0" style="display:none"/>

</body>
</html>


