<html>
   <head>
      <meta HTTP-EQUIV='Pragma' CONTENT='no-cache'>
      <link rel="stylesheet" href='stylemain.css' type='text/css'>
         <link rel="stylesheet" href='colors.css' type='text/css'>
            <script language="javascript" src="util.js"></script>
            <script type="text/javascript" src="lang/b28n.js"></script>
<script language="javascript"><%ejGetOther(forbidHTMLCode)%></script>
<script language="javascript"> 
<!-- hide 

var maxEntry = '<%ejGetOther(sysInfo, maxPrtTrgEntry)%>';
//var wanIpIfNameArray = new Array(<%ejGetOther(AncestorList, scPrtTrgIpIf)%>);
//var wanPppIfNameArray = new Array(<%ejGetOther(AncestorList, scPrtTrgPppIf)%>);
var curObjRows = 0;

var obj1Items = '<%ejGetObject(MDMOID_DEV2_NAT_PORT_TRIGGERING)%>';

var obj1Rows = numOfRow(obj1Items);
/* NOTICE: MDMOID_WAN_IP_CONN_PORT_TRIGGERING is Type1/Type2 object, follow variables are arrays */
var enableArray = getColFromList(obj1Items, "Enable");
var nameArray = getColFromList(obj1Items, "Name");
var triggerProtocolArray = getColFromList(obj1Items, "TriggerProtocol");
var openProtocolArray = getColFromList(obj1Items, "OpenProtocol");
var triggerPortStartArray = getColFromList(obj1Items, "TriggerPortStart");
var triggerPortEndArray = getColFromList(obj1Items, "TriggerPortEnd");
var openPortStartArray = getColFromList(obj1Items, "OpenPortStart");
var openPortEndArray = getColFromList(obj1Items, "OpenPortEnd");


var locationQuery='sessionKey=<%ejGetOther(sessionKey)%>';


function initTranslation() {	
	var idArray = new Array("scprttrgview_title","scprttrgview_guid1","scprttrgview_guid2","scprttrgview_app","scprttrgview_trigger","scprttrgview_open","scprttrgview_wanInter","scprttrgview_protocol","scprttrgview_porRange",
		"scprttrgview_protocol1","scprttrgview_porRange1","scprttrgview_start","scprttrgview_end","scprttrgview_start1","scprttrgview_end1","scprttrgview_add","scprttrgview_add1","scprttrgview_remove","scprttrgview_remove1", "natPortTriggerRemainNumTip1", 
		"natPortTriggerRemainNumTip2", "natPortTriggerRemainNumTip3");
	setAllIdValue(idArray);
}

function frmLoad() {
	initTranslation();

}

function displayProtocol(protocol){
	if(protocol == 'TCP or UDP')
		document.writeln("<td class='tablesize'>&nbsp;TCP/UDP</td>");
	else
		document.writeln("<td class='tablesize'>&nbsp;"+ protocol +"</td>");	
}

function fillObj1Items(){
	var i;
	for(i=0; i < obj1Rows; i++){
		if(enableArray[i] == 1){
			document.writeln("<tr>");
			document.writeln("<td class='tablesize'>"+ nameArray[i] +"</td>");
			displayProtocol(triggerProtocolArray[i]);			
			document.writeln("<td class='tablesize'>"+ triggerPortStartArray[i] +"</td>");
			document.writeln("<td class='tablesize'>"+ triggerPortEndArray[i] +"</td>");
			displayProtocol(openProtocolArray[i]);
			document.writeln("<td class='tablesize'>"+ openPortStartArray[i] +"</td>");
			document.writeln("<td class='tablesize'>"+ openPortEndArray[i] +"</td>");
			document.writeln("<td class='tablesize'>"+ wanIpIfNameArray[i] +"</td>");		
			document.writeln("<td align='center'><input type='checkbox' name='rml' value='"
				+ wanIpIfNameArray[i] +"|"
				+ triggerProtocolArray[i] +"|"
				+ triggerPortStartArray[i] +"|"
				+ triggerPortEndArray[i] +"|"
				+ openProtocolArray[i] +"|"
				+ openPortStartArray[i] +"|"			
				+ openPortEndArray[i] +"' ></td>");
			document.writeln("</tr>");
			curObjRows++;
		}
	}
}

function addClick() {
   var loc = 'scprttrg.html';
   var code = 'location="' + loc + '"';
   eval(code);
}

function removeClick(rml) {
   var lst = '';
   var rmlnum = 0;
   if (rml.length > 0){
      for (i = 0; i < rml.length; i++) {
         if ( rml[i].checked == true ){
            lst += rml[i].value + ',';
	     rmlnum++;
         }
      }
      if(rmlnum > 10){
         alert(_("natPortTriggeralert1"));
         return;
      }	  
   }
   else if ( rml.checked == true )
      lst = rml.value;
   var loc = 'scprttrg.cmd?action=remove&rmLst=' + lst + '&' + locationQuery;
   var code = 'location="' + loc + '"';
   eval(code);
}

// done hiding -->
</script>

</head>
<body onLoad='frmLoad()'>
<blockquote> 
  <form>
    <b><span id='scprttrgview_title'>NAT -- Port Triggering Setup</span></b><br>
    <br><span id='scprttrgview_guid1'>Some applications require that specific ports in the Router's firewall be opened for access 
    by the remote parties. Port Trigger dynamically opens up the 'Open Ports' in the firewall when 
    an application on the LAN initiates a TCP/UDP connection to a remote party using the 'Triggering 
    Ports'. The Router allows the remote party from the WAN side to establish new connections back 
    to the application on the LAN side using the 'Open Ports'.  A maximum</span> 
    <script language="javascript"> 
	<!-- hide 
		document.writeln("<b>" + maxEntry + "</b>");
	// done hiding -->
    </script>
     <span id='scprttrgview_guid2'> entries can be configured.</span><br>
    <br>
    <tr>
        <td><b id='natPortTriggerRemainNumTip1'>Due to limited resources, port triggering feature has some limitation:</b></td>
    </tr><br>
    <tr>
        <td><b id='natPortTriggerRemainNumTip2'>sum of the outports of all configuration entries </b>
               <b> <= <%ejGet(PT_MAX_PORTS)%></b>
        </td>
    </tr><br>
    <tr>
        <td><b id='natPortTriggerRemainNumTip3'>sum of the inports of one configuration entry </b>
               <b> <= <%ejGet(PT_MAX_EXPECTED)%></b>
        </td>
    </tr><br>
    <br>
    <center>
	<table border='1' cellpadding='4' cellspacing='0'>
	   <tr align='center'>
	      <td class='hd' rowspan=3 id='scprttrgview_app'>Application Name</td>
	      <td class='hd' colspan=3 id='scprttrgview_trigger'>Trigger</td>
	      <td class='hd' colspan=3 id='scprttrgview_open'>Open</td>
	      <td class='hd' rowspan=3 id='scprttrgview_wanInter'>WAN Interface</td>
	      <td class='hd' rowspan=3 id='scprttrgview_remove'>Remove</td>
	   </tr>
	   <tr align='center'>
	      <td class='hd' rowspan=2 id='scprttrgview_protocol'>Protocol</td>
	      <td class='hd' colspan=2 id='scprttrgview_porRange'>Port Range</td>
	      <td class='hd' rowspan=2 id='scprttrgview_protocol1'>Protocol</td>
	      <td class='hd' colspan=2 id='scprttrgview_porRange1'>Port Range</td>
	   </tr>
	   <tr align='center'>
	      <td class='hd' id='scprttrgview_start'>Start</td>
	      <td class='hd' id='scprttrgview_end'>End</td>
	      <td class='hd' id='scprttrgview_start1'>Start</td>
	      <td class='hd' id='scprttrgview_end1'>End</td>
	   </tr>
	<script language='javascript'>
	<!--hide
		fillObj1Items();
		fillObj2Items();
	//-->
      </script>
      </table>
      <br>
      <br>
	    <script language="javascript"> 
	    <!-- hide 
	        if(curObjRows < parseInt(maxEntry)){
	            document.writeln("<input type='button' onClick='addClick()' value='Add' id='scprttrgview_add'>");
		 }else{
	            document.writeln("<input type='button' onClick='addClick()' value='Add' disabled id='scprttrgview_add1'>");
		 }
	        if(curObjRows > 0){
	            document.writeln("<input type='button' onClick='removeClick(this.form.rml)' value='Remove' id='scprttrgview_remove'>");
		 }else{
	            document.writeln("<input type='button' onClick='removeClick(this.form.rml)' value='Remove' disabled id='scprttrgview_remove1'>");
		 }
	    // done hiding -->
	    </script>
    </center>
  </form>
</blockquote>
</body>
</html>
