//请在要使用本函数库的文件中使用以下句子
//<script language=JavaScript src="/include/function/function.js"></script>
//fucntion checkdate(s)检查日期是否正确
//function checkmail(mail)检查邮件是否正确
//function isEmptyNumber(p_stringcheck)检查是否是数字，且不为空
//function isempty(strsome)检查是否为空
//function isdtvalid(year,month,day)检查日期是否有效
//--------------------------------------------------------------------------


//检查一个类似1974-12-5的日期是否正确
//返回true正确
//返回false错误
function checkdate(s)
{
	re=/([0-9]{4}\-[0-9]{0,2}\-[0-9]{0,2})/
	if(s.length>10){window.alert("日期格式输入错误！");	return false;}
	if(re.exec(s)==null){window.alert("日期格式输入错误！");return false;}
	ss=s.split("-");year=ss[0];	month=ss[1];day=ss[2];
	yn=year%4;
	if(month<1||month>12){window.alert('月份输入错误！');return false;}
	if((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12))
	{if(day<1||day>31){window.alert('日期输入错误！');return false;}}
	if(month==2)
	{	if(yn==0){if(day<1||day>29){window.alert('闰年日期输入错误！');return false;}}
		if(day<1||day>28){window.alert('日期输入错误！');return false;}	
	}
	if((month==4)||(month==6)||(month==9)||(month==11))
	{if(day<1||day>30){window.alert('日期输入错误！');return false;}}		
	return true;
}
//--------------------------------------------------------------------------
//检查一个电子邮件是否正确
//返回true正确
//返回false错误

//function checkmail(mail)
//{
//  var strr;
//  re=/(\w+@\w+\.\w+)(\.{0,1}\w*)(\.{0,1}\w*)/i;
//  re.exec(mail);
//  if (RegExp.$3!=""&&RegExp.$3!="."&&RegExp.$2!=".") strr=RegExp.$1+RegExp.$2+RegExp.$3
//  else
//    if (RegExp.$2!=""&&RegExp.$2!=".") strr=RegExp.$1+RegExp.$2
//    else  strr=RegExp.$1
//  if (strr!=mail) return false
//  return true;
//}

function checkmail(mail)
{
	if (isempty(mail)) return false;
	var strr;
	re=/([A-Za-z0-9._-]+@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)(\.{0,1}[A-Za-z0-9_-]*)(\.{0,1}[A-Za-z0-9_-]*)/i;
	re.exec(mail);	
	if (RegExp.$3!=""&&RegExp.$3!="."&&RegExp.$2!=".") 
	{
		strr=RegExp.$1+RegExp.$2+RegExp.$3;
	}
	else
    if (RegExp.$2!=""&&RegExp.$2!=".") 
    {
		strr=RegExp.$1+RegExp.$2;
	}
    else
    {  
		strr=RegExp.$1
	}
	if(strr!=mail) return false
	return true;
}
//--------------------------------------------------------------------------
//检查一字字符是否是数字，而且不为空，不为空字符，如果是数字，数字不为零
//返回true 准确的数字输入
//返回false 不准确的数字输入
function isEmptyNumber(p_stringcheck)
{
	if(isempty(p_stringcheck)==true||p_stringcheck==""||(isNaN(p_stringcheck)==true)||(p_stringcheck<=0))return false;
	else return true;
}


//---------------------------------------------------------------------------
//检查字符串是否为空值
//strsome是要检查的字符串
//返回false 非空字符串
//返回true  是空字符串
function isempty(strsome)
{
	aa=strsome;
	bb=aa.length;
	for(i=1;i<bb+1;i++)
	{
		cc=aa.substring(i-1,i);
		if(cc!=" ")
		{
			return false;
		}
	}	
	return true;
}
//检查一个日期是否有效
//year输入的年，格式比如1974
//month输入的月份，格式比如12
//day输入的日期，格式比如25
//return false输入日期有错误
//return true输入日子准确
function isdtvalid(year,month,day)
{
//	window.alert(year);
//	window.alert(month);
//	window.alert(day);
	
	d=new Date();
	
	var r1
	r1 = new RegExp('[^0-9]','');

	yn=year%4;//如果yn是0则是闰年，否则不是闰年
	
	if(day.search(r1)>=0)
	{
		window.alert('对不起，您输入的日期不正确！')
		return false;
	}
	if(year<1900||year>2050||year.search(r1)>=0){window.alert('对不起，您输入的年份不正确！');return false;}	
	if(month<1||month>12||month.search(r1)>=0){window.alert('对不起，您输入的月份不正确！');return false;}
	if((month==1)||(month==3)||(month==5)||(month==7)||(month==8)||(month==10)||(month==12))
	{
		if(day<1||day>31){window.alert('对不起，您输入的日期不正确！');return false;					}
	}
	if(month==2)
	{
		if(yn==0){if(day<1||day>29){window.alert('对不起，您输入的闰年日期不正确！'); return false;}}
		if(day<1||day>28){window.alert('对不起，您输入的日期不正确！');return false;}	
	}
	if((month==4)||(month==6)||(month==9)||(month==11))
	{	
			if(day<1||day>30){window.alert('对不起，您输入的日期不正确！');return false;			}
	}	
		
	//如果输入日期小于当前日期，返回错误
	//d1=new Date(year,month-1,day);
	//if(d1<d)
	//{
		
	//	window.alert('对不起，您输入的日期小于当前日期，请重新输入！');
	//	return false;
	//}
	return true;		
}



//*****************************************************************
// function isEmptyString(str)
//	This function check if the input string is empty.return TRUE
//	if it is,else return FALSE.
// Author:Jimmy Lu
// Last Modified:2000/12/12
//*****************************************************************
function isEmptyString(str)
{
	var s,l,t;
	s=str;
	l=s.length;
	for(i=1;i<l+1;i++)
	{
		t=s.substring(i-1,i);
		if(t!=" ")
		{
			return false;
		}
	}	
	return true;
}


//*****************************************************************
// function isPlainString(str)
//	This function check if the input string include special 
//	characters.If the string only include alphabet letters and 
//	Arabic numbers,return TRUE,else return FALSE.
// Author:Jimmy Lu
// Last Modified:2000/12/6
//*****************************************************************
function isPlainString(str)
{
	var r1
	r1 = new RegExp('[^A-Za-z0-9_-]','');
	if ( str.search(r1) >= 0||isempty(str) )
		return false;
	else 
		return true;
}


//*****************************************************************
// function isValidEmail(str)
//	This function check if the email is valid,return TRUE if it is,
//	else return FALSE.
// Author:Jimmy Lu
// Last Modified:2000/12/6
//*****************************************************************
function isValidEmail(mail)
{
	if (isempty(mail)) 
		return false;
	
	var strr;
	re=/([A-Za-z0-9._-]+@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)(\.{0,1}[A-Za-z0-9_-]*)(\.{0,1}[A-Za-z0-9_-]*)/i;
	re.exec(mail);	
	if (RegExp.$3!=""&&RegExp.$3!="."&&RegExp.$2!=".") 
	{
		strr=RegExp.$1+RegExp.$2+RegExp.$3;
	}
	else if (RegExp.$2!=""&&RegExp.$2!=".") 
    {
		strr=RegExp.$1+RegExp.$2;
	}
    else
    {  
		strr=RegExp.$1
	}
	if(strr!=mail) 
		return false;
	return true;
}


//*****************************************************************
// function isValidNum(num)
//	This function check if the input number is valid,return TRUE 
//	if it is,else return FALSE.
// Author:Jimmy Lu
// Last Modified:2000/12/12
//*****************************************************************
function isValidNum(num)
{
	if(isempty(num)||(isNaN(num))||(num<=0.0001))
		return false;
	else 
		return true;
}