<html>
<head>
<title>Data Loss Prevention - Import Template</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/localization.js"></script>
<script language="JavaScript" src="javascripts/trend-ui-new.js"></script>
<script language="JavaScript" type="text/JavaScript">

var iErrorCode = "$$ERROR_CODE$$";
var itemName = "$$VAR_INVAILD_IMPORTITEMNAME$$";
var strCurrentTag = 1;
var DLP_IMPORT_SUCCESS				= 0;
var DLP_IMPORT_ERROR				= 1;
var DLP_IMPORT_ERROR_LANGUAGE		= 2;
var DLP_IMPORT_ERROR_FORMAT			= 3; 
var DLP_IMPORT_ERROR_SOME_FAILED	= 4;


function jsInitPage() {
	var allcookie = unescape(document.cookie);
    var ImportStatus = null;
	if(allcookie.indexOf("DigitalAssetsImportInit=") != -1){
	    var CookiePair = allcookie.split(";");
        for(i=0;i<CookiePair.length;i++){
            if(CookiePair[i].indexOf("DigitalAssetsImportInit=") != -1){
                ImportStatus = CookiePair[i].substring(CookiePair[i].indexOf("=")+1,CookiePair[i].length);
            }
        }
	}
	
	// Init Page
    strCurrentTag = window.opener.document.getElementById("viewGroup").value;
	if(ImportStatus=="imported")
	{
	    document.cookie = "DigitalAssetsImportInit=" + escape("initial");
	
		document.cookie = "TemplateImportInit=" + escape("initial");
		if(strCurrentTag == 1){
			if(iErrorCode==DLP_IMPORT_ERROR)
				alert(STR_WARN_EXPRESSION_INVALID_CONTENT);
			else if(iErrorCode==DLP_IMPORT_ERROR_LANGUAGE)
				alert(STR_WARN_EXPRESSION_INVALID_CONTENT);
			else if(iErrorCode==DLP_IMPORT_ERROR_FORMAT)
				alert(STR_WARN_EXPRESSION_INVALID_CONTENT);
			else if(iErrorCode == DLP_IMPORT_ERROR_SOME_FAILED)
				alert(STR_INVALID_EXPRESSION+itemName+STR_INVAILD_DIGITALASSETSEND);
		}
		else if(strCurrentTag == 2){
			if(iErrorCode==DLP_IMPORT_ERROR)
				alert(STR_WARN_KEYWORD_INVALID_CONTENT);
			else if(iErrorCode==DLP_IMPORT_ERROR_LANGUAGE)
				alert(STR_WARN_KEYWORD_INVALID_CONTENT);
			else if(iErrorCode==DLP_IMPORT_ERROR_FORMAT)
				alert(STR_WARN_KEYWORD_INVALID_CONTENT);
			else if(iErrorCode == DLP_IMPORT_ERROR_SOME_FAILED)
				alert(STR_INVALID_KEYWORD+itemName+STR_INVAILD_DIGITALASSETSEND);
		}	   
		window.opener.jsImportRefresh();
        window.close();		
	}
	
	
	if(strCurrentTag == 1){
		//Import Expressions
		document.title = "Data Loss Prevention - Import Expressions";
		document.getElementById("expressionTitle").style.display = "";
		document.getElementById("keywordTitle").style.display = "none";
		document.getElementById("expressionContent").style.display = "";
		document.getElementById("keywordContent").style.display = "none";
		document.getElementById("expressionNote").style.display = "";
		document.getElementById("keywordNote").style.display = "none";
	}else if(strCurrentTag == 2){
		//Import Keywords
		document.title = "Data Loss Prevention - Import Keywords";
		document.getElementById("expressionTitle").style.display = "none";
		document.getElementById("keywordTitle").style.display = "";
		document.getElementById("expressionContent").style.display = "none";
		document.getElementById("keywordContent").style.display = "";
		document.getElementById("expressionNote").style.display = "none";
		document.getElementById("keywordNote").style.display = "";
	}
}
function jsSubmit()
{
	if(setTrim(document.fmMain.txtFile.value) == "" )
        return;
	if(strCurrentTag == 1 && !confirm(STR_ALR_OVERWRITE_Expression_SETTING))
		return;
	if(strCurrentTag == 2 && !confirm(STR_ALR_OVERWRITE_Keyword_SETTING))
		return;	

	document.cookie = "DigitalAssetsImportInit=" + escape("imported");
	document.fmMain.action += "viewGroupCurrent=" + strCurrentTag;
	document.fmMain.encoding = "multipart/form-data";
	jsAddCSRFToken(document.fmMain);
    document.fmMain.submit();
	document.fmMain.btnSubmit.disabled = true;
	document.fmMain.btnCancel.disabled = true;
}

//-->
</script>
</head>
<!--for UI optimize, page will be hidden before this to avoid show "(##key)".|but here ,some control in <input> can't refresh correctly!so remove the visiability css from <body> tag!-->
<body style="margin:0;" onLoad="jsInitPage();">
<form id="fmMain" name="fmMain" action="$$FORM_ACTION$$" method="POST" enctype="multipart/form-data">
<!--Page Title-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td background="images/barbk2.gif" class="popup-title"><font size="2">Import Data Loss Prevention <font id="expressionTitle" style="display:none;">Expressions</font><font id="keywordTitle" style="display:none;">Keyword Lists</font></font></td>
    <td background="images/barbk2.gif" class="popup-title" align="right"></td></tr>
<tr><td colspan="2" height="1" background="images/dot.gif"></td></tr>
</table>
<!--/Page Title-->
<!--Page Content-->
<table id="importTable" width="98%" border="0" cellpadding="0" cellspacing="10">
<tr>
	<td>
		<table width="100%" border="0" cellpadding="0" cellspacing="0" class="border">
		<tr>
			<td class="tableheadergreyS" colspan="2">Import <font id="expressionContent" style="display:none;">Expressions</font><font id="keywordContent" style="display:none;">Keywords</font></td>
		</tr>
		<tr><td class="data1">File directory:</td>
			<td class="data1"><input type="file" class="text" id="txtFile" name="txtFile" size="40"></td>
		</tr>
		</table>
	</td>
</tr>
<tr>
	<td>
		<font id="expressionNote" style="display:none;">Note: Importing the expression file adds new expressions and replaces existing items.</font>
		<font id="keywordNote" style="display:none;">Note: Importing the keyword list file adds new keyword lists and replaces existing items.</font>
	</td>
</tr>
<tr><td><input name="btnSubmit" type="button" onClick="jsSubmit()" class="text" value="Import">
		<input name="btnCancel" type="button" class="text" value="Cancel" onClick="window.returnValue='';window.close();">
		
	</td>
</tr>
</table>
<!--/Page Content-->
</form>
</body>
</html>
