//检测参数设置
function ValidateNum(item,type,str)
{
	var returnVal = 0;
	var intVal;
	var strVal = new String(item.val());
	var ch;
	var i;
	var j;
	if(type == "VIDEORATE")//视频码率
	{
		if(strVal=="")
		{
			alert("Please input"+str);
		item.focus();
		return false; 
		}
		for ( i = 0 ; i < strVal.length ; i++ )
		{      
			ch = strVal.charAt(i);                
 			if(ch < '0' || ch > '9')
			{
				alert(str+" Please input valid decimal integer!");
				item.focus();
	       		return false;
			}
		}
		intVal= parseInt(item.val(),10);
		if(intVal > 15000000 || intVal<1500000)
		{
			alert(str+" must be between 1500000 and 15000000!");
			item.focus();
			return false;
		}
	}
  else if(type == "AVEVIDEORATE")//视频平均码率
	{
		if(strVal=="")
		{
			alert("Please input"+str);
		item.focus();
		return false; 
		}
		for ( i = 0 ; i < strVal.length ; i++ )
		{      
			ch = strVal.charAt(i);
 			if(ch < '0' || ch > '9')
			{
				alert(str+"Please input valid decimal integer!");
				item.focus();
	       		return false;
			}
		}
		intVal= parseInt(item.val(),10);
		if(intVal > 14800000 || intVal<1300000)
		{
			alert(str+" must be between 1300000 and 14800000!");
			item.focus();
			return false;
		}
	}
  	else if(type == "VIDEOVAL")//亮度、色度、饱和度、对比度
	{
		if(strVal=="")
	    {
			alert("Please input"+str);
			item.focus();
			return false; 
	    }
		for ( i = 0 ; i < strVal.length ; i++ )
		{      
			ch = strVal.charAt(i);
 			if(ch < '0' || ch > '9')
			{
				alert(str+"Please input valid decimal integer!");
				item.focus();
				return false;
			}
		}
		intVal= parseInt(item.val(),10);
		if(intVal > 255 || intVal <0)
		{
			alert(str+"must be between 0 and 255!");
			item.focus();
			return false;
		}
	}
	else if(type == "GOPSIZE")//GOP长度
	{
		if(strVal=="")
		{
			alert("Please input"+str);
			item.focus();
			return false;
		}
		for ( i = 0 ; i < strVal.length ; i++ )
		{
			ch = strVal.charAt(i);
			if(ch < '0' || ch > '9')
			{
				alert(str+"Please input valid decimal integer!");
				item.focus();
				return false;
			}
		}
		intVal= parseInt(item.val(),10);
		if(intVal > 30 || intVal <4)
		{
			alert(str+" must be between 4 and 30!");
			item.focus();
			return false;
		}
	}
	else if(type == "ENCDELAY")//编码延迟时间
	{
        ch = strVal.charAt(0);
		if (strVal.length == 1 && ch == '-')
		{
			alert(str+" Please input valid decimal integer!");
			item.focus();
	       	return false; 		
		}
		if ((ch < '0' || ch > '9') && ch != '-')
		{
			alert(str+" Please input valid decimal integer!");
			item.focus();
	       	return false; 
		}
		for ( i = 1 ; i < strVal.length ; i++ )
		{      
			ch = strVal.charAt(i);
 			if(ch < '0' || ch > '9')
			{
				alert(str+" Please input valid decimal integer!");
				item.focus();
	       		return false; 
			}
		}
		intVal= parseInt(item.val(),10);
		if(intVal > 500 || intVal <-500)
		{
			alert(str+" must be between -500 and 500!");
			item.focus();
			return false; 
		}
	}	
	else if(type == "CHPID")//音视频PID
	{
		if(strVal=="")//不能为空
	   	{
			alert("Please input"+str);
			item.focus();
			return false; 
	    }
		if(strVal.length == 1)//如果输入一位数，那么必须为1~9的十进制数
		{
			ch0 = strVal.charAt(0);
			if(ch0 < '1' || ch0 > '9')
			{
				alert(str+"Please input valid number!");
				item.focus();
				return false;
			}
			else
			{
				alert(str+"must be between 32 and 8190!");
				item.focus();
				return false;
			}
		}
		else//长度大于1的情况 
		{	
			ch0 = strVal.charAt(0);
			ch1 = strVal.charAt(1);
			if(((ch0 == '0')&&(ch1 == 'x'))||((ch0 == '0')&&(ch1 == 'X')))//如果是0x开头，默认为输入十六进制数据
			{
				if(strVal.length == 2)
				{
					alert(str+"Please input valid number!");
					item.focus();
					return false;
				}
				for ( i = 0 ; i < strVal.length-2; i++ )
				{      
					ch = strVal.charAt(i+2);
					if(ch < '0' || ch > '9'&& ch < 'A' || ch > 'F' && ch < 'a' || ch > 'f')
					{
						alert(str+"Please input valid number!");
						item.focus();
						return false;
					}
				}
				intVal= parseInt(item.val(),16);
				if((intVal <32)||(intVal > 8190))
				{
					alert(str+"must be between 0x20 and 0x1ffe!");
					item.focus();
					return false;
				}
			}
			else if(ch0 == '0')//否则的话不能以0作为开头
			{
				alert(str+"Please input valid number!");
				item.focus();
				return false;
			}
			else//认为输入十进制数
			{
				for ( i = 0 ; i < strVal.length ; i++ )
				{      
					ch = strVal.charAt(i);
					if(ch < '0' || ch > '9')
					{
						alert(str+"Please input valid number!");
						item.focus();
						return false;
					}
				}
				intVal= parseInt(item.val(),10);
				if((intVal <32)||(intVal > 8190))
				{
					alert(str+"must be between 32 and 8190!");
					item.focus();
					return false;
				}
			}
		} 
	}
	else if(type == "PROG")//节目号
	{
    	if(strVal=="")//不能为空
	   	{
			alert("Please input"+str);
			item.focus();
			return false; 
	    }
		if(strVal.length == 1)//如果输入一位数，那么必须为1~9的十进制数
		{
			ch0 = strVal.charAt(0);
			if(ch0 < '1' || ch0 > '9')
			{
				alert(str+"Please input valid number!");
				item.focus();
				return false;
			}
		}
		else//长度大于1的情况 
		{	
			ch0 = strVal.charAt(0);
			ch1 = strVal.charAt(1);
			if(((ch0 == '0')&&(ch1 == 'x'))||((ch0 == '0')&&(ch1 == 'X')))//如果是0x开头，默认为输入十六进制数据
			{
				if(strVal.length == 2)
				{
					alert(str+"Please input valid number!");
					item.focus();
					return false;
				}
				for ( i = 0 ; i < strVal.length-2; i++ )
				{      
					ch = strVal.charAt(i+2);
					if(ch < '0' || ch > '9'&& ch < 'A' || ch > 'F' && ch < 'a' || ch > 'f')
					{
						alert(str+"Please input valid number!");
						item.focus();
						return false;
					}
				}
				intVal= parseInt(item.val(),16);
				if((intVal <1)||(intVal > 65535))
				{
					alert(str+"must be between 0x0001 and 0xffff!");
					item.focus();
					return false;
				}
			}
			else if(ch0 == '0')//否则的话不能以0作为开头
			{
				alert(str+"Please input valid number!");
				item.focus();
				return false;
			}
			else//认为输入十进制数
			{
				for ( i = 0 ; i < strVal.length ; i++ )
				{      
					ch = strVal.charAt(i);
					if(ch < '0' || ch > '9')
					{
						alert(str+"Please input valid number!");
						item.focus();
						return false;
					}
				}
				intVal= parseInt(item.val(),10);
				if((intVal <1)||(intVal > 65535))
				{
					alert(str+"must be between 1 and 65535!");
					item.focus();
					return false;
				}
			}
		} 
  	}
	else if(type == "NAME")//业务名称、业务描述符
	{
		if(strVal=="")
	   {
			alert("Please input"+str);
		item.focus();
		return false; 
	   }
		if(strVal.length>32)
		   {
			alert(str+"length cann't be larger than 32!");
			   item.focus();
			   return false; 
		   }
	}
	return true;
}