<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" src="portName.js"></script>
<script language="javascript"><%ejGetOther(forbidHTMLCode)%></script>
<script language="javascript"> 
<!-- hide 

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

var maxPrmngrEntries = '<%ejGetOther(sysInfo, maxPrmngrEntry)%>';

var PolicyRoute = numOfPolicyRoute(obj1Items);   //     only policynum
var obj1Rows = numOfRow(obj1Items);             //
/* NOTICE: MDMOID_L3_FORWARDING_ENTRY is Type1/Type2 object, follow variables are arrays */
var PolicyRoutingNameArray = getColFromList(obj1Items, 'X_BROADCOM_COM_PolicyRoutingName');
var sourceIPAddressArray = getColFromList(obj1Items, 'X_BROADCOM_COM_SourceIPAddress');
var SourceIfNameArray = getColFromList(obj1Items, 'X_BROADCOM_COM_SourceIfName');
var interfaceArray = getColFromList(obj1Items, 'X_BROADCOM_COM_Interface');
var gatewayIPAddressArray = getColFromList(obj1Items, 'GatewayIPAddress');
var brdId = '<%ejGet(boardID)%>';

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


function initTranslation() {
	var idArray = new Array("prmngrViewTitle1", "prmngrViewTitle2", "prmngrViewPolicy", "prmngrViewSrcIP", "prmngrViewLanPort", "prmngrViewWAN", "prmngrViewDefaultGW", "prmngrViewRemove", "prmngrViewBtnAdd1", "prmngrViewBtnAdd2", "prmngrViewBtnRemove1", "prmngrViewBtnRemove2");
	setAllIdValue(idArray);
}

function frmLoad() {
	initTranslation();
}

function fillObj1Items(){
	var i;
	for(i=0; i < obj1Rows; i++){
	//	if (PolicyRoutingNameArray[i] !="")
	        if((sourceIPAddressArray[i]!="")||(SourceIfNameArray[i]!=""))
		{
			document.writeln("<tr>");
			document.writeln("<td>&nbsp;"+ PolicyRoutingNameArray[i] +"</td>");
			document.writeln("<td>&nbsp;"+ sourceIPAddressArray[i] +"</td>");
  	              /* convert the linux name to user name, xiongyuanxing on Mar 23, 2012*/
			var dispName = getUNameByLName(brdId + '|' + SourceIfNameArray[i]);
			document.writeln("<td>&nbsp;"+ dispName +"</td>");
			/* end */
			document.writeln("<td>&nbsp;"+ interfaceArray[i] +"</td>");
			document.writeln("<td>&nbsp;"+ gatewayIPAddressArray[i] +"</td>");
			document.writeln("<td align='center'><input type='checkbox' name='rml' value='"+ PolicyRoutingNameArray[i] +"'></td>");
			document.writeln("</tr>");
		}
	}
}

function addClick() {
   var loc = 'pradd.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 = 'prmngr.cmd?action=remove&rmLst=' + lst + "&" + locationQuery;
   var code = 'location=\"' + loc + '\"';
   eval(code);
}

// done hiding -->
</script>

</head>
<body onLoad='frmLoad()'>
<blockquote>
<form>
	<script language='javascript'>
		document.writeln("<b><span id='prmngrViewTitle1'>Policy Routing Setting -- A maximum </span>" + maxPrmngrEntries + "<span id='prmngrViewTitle2'>  entries can be configured.</span></b><br><br>");
	</script>
	<center>
	<table border='1' cellpadding='4' cellspacing='0'>
	<tr>
		<td class='hd' id='prmngrViewPolicy'>Policy Name</td>
		<td class='hd' id='prmngrViewSrcIP'>Source IP</td>
		<td class='hd' id='prmngrViewLanPort'>LAN Port</td>
		<td class='hd' id='prmngrViewWAN'>WAN</td>
		<td class='hd' id='prmngrViewDefaultGW'>Default GW</td>
		<td class='hd' id='prmngrViewRemove'>Remove</td>
	</tr>
	<script language='javascript'>
	<!--hide
		fillObj1Items();
	//-->
	</script>
	</table>
	<br>
	<script language='javascript'>
		if(parseInt(maxPrmngrEntries) > PolicyRoute){
			document.writeln("<input class=\"buttonX\" type='button' onClick='addClick()' value='Add' id='prmngrViewBtnAdd1'>");
		}else{
			document.writeln("<input class=\"buttonX\" type='button' onClick='addClick()' value='Add' disabled id='prmngrViewBtnAdd2'>");
		}
		if( PolicyRoute > 0){
			document.writeln("<input class=\"buttonX\" type='button' onClick='removeClick(this.form.rml)' value='Remove' id='prmngrViewBtnRemove1'>");
		}else{
			document.writeln("<input class=\"buttonX\" type='button' onClick='removeClick(this.form.rml)' value='Remove' disabled id='prmngrViewBtnRemove2'>");
		}
	</script>
	</center>
	<br><br><br>
</form>
</blockquote>
</body>
</html>
