function valDoValidateName(Name,Result)
{
   if(Name.match("^[0-9]") != null) { alert("A Username/Password cannot start with a number"); return false; return("A name can not start with a number."); }
   if(Name.match("[^0-9a-zA-Z_-]") != null) { alert("A Username/Password name only accepts alpha-numeric characters"); return false; return("A name only accepts alpha-numeric characters"); }
   else if((Name.length == 0) || (Name.length > 32)) { alert("A Username/Password must contain 1..32 characters"); return false; return("A name must contain 1..32 characters"); }
   return null;
}

function valDoValidateUsrPwd(Name,val,Result)
{
//	if(Name.match("[^@.*0-9a-zA-Z_-]") != null) 
//	{ 
//		alert("用户名/口令只能由字母和数字构成"); 
//		return false; 
//	}

//	var fstchr=Name.split("");
//	if(fstchr[0]=="@"||fstchr[0]=="-"||fstchr[0]==".") 
//	{ 
//		alert("用户名/口令只能以字母-数字字符开头");
//		return false; 
//	}

//	if(val==1)
//	{
//		for(var i=0;i<(Name.length)-1;i++)
//		{
//			if((fstchr[i]=="@" && fstchr[i+1]==".")||(fstchr[i]=="." && fstchr[i+1]=="@")) 
//			{ 
//				alert("无效用户名");
//				return false;
//			}
//		}
//	}

	if((Name.length == 0) || (Name.length > 64)) 
	{ 
    		alert("An Username/Password must contain 1..64 characters"); 
	    	return false; 
	}

	return null;
}


function valDoValidateInteger(Integer)
{   
   if(Integer.match("^[0-9]+$")) 
   { 
   	return null;
   }
   return false;
}



function isValidIpAddr(ip1,ip2,ip3,ip4)
{
if(ip1==0 || ip4==0 || ip4==255 || ip1==127 )	
	return false;			

return true;	
}

function valDoValidateIP(Address)
{
  var address = Address.match("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$");
  var digits;
  var i;
  var error=null;

  if(address == null) { 
  	alert('Invalid IP address');
  	error="Invalid IP address"; 
  	return false;
  }
  else
  {
    digits = address[0].split(".");
    for(i=0; i < 4; i++)
    {
      if((Number(digits[i]) > 255 ) || (Number(digits[i]) < 0 ) || (Number(digits[0]) > 223))
      { 
      	alert('Invalid IP address');
      	error="Invalid IP address"; 
      	return false;
      	break; 
      }
    }
    if(!isValidIpAddr(digits[0],digits[1],digits[2],digits[3],false))
    {
    	alert("Invalid IP address");
    	return false;
    }
  }
  return error;
}


function valDoValidateNet(Address)
{
  var address = Address.match("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$");
  var digits;
  var error=null;

  if(address == null) 
  { 
	alert('Invalid network ID');
	return false;
  	error="Invalid network ID"; 
  	return error; 
  }
  if(address[0] == "255.255.255.255")
  { 
	alert('Invalid network ID');
	return false;
	error="Invalid network ID"; return error; 
  }
  digits = address[0].split(".");
  for(i=1; i <= 4; i++)
   if((Number(digits[i]) > 255 ) || (Number(digits[i]) < 0 ))
    { 
    	alert('Invalid network ID');
    	error="Invalid network ID"; 
    	return false;
    	break; 
    }
   return error;
}

function valDoValidateMask(Mask)
{
  var mask = Mask.match("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$");
  var digits;
  var bMask = 0;
  var watch = false;
  var i;
  var error=null;

  if(mask == null)
  { 
	  alert('Invalid network mask');
	  error="Invalid network mask"; 
	  return false;
	  return error; 
 }
  digits = mask[0].split(".");
  for(i=0; i < 4; i++)
  {
    if((Number(digits[i]) > 255 ) || (Number(digits[i]) < 0 ))
     {
	     alert('Invalid network mask');
	     error="Invalid network mask"; 
	     return false;	
	     return error; 
     }
	bMask = (bMask << 8) | Number(digits[i]);
  }
  bMask = bMask & 0x0FFFFFFFF;
  for(i=0; i<32; i++)
  {
    if((watch==true) && ((bMask & 0x1)==0)) { 
    alert('Invalid network mask');
    error="Invalid network mask"; 
    return false;
    return error; 
  }
	bMask = bMask >> 1;
	if((bMask & 0x01) == 1) watch=true;
  }
  return error;
}

function valDoValidateHostName(HostName)
{
   if (HostName.match("^[a-zA-Z]+") == null) 
   {
   	alert('Host Name must start with a character');
   	return false;
   	return ("Host Name must start with a character");
   }	   	
   else if (HostName.match("^([a-zA-Z]+[a-zA-Z0-9_-]*)(\.*[a-zA-Z0-9])+$") == null) 
   {
   	alert('Host Name does not have correct format')
   	return false;
   	return ("Host Name does not have correct format");
   } 	   	
   else if ((HostName.length == 0) || (HostName.length > 63))
   { 
   	alert('A host name must contain 1..63 characters');
   	return false;
   	return("A host name must contain 1..63 characters"); 
   }
   return null;
}
// added for remote log patching by Rachael on 02.04.2005 
function valDoValidateIpmod(Address)
{
  var address = Address.match("^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$");
  var digits;
  var i;
  var error=null;

  if(address == null) { 
  	alert('Invalid IP address');
  	error="Invalid IP address"; 
  	return false;
  }
  else
  {
    digits = address[0].split(".");
    for(i=0; i < 4; i++)
    {
      if((Number(digits[i]) > 255 )||Number(digits[3])==255 || (Number(digits[0]) == 127 )|| (Number(digits[i]) < 0 )||Number(digits[3])==0 || (Number(digits[0]) > 223))
      { 
      	alert('Invalid IP address');
      	error="Invalid IP address"; 
      	return false;
      	break; 
      }
    }
  }
  return error;
}
//end added by Rachael on 02.05.2005
