
function isDate(str)
{
	try
	{
	    var tempdata=str;
	    if(tempdata.replace(/[^0-9\/: ]/g,"")!=tempdata)
	    {
	        return -101;
	    }	
		var date=str.split("/");
		if(date.length!=3)return -102;
		var y=Math.floor(date[0]);
		var M=Math.floor(date[1]);
		var d=Math.floor(date[2]);
		var maxday=31;
		if(M>7)M=M-1;
		if(M%2!=1)
		{//   小月
			maxday=30;
		}
		if(M==2)
		{//   2月份
			if((y%4==0 && y%100!=0) || (y%400==0) )
			{
				maxday=29;
			}else 
			{
				maxday=28;
			}
		}
		if(y<1970 || y>2036)return -103;
		if(M<1 || M>12)return -104;
		if(d<1 || d>maxday)return -105;		
		return 0;
	}catch(ee){}
	return -101;	
}

function isTime(str)
{
	try
	{
		var time=str.split(":");
		var h=Math.floor(time[0]);
		var m=Math.floor(time[1]);
		var s=Math.floor(time[2]);
		if(time.length!=3)return -11;
		if(h<0 || h>23)return -12;
		if(m<0 || m>59)return -13;
		if(s<0 || s>59)return -14;
		return 0;
	}catch(ee){}
	return -11;
}

function isDateTime(str)
{
		try
		{
			if(str=="0000-00-00 00:00:00")return 0;
			var ls=str.split(" ");
			if(ls.length!=2)
			{
				return -1;
			}
			var dateok=isDate(ls[0]);
			if(dateok!=0)return dateok;
			var timeok=isTime(ls[1]);
			if(timeok!=0)return timeok;
			return 0;
		}catch(ee){}
		return -1;
}


//   返回>2表示出错 返回1 表示st>en
function CompareDateTime(st,en)
{
	try
	{
	    if(isDateTime(st)!=0)
	    {
	        return 3;
	    }
	    if(isDateTime(en)!=0)
	    {
	        return 4;
	    }  
		var stvalue=Math.floor(st.replace(/[^0-9]+/g,""));
		var envalue=Math.floor(en.replace(/[^0-9]+/g,""));
		if(stvalue>envalue)
		{
			return 1;
		}else if(envalue>stvalue)
		{
			return -1;
		}else
		{
			return 0;
		}
	}catch(ee){}
	return 5;//   出错
}




//check str is net mask or not,if yes ,return true   
function isNetMask(str)
{
	try
	{
		if(str=="" || str==undefined)return false;
		if(!/^(254|252|248|240|224|192|128|0)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)$/.test(str)) 
		{
			return false;
		}
		return true;
	}catch(ee){}
	return false;
}




//check str is ip or not,if yes ,return true   
function isIp(ipstr)
{
	try
	{
		if(ipstr=="" || ipstr==undefined)return false;
		if(!/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){2}\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-4])$/.test(ipstr)) 
		{
			return false;
		}
		return true;
	}catch(ee){}
	return false;
}



function IsNormIp(ipstr)
{
	try
	{
		if(ipstr=="" || ipstr==undefined)return false;
		if(!/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){2}\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-4])$/.test(ipstr)) 
		{
			return false;
		} 
		var ls=ipstr.split(".");
		if(parseInt(ls[0])>223 ||  parseInt(ls[3])==0  )
		{
		    return false;
		}
		return true;
	}catch(ee){}
	return false;
}