<%ejGetOther(file, header.html)%>
<script language="javascript"><%ejGetOther(forbidHTMLCode)%></script>
<script language="javascript" src="util.js"></script>
<script language="javascript"> 
<!-- hide 

var maxEntry = '8';
var curObjRows = 0;

var obj1Items = '<%ejGetOther(table, gretunnels)%>';
var obj1Rows = numOfRow(obj1Items);
var Enable = getColFromList(obj1Items, "Enable");
var TunnelName = getColFromList(obj1Items, "X_BROADCOM_COM_TunnelName");
var WanInterface = getColFromList(obj1Items, "X_BROADCOM_COM_AssociatedWanIfName");
var RemoteGateway = getColFromList(obj1Items, "RemoteEndpoints");
var TunnelSourceIP = getColFromList(obj1Items, "X_BROADCOM_COM_TunnelSourceIP");
var TunnelMask = getColFromList(obj1Items, "X_BROADCOM_COM_TunnelMask");
var TunnelPeerIp = getColFromList(obj1Items, "ConnectedRemoteEndpoint");
var locationQuery='sessionKey=<%ejGetOther(sessionKey)%>';

function frmLoad() {
	//initTranslation();

}

function fillObj1Items(){
	var i;
	var porttmp=0;
	for(i=0; i < obj1Rows; i++){
	document.writeln("<tr>");
	document.writeln("<td class='tablesize'>&nbsp;"+ TunnelName[i] +"</td>");
	document.writeln("<td class='tablesize'>&nbsp;"+ WanInterface[i] +"</td>");
	document.writeln("<td class='tablesize'>&nbsp;"+ RemoteGateway[i]+"</td>");
	document.writeln("<td class='tablesize'>&nbsp;"+ TunnelSourceIP[i] +"</td>");
	document.writeln("<td class='tablesize'>&nbsp;"+ TunnelMask[i] +"</td>");
	document.writeln("<td class='tablesize'>&nbsp;"+ TunnelPeerIp[i] +"</td>");
	document.writeln("<td align='center'><input type='checkbox' name='gretunnelebl' value='" + TunnelName[i] + "' ");
	   
	if(Enable[i] == 1){
	     document.writeln(" checked></td>");
	}
	else{
	     document.writeln(" ></td>");
	}

	document.writeln("<td align='center'><input type='checkbox' name='rml' value='" + TunnelName[i] + "' ></td>");
	document.writeln("</tr>");
	curObjRows++;
	}
}

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

function saveapplyClick(ebl) {                                                                                
   var eblLst = '';

   if (ebl.length > 0)
      for (i = 0; i < ebl.length; i++) {
         if ( ebl[i].checked == true )
            eblLst += ebl[i].value + '|1,';
         else 
            eblLst += ebl[i].value + '|0,';
      }
   else if ( ebl.checked == true )
      eblLst += ebl.value + '|1';
   else
      eblLst += ebl.value + '|0';
                                                                                
   var loc = 'gretunnel.cmd?action=apply&eblLst=' + eblLst + '&' + locationQuery;
   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("Sorry. You could not remove more than 10 entries one time.");
         return;
      }
   }

   else if ( rml.checked == true )
      lst = rml.value;
   var loc = 'gretunnel.cmd?action=remove&rmLst=' + lst + '&' + locationQuery;
   var code = 'location="' + loc + '"';
   eval(code);
}

// done hiding -->
</script></head>
<body onLoad='frmLoad()'>
<blockquote> 
  <form>
    <b><span id='sevrtview_title'>GRE Tunnels</span></b><br>
    <br><span id='sevrtview_tips'></span> 
    <script language="javascript"> 
	<!-- hide 
		document.writeln("<b>" + maxEntry + "</b>");
	// done hiding -->
    </script>
      <span id='sevrtview_tips1'>entries can be configured.</span><br>
    <br>
    <center>
      <table border='1' cellpadding='2' cellspacing='0'>
        <tr> 

          <td class='hd' id='gre_view_TunnelName'>Tunnel Name</td>
          <td class='hd' id='gre_view_WanInterface'>Wan Interface</td>
          <td class='hd' id='gre_view_RemoteGateway'>Remote Gateway</td>
          <td class='hd' id='gre_view_TunnelSourceIP'>Tunnel Source IP</td>
          <td class='hd' id='gre_view_TunnelMask'>Tunnel Mask</td>
          <td class='hd' id='gre_view_TunnelPeerIp'>Tunnel Peer Ip</td>
          <td class='hd' id='gre_view_Enable'>Enable</td>
          <td class='hd' id='gre_view_Remove'>Remove</td> 
        </tr>
        <script language='javascript'>
        <!--hide
		fillObj1Items();
        //-->
        </script>
      </table>
      <br>
      <br>
        <script language="javascript"> 
        <!-- hide 
            if(curObjRows < parseInt(maxEntry)){
                document.writeln("<input type='button' onClick='addClick()' value='Add' id='gre_view_'>");
	     }else{
                document.writeln("<input type='button' onClick='addClick()' value='Add' disabled id='gre_view_'>");
	     }
            if(curObjRows > 0){
                document.writeln("<input type='button' onClick='saveapplyClick(this.form.gretunnelebl)' value='Save/Apply'>");
                document.writeln("<input type='button' onClick='removeClick(this.form.rml)' value='Remove' id='gre_view_'>");
	     }else{
                document.writeln("<input type='button' onClick='saveapplyClick(this.form.gretunnelebl)' value='Save/Apply' disabled>");
                document.writeln("<input type='button' onClick='removeClick(this.form.rml)' value='Remove' disabled id='gre_view_'>");
	     }
        // done hiding -->
        </script>
    </center>
  </form>
</blockquote>
</body>
</html>

