<html>
<head>
<title>Web Reputation Import File</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 approved_list = "$$APPROVED_LIST$$";
function jsInitPage() {
	// Init Page
	var allcookie = unescape(document.cookie);
    var WTPImportInit = null;
	if(allcookie.indexOf("WTPImportInit=") != -1){
	    var CookiePair = allcookie.split(";");
        for(i=0;i<CookiePair.length;i++){
            if(CookiePair[i].indexOf("WTPImportInit=") != -1){
                WTPImportInit = CookiePair[i].substring(CookiePair[i].indexOf("=")+1,CookiePair[i].length);
            }
        }
	}
	if(WTPImportInit == "imported"){
	    document.cookie = "WTPImportInit=" + escape("initial");
	    if(approved_list.length == 0){
	        alert(STR_WARN_WRONG_FILE);
	    }
	    else{
		    var URLValid = true;
		    var vTemp = approved_list.split(String.fromCharCode(9));
		    for (var i=0;i<vTemp.length;i++) {
		        vTemp[i] = setTrim(vTemp[i]).toLowerCase();
			    
			    var bFirstwww = true;
				if(vTemp[i].substr(0,7) == "http://")
        			vTemp[i] = vTemp[i].substring(7,vTemp[i].length);
		
                if(vTemp[i].substr(0,8) == "https://")
                    vTemp[i] = vTemp[i].substring(8,vTemp[i].length);
                if(vTemp[i].substr(0,4) == "www.")
                 { 
                     vTemp[i] = vTemp[i].substring(4,vTemp[i].length);
                     bFirstwww = false;
                 }
                if (bFirstwww&&(vTemp[i].substr(0,4) != "wwww"))
                 { 
                    if(vTemp[i].substr(0,3) == "www")
                    { 
                         vTemp[i] = vTemp[i].substring(3,vTemp[i].length);
                     }
                }
                
                if(vTemp[i].indexOf("/")!=-1 )
	            {
		            vTemp[i] = vTemp[i].substring(0,vTemp[i].indexOf("/"));
	            }
					
					
	            if(!checkWTPURLFormat(vTemp[i],null,false))
			    {
			         vTemp.splice(i, 1);
			         i--;
					 alert(STR_WARN_APPROVED_URL);
					 URLValid = false;
					 break;
                }
               else
                 {
                     if(vTemp[i].indexOf("[")!=-1 && vTemp[i].indexOf("]")!=-1 )
	                {
		                vTemp[i] = vTemp[i].replace("[","");
		                vTemp[i] = vTemp[i].replace("]","");
	                }
                }
	        }	
            if(URLValid)
			{
			  window.opener.document.getElementById("ReturnValue").value = vTemp.join(";");
		      window.opener.jsImportCGI();
		      window.close();
			}
	    }
		        
	}
}
function jsSubmitForm(){
    if(setTrim(document.fmMain.txtFile.value) == "" ){
        return false;
    }
    else{ 
        document.cookie = "WTPImportInit=" + escape("imported");
        return true; 
    }
}
//-->
</script>
<body style="margin:0" onLoad="jsInitPage();">
<form id="fmMain" name="fmMain" action="$$FORM_ACTION$$" method="POST" enctype="multipart/form-data" onSubmit="jsSubmitForm();">
<!--Hidden Field--><!--/Hidden Field-->

<!--Page Title-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td background="images/barbk2.gif" class="popup-title"><font size="2">Web Reputation Import File</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 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 File</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><input type=submit class="text" value="Import">
		<input type=button class="text" value="Cancel" onClick="window.returnValue='';window.close();"></td></tr>
</table>
<!--/Page Content-->
</form>
</body>
</html>
