var gCurrentPortPage="http://www.support.dlink.com/emulators/dwl2100ap/PacketsRx.html";
var gCurrentSlot=1;
var gCurrentPort=1;
var gCurrentUnit = 1;
var LAYER2_ONLY=2;
var LAYER2_VLAN=3;
var IP_ROUTING=4;
var IP_ROUTING_VLAN=5;
var IP_SWITCHING=6;
var g_IpNetworkingMode=0;
var g_iUnitSelected=1;
//---added by Olivia Liou for timer control 2001/11/22
//var webTimeout=300;
var webTimeout= 1000;
var Timer_deviceRefresh=0;
var Timer_current=0;
var Timer_reset=0;
var checkWLAN11g=1;
var pageURL=" "http://www.support.dlink.com/emulators/dwl2100ap/;//%20------------%20Do%20PortLink%20Info%20----------------------------function%20doPageLink(num){//alert("dopagelink!");
	if(num==1)
	{
	   if(checkWLAN11g)
	   		parent.location.href="http://www.support.dlink.com/html/CurrentStatus2.html";
	   else
	  		parent.location.href="http://www.support.dlink.com/html/CurrentStatus.html";
    }

	if(num==2)
		parent.location.href="http://www.support.dlink.com/html/SetupWizard.html";
	if(num==3)
		parent.location.href="http://www.support.dlink.com/html/Hmain.html";
	if(num==4)
		parent.location.href="http://www.support.dlink.com/html/MonStat.html";

}

//------------- Do page Link for Setup Wizard ------------------ Added by Olivia
function doSetupLink(action,step,reboot)
{
	if(action==1) //next
	{
		if(step==3)
		   {
		   	//document.forms[0].submit();
		   	window.location.href="http://www.support.dlink.com/html/Setup3Next.html";
		   }
		else if(step!=5)
	  		{
	  			 //alert("start submit");
	  			 //if(step!=1)
	  			  //document.forms[0].submit();
	  			 //alert("end submit");
	  			 window.location.href="/html/setup"+(step+1)+".html";
	  		}

	 	else if(step==5 && reboot==0) // last page continue setting
	  		 {
	  		 	//document.forms[0].submit();
	  		 	window.location.href="http://www.support.dlink.com/html/setup2.html";
	  		 }
	  	else
	  		{
	  			//alert("in 7 and reboot true");
	  			document.forms[0].submit();
	  			//alert("after reboot");
	  		}
	}
	else //0: prev
	{
		if(step==5)
		{
			 //document.forms[0].submit();
		  	window.location.href="http://www.support.dlink.com/html/Setup5Back.html";
		 }
		else
		{	//alert("hi");
		  	 //document.forms[0].submit();
		  	window.location.href="/html/setup"+(step-1)+".html";
		 }
	}
}

//------------------------------------------------------------------
function doSubmit(action,step,reboot)
{
	document.forms[0].submit();
}

//------------------------------------------------------
function doSubmit2()
{
 if(document.forms[0].elements[1].checked==true)
 {
 	if(document.forms[0].QuickKeyString.value=="")
 	{
 	   alert("\n Empty string would not be allowed!"+"\n Please Enter Again.");
 	   document.forms[0].QuickKeyString.select();
 	   return false;
 	}

	if(document.forms[0].QuickKeyString.value!=document.forms[0].CfmQuickKeyString.value)
	{
 		alert("\n The String is not match!"+
 		      "\n Please Enter Again.");
 		document.forms[0].QuickKeyString.select();
 		return false;
 	}
 }
        document.forms[0].submit();
}

// -----------------------------------------------------------------
// function Link(page)
// Link page in sub menu
// -----------------------------------------------------------------
function Link(page)
{
	location.href="/html/"+page+"";
}

// -----------------------------------------------------------------
// function doOpenHelpWindow()
// It will popup a new window to show the help documents
// -----------------------------------------------------------------
function doOpenHelpWindow()
{
	options="toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=400";
   	newWindow=window.open("http://www.support.dlink.com/html/helpMain.html", "HelpWindow", options);
}

// -----------------------------------------------------------------
// Function DoSelectPage(String *)
// input: WebPage file
// -----------------------------------------------------------------
function doSelectPage(pageFile)
{
	currentPortHTML='/html/'+pageFile;
	gCurrentPortPage=currentPortHTML;
	//alert(currentPortHTML);
	rbottom.location.href=currentPortHTML+'?0,'+gCurrentUnit+','+(gCurrentSlot-1)+','+gCurrentPort;
}

////////////////////////////////////////////////////////////////////
// accept ip format: xxx.xxx.xxx.xxx , xxx xxx xxx xxx
//////////////////////////////////////////////////////////////////////
 function ipCheck_X(textValue)
  {

    re1=/(\d+)(\W)(\d+)(\W)(\d+)(\W)(\d+)/
    Check=textValue.search(re1);
    if(Check==-1)
    	return false;
    else
    {
       re2=/(\W)/
       ipSplit=textValue.split(re2);
       if(ipSplit.length!=4) return false;
       for(i=0; i<ipSplit.length; i++)
       {
         if(ipSplit[i]>255)  return false;
       }

       return true;

    }
 }

////////////////////////////////////////////////////////////////////
// not accept ip 255.255.255.255
//////////////////////////////////////////////////////////////////////
function ipCheck2_X(textValue)
  {
    re1=/(\d+)(\W)(\d+)(\W)(\d+)(\W)(\d+)/
    Check=textValue.search(re1);
    if(Check==-1)   return false;

    else
    {

       re2=/(\W)/

       ipSplit=textValue.split(re2);
       if(ipSplit.length!=4) return false;
       for(i=0; i<ipSplit.length; i++)
       {
         if(ipSplit[i]>=255)  return false;
       }

       return true;

    }
 }

////////////////////////////////////////////////////////////////////
// not accept ip 255.255.255.255
//////////////////////////////////////////////////////////////////////
 function ipCheck2(textValue)
  {

       var i,j=0;
       for(i=0;i<textValue.length;i++)
       {
           ch=textValue.charAt(i);
           if(ch==".")
              j++;
        }
            if(j!=3)
             return false;       // the number of '.' must be three

       ipSplit=textValue.split('.');

       if(ipSplit.length!=4) return false;   //// the number of ipSplit must be four

       for(i=0; i<ipSplit.length; i++)
       {
          if(isNaN(ipSplit[i]) || ipSplit[i]==null || ipSplit[i]==""|| ipSplit[i]==" ")
          return false;
        } //check if ipSplit[i] is invaild number

       for(i=0; i<ipSplit.length; i++)
       {
         if(ipSplit[i]>255)  return false;
       }
       if(ipSplit[0]==255 && ipSplit[1]==255 && ipSplit[2]==255 && ipSplit[3]==255)  return false; // case 2

       return true;
 }

////////////////////////////////////////////////////////////////////
// invalid ip
//case 1:     127.(0-255).(0-255).(0-255)            //class A
//case 2:     (224-255).(0-255).(0-255).(0-255)      //class D
//case 3:     128.0.(0-255).(0-255)                  //class B
//case 4:     191.255.(0-255).(0-255)                //class C
//case 5:     (64-127).255.255.255                   //class A
//case 6:     (128-191).(0-255).255.255              //class B
//case 7:     (192-255).(0-255).(0-255).255          //class C
//case 8: 	  (64-127).0.0.0                         //class A
//case 9:     (128-191).(0-255).0.0                  //class B
//case 10:    (192-255).(0-255).(0-255).0            //class C
//////////////////////////////////////////////////////////////////////
 function ipCheck3_X(textValue)
  {
    re1=/(\d+)(\W)(\d+)(\W)(\d+)(\W)(\d+)/
    Check=textValue.search(re1);
    if(Check==-1)   return false;

    else
    {
       //re2=/(\W)/
       //ipSplit=textValue.split(re2);
       ipSplit=textValue.split('.');

       if(ipSplit.length!=4) return false;
       for(i=0; i<ipSplit.length; i++)
          {
           if(ipSplit[i]>=255) return false;
          }

       if(ipSplit[0]==127) return false;  //case 1
       if(ipSplit[0]>=224 && ipSplit[0]<=255) return false; //case 2

       if(ipSplit[0]==128 && ipSplit[1]==0) return false;   //case 3
       if(ipSplit[0]==191 && ipSplit[1]==255) return false;  // case 4


       if(ipSplit[3]==255 || ipSplit[3]==0)
        {
           if(ipSplit[0]>=192 && ipSplit[0]<=255) return false;  //case 7, 10

           if(ipSplit[2]==255 || ipSplit[2]==0)
           {
           	  if(ipSplit[0]>=128 && ipSplit[0]<=191) return false; //case 6, 9

           	  if(ipSplit[1]==255 || ipSplit[1]==0)
           	  if(ipSplit[0]>=64 && ipSplit[0]<=127) return false; //case 5, 8
           }
        }

       return true;

    }
 }

///////////////////////////////////////////////////////////////////////////////
// accept mac format: xx-xx-xx-xx-xx-xx , xx:xx:xx:xx:xx:xx, xx xx xx xx xx xx
///////////////////////////////////////////////////////////////////////////////
 function macCheck_X(textValue)
 {
   re1=/(:)/
   Check=textValue.search(re1);
   if(Check==-1)  return false;

   else{

         macSplit=textValue.split(re1);
         if(macSplit.length!=6) return false;

         for(i=0; i< macSplit.length; i++) {
         	if(macSplit[i].length!=2)
         		return false;
    	  re2=/[A-Fa-f0-9][A-Fa-f0-9]/
     	  Check=macSplit[i].search(re2);
     	  if(Check==-1)  return false;
 		 }

   }
 return true;
}

/*
  Check input hex value whether match the rules listed below:
  1: must input hex value, and
  2: must inout two hex values for one entry
  */
//----------------------------------------------------- check input key
function HexCheck_X(obj)
{
	reg1=/[^0-9a-f]/i;

	Check=obj.value.search(reg1);
	if(Check==-1)
	{
		if(obj.value.length==1)
		{
			alert(" Accept only 2 Hex Values!");
			obj.select();
			return true;
		}
		else
		return false;
	}
	else
	{
		alert("Not valid Hex Value");
		obj.select();
		return true;
	}

}

//------------------------------------------------------
function HexCheck2_X(obj)
{
	reg1=/[^0-9a-f]/i;

	Check=obj.search(reg1);
	if(Check==-1)
	{
		return true;
	}
	else
	{
		//alert("Not valid Hex Value");
		return false;
	}

}

//-----------------------------------------------------------------
function ShowWizard(name)
{
	window.open(name,"Wizard","width=450,height=320");
}

//------------------------------------------------------------------
function ExitWizard(){

    if (confirm("Quit setup wizard without finishing settings ?"))
        window.close();
}

function CloseWindow(){
           window.close();
}

//-------------------------------------------------------------------
//  accept characters:  ascii code (20~7E)
//-------------------------------------------------------------------
function ASCIICheck_X(text)
{
     for(var i=0;i<text.length;i++)
     {
  	ascStr=text.charCodeAt(i);
  	hexStr=tran10to16(ascStr);
  	//if(hexStr<20) return false;
  	re=/[2-7][A-Fa-f0-9]/
     	Check2=hexStr.search(re);
        if(Check2==-1)  return false;
     }

     return true;
}

//-------------------------------------------------------------------
function HexToASCII(text,param)
{
   var asStr="";

   for(i=0;i<param;i++)
   {
    tempStr=String.fromCharCode(text.substr(2*i,2));
    asStr=asStr+tempStr;
    }

  return asStr;
}

//-------------------------------------------------------------------
function ASCIIToHex(text)
{
  var hexStr="";
 // alert("asciitohex"+text);
  for(var i=0;i<text.length;i++)
  {
  	tempStr=text.charCodeAt(i);
  	//alert("tempStr"+tempStr);
  	tempStr2=tran10to16(tempStr);
  	//alert("tempStr2"+tempStr2);
  	hexStr=hexStr+tempStr2;
  }
 // alert("hexStr"+hexStr);
   return hexStr;
}

//-------------------------------------------------------------
//  10 進位 轉 16 進位
//-------------------------------------------------------------
var a16=new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F')

function tran10to16(num){
   var st16=""
   var quot=(num-(num%16))/16
   st16=a16[(num%16)]+st16
   while(quot>15){
        quot=(quot-(quot%16))/16
        st16=a16[(quot%16)]+st16
   }
   if(quot!=0) st16=a16[quot]+st16
   return st16
}

////////////////////////////////////////////////////////////////////
// invalid ip
//case 1:		127.(0~255).(0~255).(0~255)            //class A
//case 2:		(224~255).(0~255).(0~255).(0~255)      //class D
//case 3:		128.0.(0~255).(0~255)                  //class B
//case 4:		191.255.(0~255).(0~255)                //class C
//case 5:		(64~127).255.255.255                   //class A
//case 6:		(128~191).(0~255).255.255              //class B
//case 7:		(192~255).(0~255).(0~255).255          //class C
//case 8:		(64~127).0.0.0                         //class A
//case 9:		(128~191).(0~255).0.0                  //class B
//case 10:		(192~255).(0~255).(0~255).0            //class C
//2003.10.14
//case 11:		(>255).(>255).(>255).(>255)
//case 12:		0.0.0.0
//case 13:		11.0.0.0
//case 14:		11.127.255.255
//case 15:		11.255.255.255
//case 16:      0.(<255).(<255).(<255)
//case 17:      (<255).(<255).(<255).0
//////////////////////////////////////////////////////////////////////
function CheckIP(textValue)
{
    var i,j = 0;
    var debug = 0;

    for(i=0; i<textValue.length; i++)
    {
        ch = textValue.charAt(i);
        if(ch == ".") {j++;}
    }

    // the number of '.' must be three
    if(j!=3) {return false;}

    ipSplit = textValue.split('.');

    // the number of ipSplit must be four
    if(ipSplit.length != 4) {return false;}

    //check each part is a vaild number
    for(i=0; i<ipSplit.length; i++)
    {
        if(isNaN(ipSplit[i]) || ipSplit[i]==null ||
           ipSplit[i]==""|| ipSplit[i]==" ")
        {
            return false;
        }
    }
    
    
    //case 1
    if(ipSplit[0] == 127)
    {
        if(debug == 1){alert("case 1");}
        return false;
    }

    //case 2
    if(ipSplit[0]>=224 && ipSplit[0]<=255)
    {
        if(debug == 1){alert("case 2");}
        return false;
    }

    //case 3
    if(ipSplit[0]==128 && ipSplit[1]==0)
    {
        if(debug == 1){alert("case 3");}
        return false;
    }

    //case 4
    if(ipSplit[0]==191 && ipSplit[1]==255)
    {
        if(debug == 1){alert("case 4");}
        return false;
    }

    if(ipSplit[3]==255 || ipSplit[3]==0)
    {
        //case 7, 10
        if(ipSplit[0]>=192 && ipSplit[0]<=255)
        {
            if(debug == 1){alert("case 7, 10");}
            return false;
        }

        if(ipSplit[2]==255 || ipSplit[2]==0)
        {
            //case 6, 9
            if(ipSplit[0]>=128 && ipSplit[0]<=191)
            {
                if(debug == 1){alert("case 6, 9");}
                return false;
            }

            //case 5, 8
            if(ipSplit[1]==255 || ipSplit[1]==0)
            {
                if(ipSplit[0]>=64 && ipSplit[0]<=127)
                {
                    if(debug == 1){alert("case 5, 8");}
                    return false;
                }
            }
        }
    }

    //case 11
    for(i=0; i<ipSplit.length; i++)
    {
        if(ipSplit[i]>255)
        {
            if(debug == 1){alert("case 11");}
            return false;
        }
    }

    //case 12
    if(ipSplit[0]==0 && ipSplit[1]==0 && ipSplit[2]==0 && ipSplit[3]==0)
    {
        if(debug == 1){alert("case 12");}
        return false;
    }

    //case 13
    if(ipSplit[0]==11 && ipSplit[1]==0 && ipSplit[2]==0 && ipSplit[3]==0)
    {
        if(debug == 1){alert("case 13");}
        return false;
    }

    //case 14
    if(ipSplit[0]==11 && ipSplit[1]==127 && ipSplit[2]==255 && ipSplit[3]==255)
    {
        if(debug == 1){alert("case 14");}
        return false;
    }

    //case 15
    if(ipSplit[0]==11 && ipSplit[1]==255 && ipSplit[2]==255 && ipSplit[3]==255)
    {
        if(debug == 1){alert("case 15");}
        return false;
    }
    
    //case 16
    if(ipSplit[0]==0)
    {
        if(debug == 1){alert("case 16");}
        return false;
    }

    //case 17
    if(ipSplit[3]==0)
    {
        if(debug == 1){alert("case 17");}
        return false;
    }
    
    return true;
 }

////////////////////////////////////////////////////////////////////
// invalid ip
// DHCP			XXX.XXX.XXX.0
//case 1:		127.(0-255).(0-255).(0-255)            //class A
//case 2:		(224-255).(0-255).(0-255).(0-255)      //class D
//case 3:		128.0.(0-255).(0-255)                  //class B
//case 4:		191.255.(0-255).(0-255)                //class C
//case 5:		(64-127).255.255.255                   //class A
//case 6:		(128-191).(0-255).255.255              //class B
//case 7:		(192-255).(0-255).(0-255).255          //class C
//case 8:		(64-127).0.0.0                         //class A
//case 9:		(128-191).(0-255).0.0                  //class B
//case 10:		(192-255).(0-255).(0-255).0            //class C
//2003.10.14
//case 11:		(>255-~).(>255-~).(>255-~).(>255-~)
//case 12:		0.0.0.0
//case 13:		11.0.0.0
//case 14:		11.127.255.255
//case 15:		11.255.255.255
//////////////////////////////////////////////////////////////////////
function CheckDHCPIP(textValue)
  {
       var i,j=0;
       for(i=0;i<textValue.length;i++)
       {
           ch=textValue.charAt(i);
           if(ch==".")
              j++;
        }
            if(j!=3)
             return false;       // the number of '.' must be three

       ipSplit=textValue.split('.');

       if(ipSplit.length!=4) return false;   //// the number of ipSplit must be four

       for(i=0; i<ipSplit.length; i++)
    {
          if(isNaN(ipSplit[i]) || ipSplit[i]==null || ipSplit[i]==""|| ipSplit[i]==" ")
          return false;
        } //check if ipSplit[i] is invaild number

       for(i=0; i<ipSplit.length; i++)
       {
         if(ipSplit[i]>=255)  return false; // case 11
       }

       if(ipSplit[0]==0 && ipSplit[1]==0 && ipSplit[2]==0 && ipSplit[3]==0)  return false; // case 12
       if(ipSplit[0]==11 && ipSplit[1]==0 && ipSplit[2]==0 && ipSplit[3]==0)  return false; // case 13
       if(ipSplit[0]==11 && ipSplit[1]==127 && ipSplit[2]==255 && ipSplit[3]==255)  return false; // case 14
       if(ipSplit[0]==11 && ipSplit[1]==255 && ipSplit[2]==255 && ipSplit[3]==255)  return false; // case 15

       if(ipSplit[0]==127) return false;  //case 1
       if(ipSplit[0]>=224 && ipSplit[0]<=255) return false; //case 2

       if(ipSplit[0]==128 && ipSplit[1]==0) return false;   //case 3
       if(ipSplit[0]==191 && ipSplit[1]==255) return false;  // case 4

       if(ipSplit[3]==0) return false;  // DHCP IP filter
       if(ipSplit[0]==0) return false;  // DHCP IP filter

       if(ipSplit[3]==255 || ipSplit[3]==0)
        {
           if(ipSplit[0]>=192 && ipSplit[0]<=255) return false;  //case 7, 10

           if(ipSplit[2]==255 || ipSplit[2]==0)
           {
           	  if(ipSplit[0]>=128 && ipSplit[0]<=191) return false; //case 6, 9

           	  if(ipSplit[1]==255 || ipSplit[1]==0)
           	  if(ipSplit[0]>=64 && ipSplit[0]<=127) return false; //case 5, 8
           }

        }
       return true;

 }

////////////////////////////////////////////////////////////////////
// invalid mask
//case 1:		(>255).(>255).(>255).(>255)
//case 2:   255.255.255.255
//case 3:   255.254.255.255
//case 4:   255.255.255.130
//case 5:   0.0.0.0
//case 6:   10.10.10.10
////////////////////////////////////////////////////////////////////
function CheckMask(textValue)
{
    
        var i,j=0;
       for(i=0;i<textValue.length;i++)
       {
           ch=textValue.charAt(i);
           if(ch==".")
              j++;
       }
            if(j!=3)
             return false;       // the number of '.' must be three

       ipSplit=textValue.split('.');

       if(ipSplit.length!=4) return false;   //// the number of ipSplit must be four

       for(i=0; i<ipSplit.length; i++)
       {
          if(isNaN(ipSplit[i]) || ipSplit[i]==null || ipSplit[i]==""|| ipSplit[i]==" ")
          return false;
        } //check if ipSplit[i] is invaild number

       for(i=0; i<ipSplit.length; i++)
       {
         if(ipSplit[i]>255)  return false; // case 1
       }
       if(ipSplit[0]==255 && ipSplit[1]==255 && ipSplit[2]==255 && ipSplit[3]==255)  return false; // case 2
       if(ipSplit[0]==255 && ipSplit[1]==254 && ipSplit[2]==255 && ipSplit[3]==255)  return false; // case 3
       if(ipSplit[0]==255 && ipSplit[1]==255 && ipSplit[2]==255 && ipSplit[3]==130)  return false; // case 4
       if(ipSplit[0]==0 && ipSplit[1]==0 && ipSplit[2]==0 && ipSplit[3]==0)  return false; // case 5
       if(ipSplit[0]==10 && ipSplit[1]==10 && ipSplit[2]==10 && ipSplit[3]==10)  return false; // case 6
      

   return true; 
   
}

////////////////////////////////////////////////////////////////////
// invalid gateway
//case 1:		(>255).(>255).(>255).(>255)
//case 2:   255.255.255.255
//case 3:   (224-239).(0-255).(0-255).(0-255)
//case 4:   (240-254).(0-255).(0-255).(0-255)
//case 5:   127.0.0.1
//case 6:   0.0.0.0
////////////////////////////////////////////////////////////////////
function CheckGateway_X(textValue)
  {
    re1=/(\d+)(\W)(\d+)(\W)(\d+)(\W)(\d+)/
    Check=textValue.search(re1);

    if(Check==-1)
  return false;
    else
    {
       re2=/(\W)/
       ipSplit=textValue.split(re2);
       //ipSplit=textValue.split('.');

       if(ipSplit.length!=4) return false;

       for(i=0; i<ipSplit.length; i++)
       {
         if(ipSplit[i]>255)  return false; // case 1
       }
       if(ipSplit[0]==255 && ipSplit[1]==255 && ipSplit[2]==255 && ipSplit[3]==255)  return false; // case 2
       if(ipSplit[0] >= 224 && ipSplit[0] <= 239) return false; // case 3
       if(ipSplit[0] >= 240 && ipSplit[0] <= 254)  return false; // case 4
       if(ipSplit[0]== 127 && ipSplit[1]== 0 && ipSplit[2]== 0 && ipSplit[3]== 1)  return false; // case 5
       if(ipSplit[0]==0 && ipSplit[1]==0 && ipSplit[2]==0 && ipSplit[3]==0)  return false; // case 6

   }
   return true;
}

////////////////////////////////////////////////////////////////////
// invalid gateway
//case 1:		(>255).(>255).(>255).(>255)
//case 2:   255.255.255.255
//case 3:   (224-239).(0-255).(0-255).(0-255)
//case 4:   (240-254).(0-255).(0-255).(0-255)
//case 5:   127.0.0.1
//case 6:   0.0.0.0
////////////////////////////////////////////////////////////////////
function CheckGateway(textValue)
  {
    
       var i,j=0;
       for(i=0;i<textValue.length;i++)
       {
           ch=textValue.charAt(i);
           if(ch==".")
              j++;
       }
            if(j!=3)
             return false;       // the number of '.' must be three

       ipSplit=textValue.split('.');

       if(ipSplit.length!=4) return false;   //// the number of ipSplit must be four

       for(i=0; i<ipSplit.length; i++)
       {
          if(isNaN(ipSplit[i]) || ipSplit[i]==null || ipSplit[i]==""|| ipSplit[i]==" ")
          return false;
        } //check if ipSplit[i] is invaild number

       for(i=0; i<ipSplit.length; i++)
       {
         if(ipSplit[i]>255)  return false; // case 1
       }
       if(ipSplit[0]==255 && ipSplit[1]==255 && ipSplit[2]==255 && ipSplit[3]==255)  return false; // case 2
       if(ipSplit[0] >= 224 && ipSplit[0] <= 239) return false; // case 3
       if(ipSplit[0] >= 240 && ipSplit[0] <= 254)  return false; // case 4
       if(ipSplit[0]== 127 && ipSplit[1]== 0 && ipSplit[2]== 0 && ipSplit[3]== 1)  return false; // case 5
       if(ipSplit[0]==0 && ipSplit[1]==0 && ipSplit[2]==0 && ipSplit[3]==0)  return false; // case 6

   return true; 
}

function HexCheck2(str)
{
	var len = str.length;

	if((len == 0) || (len%2 != 0))
	{
		return false;
	}
	else
	{
		for(var i=0 ; i<len ; i++)
		{
			substring = str.substr(i,1);
		    if(!((substring>='0' && substring<='9') || (substring>='a' && substring<='f') || (substring>='A' && substring<='F') ? true : false))
				return false;
		}
		return true;
	}
}

function macCheck(str)
{
	// type 1 xx:xx:xx:xx:xx:xx
	// type 2 xx xx xx xx xx xx
	var len = str.length;
	var substring1 = str.split(":");
	//var substring2 = new Array(str.substring(0,2),str.substring(3,5),str.substring(6,8),
	//                           str.substring(9,11),str.substring(12,14),str.substring(15,17));
	var substring2 = str.split(" ");
	var len1 = substring1.length;
	var len2 = substring2.length;

	if(len == 0)
	{
		//alert("The MAC is empty.");
		return false;
	}
	else
	{
		if(len1 == 6)
		{
			for(var i=0 ; i<6 ; i++)
			{
				//alert(substring1[i]);
				if(!HexCheck2(substring1[i]))
				{
					//alert("false1");
					return false;
				}
			}
			return true;
		}

		if(len2 == 6)
		{
			for(var i=0 ; i<6 ; i++)
			{
				if(!HexCheck2(substring2[i]))
				{
					//alert("false2");
					return false;
				}
			}
			return true;
		}
		//alert(false);
		return false;
	}
}

function ASCIICheck(str)
{
	// ASCII range  16:(20~7E)  10:(32~126)
	for(var i=0 ; i<str.length ; i++)
	{
		if(str.charCodeAt(i) < 32 || str.charCodeAt(i) > 126)
		{
			//alert(false);
			return false;
		}
	}
	//alert(true);
	return true;
}

function SSIDCheck(str)
{
	for(i=0;i<str.length;i++)
	{
		if(str.charAt(i)=='"')
			return false;
		else
			return true;
	}
}

var deviceType = "DWL-2100AP";
function Change_Device_Name()
{
	var logo = document.getElementById("img_logo");
	var ap = document.getElementById("img_ap");
	var wizard = document.getElementById("img_wizard");
	var dt = document.getElementById("Device_Type");
	var APR_APC = document.getElementById("APR_APC");

	if(logo != null)
	{
		if(deviceType == "DWL-2100AP")
		    logo.src = "dwl2100ap_top.jpg";
		else if(deviceType == "DWL-2200AP")
		  	logo.src = "http://www.support.dlink.com/emulators/dwl2100ap/dwl2200ap_top.jpg";
		else if(deviceType == "DWL-3200AP")
		  	logo.src = "http://www.support.dlink.com/emulators/dwl2100ap/dwl3200ap_top.jpg";
	}

	if(ap != null)
	{
		if(deviceType == "DWL-2100AP")
		{
			ap.src = "dwl2100ap_ap.jpg";
		    ap.background="dwl2100ap_ap.jpg";
		}
		else if(deviceType == "DWL-2200AP")
		{
			ap.src ="http://www.support.dlink.com/emulators/dwl2100ap/dwl2200ap_ap.jpg";
			ap.background = "http://www.support.dlink.com/emulators/dwl2100ap/dwl2200ap_ap.jpg";
		}
		else if(deviceType == "DWL-3200AP")
		{
			ap.src ="http://www.support.dlink.com/emulators/dwl2100ap/dwl3200ap_ap.jpg";
			ap.background = "http://www.support.dlink.com/emulators/dwl2100ap/dwl3200ap_ap.jpg";
		}
	}

	if(wizard != null)
	{
		if(deviceType == "DWL-2100AP")
			wizard.src = "http://www.support.dlink.com/emulators/dwl2100ap/dwl2100ap_wizard.jpg";
		else if(deviceType == "DWL-2200AP")
	  		wizard.src = "http://www.support.dlink.com/emulators/dwl2100ap/dwl2200ap_wizard.jpg";
		else if(deviceType == "DWL-3200AP")
	  		wizard.src = "http://www.support.dlink.com/emulators/dwl2100ap/dwl3200ap_wizard.jpg";
	}

	var obj = new Array();

	for(var i=0; i<=15; i++)
	{
		obj[i] = document.getElementById("APName"+i);
		if(obj[i] != null) obj[i].innerHTML = deviceType;
	}

	if(dt != null)
	{
		if(deviceType == "DWL-G820")
			dt.innerHTML = "Wireless Gaming Adapter";
		else
			dt.innerHTML = "Wireless Access Point";
	}

	for(i=0; i<=15; i++)
	{
		obj[i] = document.getElementById("APType"+i);
		if(deviceType == "DWL-G820")
			if(obj[i] != null) obj[i].innerHTML = "Gaming Adapter";
		else
			if(obj[i] != null) obj[i].innerHTML = "Access Point";
	}

	//obj = null;

	for(i=0; i<=5; i++)
	{
    	obj[i] = document.getElementById("IPReplace"+i);
    	if((deviceType=="DWL-2100AP" )||(deviceType=="DWL-2200AP"))
    	{
    		if(obj[i] != null) obj[i].innerHTML = "192.168.0.50";
    	}
    	else if(deviceType == "DWL-G820")
    	{
    		if(obj[i] != null) obj[i].innerHTML = "192.168.0.35";
    	}
    	else
    	{
    		if(obj[i] != null) obj[i].innerHTML = "192.168.0.30";
    	}
	}
	
	/* add by John 2005.1.21 for show AP cilent & AP repeater*/
	if (APR_APC != null)
    {
	    if(deviceType == "DWL-2100AP")
	    {
	        APR_APC.innerHTML = ", AP client, and AP repeater";
	    }
	}
}
