<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, rtMaxStaticEntry)%>';
var obj1Items = '<%ejGetObject(MDMOID_DEV2_IPV4_FORWARDING)%>';

var staticRoute = numOfRow(obj1Items)-numOfPolicyRoute(obj1Items)/*numOfRow(obj1Items)*/;  
var obj1Rows =  numOfRow(obj1Items);
/* NOTICE: MDMOID_L3_FORWARDING_ENTRY is Type1/Type2 object, follow variables are arrays */
var dstAddrArray = getColFromList(obj1Items, 'DestIPAddress');
var destSubnetMask = getColFromList(obj1Items, 'DestSubnetMask');
var dstGtwyArray = getColFromList(obj1Items, 'GatewayIPAddress');
var wanIfArray = getColFromList(obj1Items, 'X_BROADCOM_COM_Interface');
var metricArray = getColFromList(obj1Items, 'ForwardingMetric');
var sourceIPAddressArray = getColFromList(obj1Items, 'X_BROADCOM_COM_SourceIPAddress');
var SourceIfNameArray = getColFromList(obj1Items, 'X_BROADCOM_COM_SourceIfName');
var PolicyRoutingNameArray = getColFromList(obj1Items, 'X_BROADCOM_COM_PolicyRoutingName');
var isStaticRoute = getColFromList(obj1Items, 'StaticRoute');

var obj2Items = '<%ejGetObject(MDMOID_DEV2_IPV6_FORWARDING)%>';
var obj2Rows = numOfRow(obj2Items);
var obj2_dstAddrArray = getColFromList(obj2Items, 'DestIPPrefix');
var obj2_dstGtwyArray = getColFromList(obj2Items, 'NextHop');
var obj2_wanIfArray = getColFromList(obj2Items, 'Interface');
var obj2_metricArray = getColFromList(obj2Items,'ForwardingMetric');

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



function initTranslation() {
	var idArray = new Array("rtroutecfgTitle1", "rtroutecfgTitle2", "rtroutecfgIPVersion", "rtroutecfgDstIP", "rtroutecfgGateWay", "rtroutecfgInterface", "rtroutecfgMetric", "rtroutecfgRemove", "rtroutecfgBtnAdd1", "rtroutecfgBtnAdd2", "rtroutecfgBtnRemove1", "rtroutecfgBtnRemove2");
	setAllIdValue(idArray);
}

function frmLoad() {
	initTranslation();
}

function fillObj1Items(){
	var i;
	for(i=0; i < obj1Rows; i++){
//		if ( PolicyRoutingNameArray[i] == "")
	        if((sourceIPAddressArray[i]=="")&&(SourceIfNameArray[i]=="") && isStaticRoute[i] == "1")
		{
			document.writeln("<tr>");
			document.writeln("<td class='tablesize'> 4 </td>");
			document.writeln("<td class='tablesize'>"+ dstAddrArray[i] +"/"+destSubnetMask[i]+"</td>");
			if (dstGtwyArray[i] == "")
				document.writeln("<td class='tablesize'>&nbsp;</td>");
			else
				document.writeln("<td class='tablesize'>"+ dstGtwyArray[i] +"</td>");
			document.writeln("<td class='tablesize'>"+ wanIfArray[i] +"</td>");
			if (metricArray[i] != -1)
				document.writeln("<td class='tablesize'>"+ metricArray[i] +"</td>");
			else
				document.writeln("<td class='tablesize'>&nbsp;</td>");
			document.writeln("<td align='center'><input type='checkbox' name='rml' value='" + dstAddrArray[i] +"|" + destSubnetMask[i] + "'></td>");
			document.writeln("</tr>");
		}
	}
}


function fillObj2Items(){
	var i;
	for(i=0; i < obj2Rows; i++){
		document.writeln("<tr>");
		document.writeln("<td class='tablesize'> 6 </td>");
		document.writeln("<td class='tablesize'>"+ obj2_dstAddrArray[i] +"</td>");
		document.writeln("<td class='tablesize'>"+ obj2_dstGtwyArray[i] +"</td>");
		document.writeln("<td class='tablesize'>"+ obj2_wanIfArray[i] +"</td>");
		if (obj2_metricArray[i] != -1)
			document.writeln("<td class='tablesize'>"+ obj2_metricArray[i] +"</td>");
		else
			document.writeln("<td class='tablesize'>&nbsp;</td>");
		document.writeln("<td align='center'><input type='checkbox' name='rml' value=" + obj2_dstAddrArray[i]+ "></td>");
		document.writeln("</tr>");		
	}
}

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

function removeClick(rml) {
   var lst = '';
   if (rml.length > 0)
      for (i = 0; i < rml.length; i++) {
         if ( rml[i].checked == true )
            lst += rml[i].value + ', ';
      }
   else if ( rml.checked == true )
      lst = rml.value;

   var loc = 'rtroutecfg.cmd?action=remove&rmLst=' + lst + '&' + locationQuery;
   var code = 'location="' + loc + '"';
   eval(code);
}

// done hiding -->
</script>

   </head>
   <body onLoad='frmLoad()'>
      <blockquote>
         <form>
            <b><span id='rtroutecfgTitle1'>Routing -- Static Route (A maximum</span></b>
		<script language="javascript"> 
		<!-- hide 
			document.writeln("<b>" + maxEntry + "</b>");
		// done hiding -->
		</script>
            <b><span id='rtroutecfgTitle2'>entries can be configured)</span></b><br><br>
            <center>
            <table border='1' cellpadding='4' cellspacing='0'>
               <tr>
                  <td class='hd' id='rtroutecfgIPVersion'>IP Version</td>
                  <td class='hd' id='rtroutecfgDstIP'>DstIP/Mask</td>
                  <td class='hd' id='rtroutecfgGateWay'>Gateway</td>
                  <td class='hd' id='rtroutecfgInterface'>Interface</td>
                  <td class='hd' id='rtroutecfgMetric'>Metric</td>
                  <td class='hd' id='rtroutecfgRemove'>Remove</td>
               </tr>
               <script language='javascript'>
               <!--hide
                   fillObj1Items();
		     fillObj2Items();
               //-->
               </script>
            </table>
            <br>
            <script language="javascript"> 
            <!-- hide 
                if(staticRoute+obj2Rows < parseInt(maxEntry)){
                    document.writeln("<input type='button' onClick='addClick()' value='Add' id='rtroutecfgBtnAdd1'>");
		  }else{
                    document.writeln("<input type='button' onClick='addClick()' value='Add' disabled id='rtroutecfgBtnAdd2'>");
		  }
                if(staticRoute+obj2Rows > 0){
                    document.writeln("<input type='button' onClick='removeClick(this.form.rml)' value='Remove' id='rtroutecfgBtnRemove1'>");
		  }else{
                    document.writeln("<input type='button' onClick='removeClick(this.form.rml)' value='Remove' disabled id='rtroutecfgBtnRemove2'>");
		  }
            // done hiding -->
            </script>
            </center>
         </form>
      </blockquote>
   </body>
</html>

