function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
function sTrim(I)
{
  var p=0;
  var q=0;
  var sL;
  var sTemp;
  sL=I.value.length;
  sTemp=I.value; 
  if (sL>0)
  {
      while(sTemp.charAt(p)==' ') p++;
	  while(sTemp.charAt((sL-1)-q)==' ') q++;
  }
  if (p==sL)
  I.value="";
  else
  I.value=sTemp.substring(p,sL-q);

}
/**********open port*******************/
var wPo1=null;
var wPo2=null;
var wPo3=null;
var wPo4=null;
var wPo5=null;
var wPo6=null;
var wPo7=null;
var wPo8=null;
var wDMZ=null;
var wWAN=null;

function openPort(n)
{
	
    switch (n)
    {	
    	case '1':
    	        if (wPo1!=null) closePort(wPo1);
    	 	wPo1=window.open('port1_information.htm','po1','menubar=no,scrollbars,width=650,height=530');
    	break;
  	case '2': 
  		if (wPo2!=null) closePort(wPo2);
  		wPo2=window.open('port2_information.htm','po2','menubar=no,scrollbars,width=650,height=530');
  	break;
  	case '3':
  		if (wPo3!=null) closePort(wPo3);
  		wPo3=window.open('port3_information.htm','po3','menubar=no,scrollbars,width=650,height=530');
  	break;
  	case '4':
  		if (wPo4!=null) closePort(wPo4);
  		wPo4=window.open('port4_information.htm','po4','menubar=no,scrollbars,width=650,height=530');
  	break;
  	case '5': 
  		if (wPo5!=null) closePort(wPo5);
  		wPo5=window.open('port5_information.htm','po5','menubar=no,scrollbars,width=650,height=530');
  	break;
  	case '6': 
  		if (wPo6!=null) closePort(wPo6);
  		wPo6=window.open('port6_information.htm','po6','menubar=no,scrollbars,width=650,height=530');
  	break;
  	case '7':
  		if (wPo7!=null) closePort(wPo7);
  		wPo7=window.open('port7_information.htm','po7','menubar=no,scrollbars,width=650,height=530');
  	break;
  	case '8':
  		if (wPo8!=null) closePort(wPo8);
  		wPo8=window.open('port8_information.htm','po8','menubar=no,scrollbars,width=650,height=530');
  	break;
  	case '9':
  		if (wDMZ!=null) closePort(wDMZ);
  		wDMZ=window.open('dmz_port_information.htm','dmz','menubar=no,scrollbars,width=650,height=530');  
  	break;
  	case '10': 
  		if (wWAN!=null) closePort(wWAN);              
  		wWAN=window.open('wan_port_information.htm','wan','menubar=no,scrollbars,width=650,height=530');
  	break;
  	default:
  	
  	break;
    }

}
function closePort(wThis)
{
    if (wThis!=null)
    {
      wThis.close();
      wThis=null;
    }
}
/**************************************/
/*********open waiting*******************/
var wWait=null;
function openWait()
{
    if (wWait!=null) closeWait(wWait);
    wWait=window.open('waiting.htm','sWait','menubar=no,width=300,height=50');		
	
}
function closeWait(wThis)
{
    if (wThis!=null)
    {
      wThis.close();
      wThis=null;
    }
}
/**************************************/
/*********open table*******************/
var wPortRange_table=null;
var wUPnP_table=null;
var wRouting_table=null;
var wVpnSetting=null;
var wgroup_list1=null;
var wgroup_list2=null;
var wsys_log=null;
var woutgoing_log=null;
var wincoming_log=null;

function openTable(n)
{
    switch (n)
    {
    	case 'PortRange_table.htm':  	        
    	        if (wPortRange_table!=null) closeTable(wPortRange_table);
    		wPortRange_table=window.open('PortRange_table.htm','PortRange_table','resizable,menubar=no,scrollbars,width=820');
    	break;
    	case 'UPnP_table.htm':    	        
    	        if (wUPnP_table!=null) closeTable(wUPnP_table);
    		wUPnP_table=window.open('UPnP_table.htm','UPnP_table','resizable,menubar=no,scrollbars,width=820');
    	break;    
    	case 'Routing_table.htm':    	        
    	        if (wRouting_table!=null) closeTable(wRouting_table);
    		wRouting_table=window.open('Routing_table.htm','Routing_table','resizable,menubar=no,scrollbars,width=820');
    	break;  
    	case 'VpnSetting.htm':    	        
    	        if (wVpnSetting!=null) closeTable(wVpnSetting);
    		wVpnSetting=window.open('VpnSetting.htm','VpnSetting','resizable,menubar=yes,scrollbars,width=820');
    	break; 
    	case 'group_list1.htm':    	        
    	        if (wgroup_list1!=null) closeTable(wgroup_list1);
    		wgroup_list1=window.open('group_list1.htm','group_list1','resizable,menubar=no,scrollbars,width=820');
    	break;    
    	case 'group_list2.htm':    	        
    	        if (wgroup_list2!=null) closeTable(wgroup_list2);
    		wgroup_list2=window.open('group_list2.htm','group_list2','resizable,menubar=no,scrollbars,width=820');
    	break;    
    	case 'sys_log.htm':    	        
    	        if (wsys_log!=null) closeTable(wsys_log);
    		wsys_log=window.open('sys_log.htm','sys_log','resizable,menubar=no,scrollbars,width=820');
    	break;   
    	case 'outgoing_log.htm':    	        
    	        if (woutgoing_log!=null) closeTable(woutgoing_log);
    		woutgoing_log=window.open('outgoing_log.htm','outgoing_log','resizable,menubar=no,scrollbars,width=820');
    	break; 
    	case 'incoming_log.htm':    	        
    	        if (wincoming_log!=null) closeTable(wincoming_log);
    		wincoming_log=window.open('incoming_log.htm','incoming_log','resizable,menubar=no,scrollbars,width=820');
    	break;     	    	    	   	   	    	    		
    	default:
    	
    	
    	break;
    }	
    
}
function closeTable(wThis)
{
    if (wThis!=null)
    {
      wThis.close();
      wThis=null;
    }
}
/***************************************/
/*********open wizard*******************/
var wWizard=null;
function openWizard(n)
{
      if (wWizard!=null) closeWizard();

      switch (n)
      {
          case '1':
    	      wWizard=window.open('wizard_basic.htm','wizard','menubar=no,scrollbars,width=570,height=490');
    	  break;
	  case '2':
	      wWizard=window.open('Wizard-Access-Rule-Wizard.htm','wizard','menubar=no,scrollbars,width=570,height=490');
	  break;	
 	  case '3':
	      wWizard=window.open('wizard_vpn.htm','wizard','menubar=no,scrollbars,width=570,height=590');
	  break;	    
	  default:
	  
	  break;
      }


}
function closeWizard()
{
  if (wWizard!=null)
  {
    wWizard.close();
	wWizard=null;
  }
}
function WizardTo(p)
{
  document.location.href=p; 
  closeWizard(); 
}
/******************************************/
/*********open Linksys Web Site*******************/
var wDownload=null;
var wManual=null;
var wWeb=null;

function openLinksys(n)
{
      switch (n)
      {
          case 'Download':
              if (wDownload!=null) closeLinksys(wDownload);
    	      wDownload=window.open('http://www.linksys.com/download/','Download','');
    	  break;
          case 'Manual':
              if (wManual!=null) closeLinksys(wManual);
    	      wManual=window.open('http://linksys.com/support/','Manual','');
    	  break;    
          case 'Web':
              if (wWeb!=null) closeLinksys(wWeb);
    	      wWeb=window.open('http://linksys.com/support/','Web','');
    	  break;         
	  default:
	  
	  break;
      }

}
function closeLinksys(wThis)
{
    if (wThis!=null)
    {
      wThis.close();
      wThis=null;
    }
}
/******************************************/

/*********open help file*******************/
var wHelp=null;

function h_home()
{
    if (wHelp!=null) closeHelp();
    wHelp=window.open('help_home.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_network()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_network.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_password()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_password.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_time()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_time.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_adv_dmz()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_adv_dmz.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_adv_forwarding()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_adv_forwarding.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_adv_upnp()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_adv_upnp.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_adv_nat()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_adv_nat.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_adv_mac()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_adv_mac.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_adv_ddns()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_adv_ddns.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_adv_routing()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_adv_routing.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_adv_through()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_adv_through.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_dhcp_setup()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_dhcp_setup.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_dhcp_status()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_dhcp_status.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_sys_factory()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_factory.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_sys_firmware()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_firmware.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_sys_restart()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_restart.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_sys_dualwan()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_dualwan.htm','help','resizable,scrollbars,width=660,height=600');

}
/* 2004/07/26 Eric */
function h_sys_dualwan1()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_dualwan1.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_sys_dualwan2()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_dualwan2.htm','help','resizable,scrollbars,width=660,height=600');

}
// <-- Eric
function h_sys_snmp()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_snmp.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_sys_diag()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_diag.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_sys_setting()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_sys_setting.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_lan_setting()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_lan_setting.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_lan_status()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_lan_status.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_f_general()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_f_general.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_access_rules()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_access_rules.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_edit_access_rules()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_edit_access_rules.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_content_filter()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_content_filter.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_vpn_summary()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_vpn_summary.htm','help','resizable,scrollbars,width=660,height=600');

}
/* 2004/07/29 Eric */
function h_vpn_summary_rw()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_vpn_summary_rw.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_vpn_clients()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_vpn_clients.htm','help','resizable,scrollbars,width=660,height=600');

}
// <-- Eric
function h_addvpn_mode_choose()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_addvpn_mode_choose.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_gateway_to_gateway()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_gateway_to_gateway.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_client_to_gateway_t()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_client_to_gateway_t.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_client_to_gateway_g()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_client_to_gateway_g.htm','help','resizable,scrollbars,width=660,height=600');

}
/* 2004/08/24 Eric */
function h_pptp()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_pptp.htm','help','resizable,scrollbars,width=660,height=600');

}
// <-- Eric
function h_log_setting()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_log_setting.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_log_report()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_log_report.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_wizard()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_wizard.htm','help','resizable,scrollbars,width=660,height=600');

}
function h_support()
{
    if (wHelp!=null) closeHelp();	
    wHelp=window.open('help_support.htm','help','resizable,scrollbars,width=660,height=600');

}

function closeHelp()
{
  if (wHelp!=null)
  {
    wHelp.close();
	wHelp=null;
  }
}
/******************************************/
/********************************************************************************************/
/* 2004/08/18 Eric --> Network Check */
function IpToArray(V, n) // IP (or Mask) value [ex: 192.168.1.1], want to get IP index (1~4)
{
    var ip1,ip2,ip3,ip4;
	var p,q,rightString,tmpString;

    rightString=V;
/**/
    q=rightString.length;
    p=rightString.indexOf(".");
    ip1=rightString.substring(0,p); 
    tmpString=rightString;
    rightString=tmpString.substring(p+1,q); 
/*.*/

    q=rightString.length;
    p=rightString.indexOf(".");
    ip2=rightString.substring(0,p); 
    tmpString=rightString;
    rightString=tmpString.substring(p+1,q); 
/*.*/

    q=rightString.length;
    p=rightString.indexOf(".");
    ip3=rightString.substring(0,p); 
    tmpString=rightString;
    
/*.*/
	ip4=tmpString.substring(p+1,q); 

/*.*/
    if (n=="1") return ip1;
	if (n=="2") return ip2;
	if (n=="3") return ip3;
	if (n=="4") return ip4;	// get IP index (1~4)
}
function NetworkToArray(ip, mask, n) // IP value [ex: 192.168.1.1], Mask value [ex: 255.255.255.0], want to get NETWORK ID index (1~4)
{
    var ip1,ip2,ip3,ip4;
	var mask1,mask2,mask3,mask4;
    var network1,network2,network3,network4;
	
	ip1=IpToArray(ip, '1');
	ip2=IpToArray(ip, '2');
	ip3=IpToArray(ip, '3');
	ip4=IpToArray(ip, '4');
	
	mask1=IpToArray(mask, '1');
	mask2=IpToArray(mask, '2');
	mask3=IpToArray(mask, '3');
	mask4=IpToArray(mask, '4');
	
	network1 = ip1 & mask1; 
	network2 = ip2 & mask2;
	network3 = ip3 & mask3; 
	network4 = ip4 & mask4; 
	
	if (n=="1") return network1;
	if (n=="2") return network2;
	if (n=="3") return network3;
	if (n=="4") return network4; // get NETWORK ID index (1~4)
}

function ArrayNetworkCheck(lanIp, lanMask, I, n) // LAN IP value [ex: 192.168.1.1], LAN Mask value [ex: 255.255.255.0], this text object, input this ip index (1~4)
{   
	var lanNetworkArray;
	var thisNetworkArray;
		
	lanNetworkArray = NetworkToArray(lanIp, lanMask, n);
	thisNetworkArray = I.value & IpToArray(lanMask, n);
	
	if (lanNetworkArray!=thisNetworkArray)
	{
	    alert("Out of Network!");
		I.value=I.defaultValue;
		return -1;
	}
	
	return 1; // Check the same network OK!

}
// <-- Eric
/*****************************pages.js**********************************************************/
// 2004/08/18 Eric --> Check Local Security Group IP Address and Remote Security Group IP Address in the same network.
function chSameLsgRsg()
{
    var lsg_ip1, lsg_ip2, lsg_ip3, lsg_ip4, lsg_ip5;
	var lsg_ip, lsg_ip123, lsg_ips, lsg_ipe;
	var lsg_network1, lsg_network2, lsg_network3, lsg_network4;
	var lsg_network, lsg_network123;
	var lsg_mask1, lsg_mask2, lsg_mask3, lsg_mask4;
	
	var rsg_ip1, rsg_ip2, rsg_ip3, rsg_ip4, rsg_ip5;
	var rsg_ip, rsg_ip123, rsg_ips, rsg_ipe;
	var rsg_network1, rsg_network2, rsg_network3, rsg_network4;
	var rsg_network, rsg_network123;
	var rsg_mask1, rsg_mask2, rsg_mask3, rsg_mask4;
	
	var big_mask1, big_mask2, big_mask3, big_mask4;
		
	var cSameLsgRsg="The settings of Local Security Group conflict with the settings of Remote Security Group. Press 'Ok' to save settings, or press 'Cancel' to undo the changes.";	
	
	/* Initial Value */
	if (document.formgtg.ipLSG1[1])
	{
	    lsg_ip1 = document.formgtg.ipLSG1[1].value;
		lsg_ip2 = document.formgtg.ipLSG2[1].value;
		lsg_ip3 = document.formgtg.ipLSG3[1].value;
		lsg_ip4 = document.formgtg.ipLSG4[1].value;
		lsg_ip = lsg_ip1+"."+lsg_ip2+"."+lsg_ip3+"."+lsg_ip4;
		lsg_ip123 = lsg_ip1+"."+lsg_ip2+"."+lsg_ip3;
		
	}
	
	if (document.formgtg.rangeLSG[1])
	{
	    lsg_ip5 = document.formgtg.rangeLSG[1].value;
		lsg_ip123 = lsg_ip1+"."+lsg_ip2+"."+lsg_ip3;
		if (eval(lsg_ip5) >= eval(lsg_ip4))
		{
		    lsg_ips = lsg_ip4;
			lsg_ipe = lsg_ip5;
		}
		else
		{
		    lsg_ips = lsg_ip5;
			lsg_ipe = lsg_ip4;
		}
	}
	
	if (document.formgtg.smLSG1[1])
	{
	    lsg_mask1 = document.formgtg.smLSG1[1].value;
		lsg_mask2 = document.formgtg.smLSG2[1].value;
		lsg_mask3 = document.formgtg.smLSG3[1].value;
		lsg_mask4 = document.formgtg.smLSG4[1].value;
		
		lsg_network1 = lsg_ip1 & lsg_mask1;
		lsg_network2 = lsg_ip2 & lsg_mask2;
		lsg_network3 = lsg_ip3 & lsg_mask3;
		lsg_network4 = lsg_ip4 & lsg_mask4;
		lsg_network = lsg_network1+"."+lsg_network2+"."+lsg_network3+"."+lsg_network4;
		lsg_network123 = lsg_network1+"."+lsg_network2+"."+lsg_network3;
	}
	
	if (document.formgtg.ipRSG1[1])
	{
	    rsg_ip1 = document.formgtg.ipRSG1[1].value;
		rsg_ip2 = document.formgtg.ipRSG2[1].value;
		rsg_ip3 = document.formgtg.ipRSG3[1].value;
		rsg_ip4 = document.formgtg.ipRSG4[1].value;	
		rsg_ip = rsg_ip1+"."+rsg_ip2+"."+rsg_ip3+"."+rsg_ip4;
		rsg_ip123 = rsg_ip1+"."+rsg_ip2+"."+rsg_ip3;
	}
	
	if (document.formgtg.rangeRSG[1])
	{
	    rsg_ip5 = document.formgtg.rangeRSG[1].value;
		rsg_ip123 = rsg_ip1+"."+rsg_ip2+"."+rsg_ip3;
		if (eval(rsg_ip5) >= eval(rsg_ip4))
		{
		    rsg_ips = rsg_ip4;
			rsg_ipe = rsg_ip5;
		}
		else
		{
		    rsg_ips = rsg_ip5;
			rsg_ipe = rsg_ip4;
		}
	}
	
	if (document.formgtg.smRSG1[1])
	{
	    rsg_mask1 = document.formgtg.smRSG1[1].value;
		rsg_mask2 = document.formgtg.smRSG2[1].value;
		rsg_mask3 = document.formgtg.smRSG3[1].value;
		rsg_mask4 = document.formgtg.smRSG4[1].value;
		
		rsg_network1 = rsg_ip1 & rsg_mask1;
		rsg_network2 = rsg_ip2 & rsg_mask2;
		rsg_network3 = rsg_ip3 & rsg_mask3;
		rsg_network4 = rsg_ip4 & rsg_mask4;	
		rsg_network = rsg_network1+"."+rsg_network2+"."+rsg_network3+"."+rsg_network4;
		rsg_network123 = rsg_network1+"."+rsg_network2+"."+rsg_network3;
	}
	/* <-- */
	
    if (document.formgtg.typeLSG[1])
    if (document.formgtg.typeLSG[1].selectedIndex == 0) // IP
	{
        if (document.formgtg.typeRSG[1])
        if (document.formgtg.typeRSG[1].selectedIndex == 0) // IP
	    {
            if (lsg_ip == rsg_ip)
			{
			    if (!confirm(cSameLsgRsg)) return -1;
			    return 1;			
			}
	
	    }
	    else if (document.formgtg.typeRSG[1].selectedIndex == 1) // Mask
	    {
	        lsg_network1 = lsg_ip1 & rsg_mask1;
			lsg_network2 = lsg_ip2 & rsg_mask2;
			lsg_network3 = lsg_ip3 & rsg_mask3;
			lsg_network4 = lsg_ip4 & rsg_mask4;
			lsg_network = lsg_network1+"."+lsg_network2+"."+lsg_network3+"."+lsg_network4;
			if (lsg_network == rsg_network)
			{
			    if (rsg_network != "0.0.0.0")
			    if (!confirm(cSameLsgRsg)) return -1;
			    return 1;
			}
	    }
	    else if (document.formgtg.typeRSG[1].selectedIndex == 2) // Range
	    {
		    if (lsg_ip123 == rsg_ip123)
			{
			    if ((eval(lsg_ip4) >= eval(rsg_ips)) && (eval(lsg_ip4) <= eval(rsg_ipe)))
				{
			            if (!confirm(cSameLsgRsg)) return -1;
			    	    return 1;
				}			
			}
	    }
	
	}
	else if (document.formgtg.typeLSG[1].selectedIndex == 1) // Mask
	{
        if (document.formgtg.typeRSG[1])
        if (document.formgtg.typeRSG[1].selectedIndex == 0) // IP
	    {
	        rsg_network1 = rsg_ip1 & lsg_mask1;
			rsg_network2 = rsg_ip2 & lsg_mask2;
			rsg_network3 = rsg_ip3 & lsg_mask3;
			rsg_network4 = rsg_ip4 & lsg_mask4;
			rsg_network = rsg_network1+"."+rsg_network2+"."+rsg_network3+"."+rsg_network4;
			
			if (lsg_network == rsg_network)
			{
			    if (lsg_network != "0.0.0.0")
			    if (!confirm(cSameLsgRsg)) return -1;
			    return 1;
			}	
	    }
	    else if (document.formgtg.typeRSG[1].selectedIndex == 1) // Mask
	    {
		    big_mask1 = lsg_mask1 & rsg_mask1;
			big_mask2 = lsg_mask2 & rsg_mask2;
			big_mask3 = lsg_mask3 & rsg_mask3;
			big_mask4 = lsg_mask4 & rsg_mask4;
			
			lsg_network1 = lsg_ip1 & big_mask1;
			lsg_network2 = lsg_ip2 & big_mask2;
			lsg_network3 = lsg_ip3 & big_mask3;
			lsg_network4 = lsg_ip4 & big_mask4;
			lsg_network = lsg_network1+"."+lsg_network2+"."+lsg_network3+"."+lsg_network4;
			
			rsg_network1 = rsg_ip1 & big_mask1;
			rsg_network2 = rsg_ip2 & big_mask2;
			rsg_network3 = rsg_ip3 & big_mask3;
			rsg_network4 = rsg_ip4 & big_mask4;
			rsg_network = rsg_network1+"."+rsg_network2+"."+rsg_network3+"."+rsg_network4;
						
			if (lsg_network == rsg_network)
			{
			    if (lsg_network != "0.0.0.0")	
			    if (!confirm(cSameLsgRsg)) return -1;
			    return 1;
			}	
	    }
	    else if (document.formgtg.typeRSG[1].selectedIndex == 2) // Range
	    {
	    	rsg_network1 = rsg_ip1 & lsg_mask1;
	        rsg_network2 = rsg_ip2 & lsg_mask2;
	        rsg_network3 = rsg_ip3 & lsg_mask3;
	        rsg_network123 = rsg_network1+"."+rsg_network2+"."+rsg_network3;
	        
	        if (lsg_network123 == rsg_network123)	    
	        if ((lsg_mask1 == 255) && (lsg_mask2 == 255) && (lsg_mask3 == 255))
			{
			    lsg_ips = lsg_network4;
				lsg_ipe = eval(lsg_network4)+255-eval(lsg_mask4);
				
				if (((eval(lsg_ips) >= eval(rsg_ips)) && (eval(lsg_ips) <= eval(rsg_ipe)))
				 || ((eval(lsg_ipe) >= eval(rsg_ips)) && (eval(lsg_ipe) <= eval(rsg_ipe))))
				{
				    if (lsg_network != "0.0.0.0")
				    if (!confirm(cSameLsgRsg)) return -1;
			    	    return 1;
				}
				
				if (((eval(rsg_ips) >= eval(lsg_ips)) && (eval(rsg_ips) <= eval(lsg_ipe)))
				 || ((eval(rsg_ipe) >= eval(lsg_ips)) && (eval(rsg_ipe) <= eval(lsg_ipe))))
				{
				    if (lsg_network != "0.0.0.0")
				    if (!confirm(cSameLsgRsg)) return -1;
			            return 1;
				}
			
			}
		        else
		        {
		            if (lsg_network != "0.0.0.0")
			    if (!confirm(cSameLsgRsg)) return -1;
			    return 1;			        	
		        }				
	    }	    
	}
	else if (document.formgtg.typeLSG[1].selectedIndex == 2) // Range
	{
        if (document.formgtg.typeRSG[1])
        if (document.formgtg.typeRSG[1].selectedIndex == 0) // IP
	    {
		    if (lsg_ip123 == rsg_ip123)
			{
			    if ((eval(rsg_ip4) >= eval(lsg_ips)) && (eval(rsg_ip4) <= eval(lsg_ipe)))
				{
			            if (!confirm(cSameLsgRsg)) return -1;
			            return 1;
				}			
			}	    	
	
	    }
	    else if (document.formgtg.typeRSG[1].selectedIndex == 1) // Mask
	    {
	    	lsg_network1 = lsg_ip1 & rsg_mask1;
	        lsg_network2 = lsg_ip2 & rsg_mask2;
	        lsg_network3 = lsg_ip3 & rsg_mask3;
	        lsg_network123 = lsg_network1+"."+lsg_network2+"."+lsg_network3;
	        
	        if (lsg_network123 == rsg_network123)
	        if ((rsg_mask1 == 255) && (rsg_mask2 == 255) && (rsg_mask3 == 255))
			{
			    rsg_ips = rsg_network4;
				rsg_ipe = eval(rsg_network4)+255-eval(rsg_mask4);
				
				if (((eval(lsg_ips) >= eval(rsg_ips)) && (eval(lsg_ips) <= eval(rsg_ipe)))
				 || ((eval(lsg_ipe) >= eval(rsg_ips)) && (eval(lsg_ipe) <= eval(rsg_ipe))))
				{
				    if (rsg_network != "0.0.0.0")
				    if (!confirm(cSameLsgRsg)) return -1;
			            return 1;
				}
				
				if (((eval(rsg_ips) >= eval(lsg_ips)) && (eval(rsg_ips) <= eval(lsg_ipe)))
				 || ((eval(rsg_ipe) >= eval(lsg_ips)) && (eval(rsg_ipe) <= eval(lsg_ipe))))
				{
				    if (rsg_network != "0.0.0.0")	
				    if (!confirm(cSameLsgRsg)) return -1;
			            return 1;
				}
			
			}
		        else
		        {		            
	           	    if (rsg_network != "0.0.0.0")
		   	    if (!confirm(cSameLsgRsg)) return -1;
		   	    return 1;		    		   		        	
		        }	
	    }
	    else if (document.formgtg.typeRSG[1].selectedIndex == 2) // Range
	    {
	        if (lsg_ip123 == rsg_ip123)
			{
				
				if (((eval(lsg_ips) >= eval(rsg_ips)) && (eval(lsg_ips) <= eval(rsg_ipe)))
				 || ((eval(lsg_ipe) >= eval(rsg_ips)) && (eval(lsg_ipe) <= eval(rsg_ipe))))
				{
				    if (!confirm(cSameLsgRsg)) return -1;
			            return 1;
				}
				
				if (((eval(rsg_ips) >= eval(lsg_ips)) && (eval(rsg_ips) <= eval(lsg_ipe)))
				 || ((eval(rsg_ipe) >= eval(lsg_ips)) && (eval(rsg_ipe) <= eval(lsg_ipe))))
				{
				    if (!confirm(cSameLsgRsg)) return -1;
			            return 1;
				}
			
			}		
	    }	
	}
	
    return 1;
} 
// <-- Eric