/*****************************************************************************
?????fucCheckNull
???????????
??	?obj???????
??	?strAlertMsg ????????
??    ??????  true/false
??	?2004-03-19
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckNull(obj,strAlertMsg)
{
    var strTemp=obj.value;
	strTemp=strTemp.replace(/^(\s)*|(\s)*$/g,"");//??????????	
	if (strTemp.length<1)
			{
				alert(strAlertMsg);
				obj.focus();
				return false;
			}
}


/*****************************************************************************
?????fucCheckMail
??????????????Email Address
??	?obj,??????
??    ??????  true/false
??	?2004-03-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckMail(obj,strAlertMsg)
 {
		strAddress=obj.value;
		strAddress=strAddress.replace(/^(\s)*|(\s)*$/g,"");//??????????
				
		//?????
		//??????????a-z,A-Z,0-9????????email?
		//email????????????????,????.,?????????
		var newPar=/^[a-zA-Z](\w*)@\w+\.(\w|.)*\w+$/
		if(strAddress.length>0 && newPar.test(strAddress)==false)
		{
		   alert(strAlertMsg);
		   obj.focus();	
		   return false;	
		 }
		 else
		 {
		    return true;
		 }
 }
 
 /*****************************************************************************
?????fucCompareValue
?????????????????
??	?obj1,??1
??	?obj2,??2
??	?strAddress,????
??    ??????  true/false
??	?2004-03-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucCompareValue(obj1,obj2,strAlertMsg)
 {
		strValue1=obj1.value;
		strValue2=obj2.value;
		strValue1=strValue1.replace(/^(\s)*|(\s)*$/g,"");//??????????
		strValue2=strValue2.replace(/^(\s)*|(\s)*$/g,"");//??????????
				
		if(strValue1!=strValue2)
		{
		   alert(strAlertMsg);
		   obj1.focus();	
		   return false;	
		 }
		 else
		 {
		    return true;
		 }
 }
 
 /*****************************************************************************
?????fucCheckLength
????????????????????????
??	?obj,??????
??	?iStrMax,??????????
??	?strAlertMsg ????????
??    ??????  true/false
??	?2003-10-20
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckLength(obj,iStrMax,strAlertMsg)
{
	strTemp=obj.value;
	strTemp=strTemp.replace(/"/,"&quot");
	strTemp=strTemp.replace(/</g,"&lt");
	strTemp=strTemp.replace(/>/g,"&gt");
	strTemp=strTemp.replace(/'/g,"''");
	strTemp=strTemp.replace(/\n/g,"<br>");
	var i,sum;
	sum=0;
	for(i=0;i<strTemp.length;i++)
	{
		//???????????????
		if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))
			sum=sum+1;
		else  //????????????????????
			sum=sum+2;
	}
	
	if(sum>iStrMax)
	{
	  //????????????
	   alert(strAlertMsg);
	   obj.focus();
	   return false;
	}
	else
	{
	   return true;
	}
		
}

/*****************************************************************************
?????fucCheckObjAndNull
???????????????????
??	?strObj1 ???ID
??	?strObj2  ???ID
??	?strAlertMsg ????????
??    ??????  true/false
??	?2003-10-30
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckObjAndNull(strObj1,strObj2,strAlertMsg)
{
        var obj1=document.all[strObj1];
		var strTmp1="";		
		if(obj1!=null)
		{
		  strTmp1=obj1.value;
		}
		
		var obj2=document.all[strObj2];
		var strTmp2="";
		if(obj2!=null)
		{
		  strTmp2=obj2.value;
		}
		
		//???????
		strTemp1=strTemp1.replace(/^(\s)*|(\s)*$/g,"");//??????????
        strTemp2=strTemp2.replace(/^(\s)*|(\s)*$/g,"");//??????????
        if ((strTemp1.length<1) && (strTemp2.length<1))
		{
		    strObj1.focus();
			alert(strAlertMsg);
			return false;
		}
		else
	    {
	      return true;
	    }
		
}

/*****************************************************************************
?????fucCheckDateFormat
??????????????????,?2003-09-01 ? ?
??	?obj,??????
??	?strAlertMsg, ???????????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckDateFormat(obj,strAlertMsg)
{
    strDate=obj.value;
    strDate=strDate.replace(/^(\s)*|(\s)*$/g,"");//??????????
    
   //??????????????0????2003-09-01
    var newPar=/^\d{4}\-\d{2}\-\d{2}$/
    if(strDate.length>0 && newPar.test(strDate)==false)
    {
        obj.focus();
		alert(strAlertMsg);	
	    return false;
	}
	else
	{
	   return true;
	}
		
}

/*****************************************************************************
?????fucCheckTimeFormat
??????????????????,? hh:ss ? ?
??	?strTime,??????
??	?strAlertMsg, ???????????
??    ??????  true/false
??	?2003-11-20
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckTimeFormat(obj,strAlertMsg)
{
    strTime=obj.value;//?????
    strTime=strDate.replace(/^(\s)*|(\s)*$/g,"");//??????????
    
   //?????????(???) hh:mm
    var newPar=/^([0,1][0-9])|[2][0-3]:[0-5][0-9]$/
    if(strTime.length>0 && newPar.test(strTime)==false)
    {
        obj.focus();
		alert(strAlertMsg);	
	    return false;
	}
	else
	{
	   return true;
	}
		
}



/*****************************************************************************
?????fucCheckDateOrder
????????????????????(????????2003-09-01)
??	?strDate,???????
??	?strEDate,???????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckDateOrder(objSDate,objEDate,strMsg)
{
    strSDate=objSDate.value;//?????
    strSDate=strDate.replace(/^(\s)*|(\s)*$/g,"");//??????????
    
    strEDate=objEDate.value;//?????
    strEDate=strEDate.replace(/^(\s)*|(\s)*$/g,"");//??????????
    
    strSDate=strSDate.replace(/\-/,"\/");
    strEDate=strEDate.replace(/\-/,"\/");
    
    if(strMsg==""||strMsg==null)
    {
       strMsg="????????????????";
    }
   
   //????
    if(new Date(strSDate).getTime()>new Date(strEDate).getTime())
    {
        objEDate.focus();
        alert(strMsg);
        return false;
     }
     else
     {
        return true;
     }
}

/*****************************************************************************
?????fucIsInteger
?????????? ? ? ??
??	?obj,??????
??	?strAlertMsg, ???????????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucIsInteger(obj,strAlertMsg)
 {
        strInteger=obj.value;//??????
        strInteger=strInteger.replace(/^(\s)*|(\s)*$/g,"");//??????????
        
		//???????
		var newPar=/^(-|\+)?\d+$/
		if(strInteger.length>0 && newPar.test(strInteger)==false)
		{
		   obj.focus();
		   alert(strAlertMsg);	
		   return false;	
		 }
		 else
		 {
		    return true;
		 }
 }
		
/*****************************************************************************
?????fucIsFloat
?????????? ? ? ????????
??	?obj,??????
??	?strAlertMsg, ???????????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucIsFloat(obj,strAlertMsg)
 {
        strFloat=obj.value;//??????
        strFloat=strFloat.replace(/^(\s)*|(\s)*$/g,"");//??????????
        
		//???????
		var newPar=/^(-|\+)?\d*.?\d+$/
		if(strFloat.length>0 && newPar.test(strFloat)==false)
		{
		   obj.focus();
		   alert(strAlertMsg);	
		   return false;	
		 }
		 else
		 {
		    return true;
		 }
 }
 
/*****************************************************************************
?????fucIsUnsignedInteger
?????????? ? ? ???
??	?obj,??????
??	?strAlertMsg, ???????????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucIsUnsignedInteger(obj,strAlertMsg)
 {
		strInteger=obj.value;//??????
        strInteger=strInteger.replace(/^(\s)*|(\s)*$/g,"");//??????????
        
		//????????
		var newPar=/^\d*[123456789]\d*$/
		if(strInteger.length>0 && newPar.test(strInteger)==false)
		{
		   obj.focus();
		   alert(strAlertMsg);	
		   return false;	
		 }
		 else
		 {
		    return true;
		 }
 }
 
 /*****************************************************************************
?????fucIsUnsignedInteger
?????????? ? ? ???
??	?obj,??????
??	?strAlertMsg, ???????????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucIsNoUnsignedInteger(obj,strAlertMsg)
 {
		strInteger=obj.value;//??????
        strInteger=strInteger.replace(/^(\s)*|(\s)*$/g,"");//??????????
        
		//????????
		var newPar=/^\d+$/
		if(strInteger.length>0 && newPar.test(strInteger)==false)
		{
		   obj.focus();
		   alert(strAlertMsg);	
		   return false;	
		 }
		 else
		 {
		    return true;
		 }
 }

/*****************************************************************************
?????fucCheckHTML
?????????????HTML??????
??	?obj,?????????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckHTML(obj)
 {
		strAddress=obj.value;//?????????
		strAddress=strAddress.replace(/^(\s)*|(\s)*$/g,"");//??????????
				
		//?????
		//????http:\\??
		//?.htm?html??
		var newPar=/^[hH][tT]{2}[pP]:(\/|\\){2}(\w|.|-|\/|\\)+(\/|\\)(\w|-)+.[hH][tT][mM](l|L)*$/
		if(strAddress.length>0 && newPar.test(strAddress)==false)
		{
		   obj.focus();
		   alert("??????html?????");	
		   return false;	
		 }
		 else
		 {
		    return true;
		 }
 }
 
 /*****************************************************************************
?????getNowDate
???????????
??    ?????:yyyy-mm-dd
??	?2003-10-17
??    ???
???  ?
???  ?
******************************************************************************/
function getNowDate()
{
	var today=new Date();
	year = today.getUTCFullYear(); 
	month =today.getUTCMonth()+1; 
	day = today.getUTCDate(); 
	if (month <= 9) month = "0" + month; 
	if (day <= 9) day = "0" + day; 
	var clocktext =year+"-"+month+"-"+day;
	return clocktext;
}
 

/*****************************************************************************
?????getNowTime
??????????? 
??    ?????:yyyy-mm-dd hh:mm:ss
??  ?2003-11-17
??    ???
???  ?
???  ?
******************************************************************************/
function getNowTime()
{
    var today=new Date();					//?????????
	var year = today.getUTCFullYear();		//?
	var month =today.getUTCMonth()+1;		//?
	var day = today.getUTCDate();			//?
	var hour=today.getHours();				//?
	var minute=today.getMinutes();			//?
	var second=today.getSeconds();			//?
	if (month <= 9) month = "0" + month; 
	if (day <= 9) day = "0" + day;
	if (hour <= 9) hour = "0" + hour;
	if (minute <= 9) minute = "0" + minute;
	if (second <= 9) second = "0" + second;
	var clocktext =year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
	return clocktext;
}

/*****************************************************************************
?????okDate
????? ????????,?????"YYYY-MM-DD"
??    ??????
??  ?2004-06-10
??    ????
???  ?
???  ?
******************************************************************************/
function okDate(strDate,strMsg)
{
	var ruleDate=/^\d{4}\-\d{2}\-\d{2}$/;
	
	var myyear,mymonth,myday;//?????
	if(ruleDate.test(strDate)==false)
	{
		alert(strMsg);			
		return false;
	}				
	
	var strArray=strDate.split("-");//?????
	myyear=strArray[0];
	mymonth=strArray[1];
	myday=strArray[2];		
	if (mymonth>12)
	{
		alert("??"+mymonth+"?");
		return false;
	}
	else if (myday>31)
	{
		alert("???"+myday+"?");
		return false;
	}
	else if (mymonth==4&&myday>30)
	{
		alert(myyear+"?"+mymonth+"???"+myday+"???");
		return false;
	}
	else if (mymonth==6&&myday>30)
	{
		alert(myyear+"?"+mymonth+"???"+myday+"???");
		return false;
	}
	else if (mymonth==9&&myday>30)
	{
		alert(myyear+"?"+mymonth+"???"+myday+"???");
		return false;
	}
	else if (mymonth==11&&myday>30)
	{
		alert(myyear+"?"+mymonth+"???"+myday+"???");
		return false;
	}		
	else if (myyear%4==0||(myyear%100==0&&myyear%400==0))
	{
		if(mymonth==2&&myday>29)
		{
			alert(myyear+"?"+mymonth+"???"+myday+"????");
			return false;
		}				
	}
	else if(mymonth==2&&myday>28)
	{
		alert(myyear+"?"+mymonth+"???"+myday+"????");
		return false;				
	}		
	else		
		return true;		
}


/*****************************************************************************
?????fucCheckDateOrder
????????????????????
??	?strDate,???????
??	?strEDate,???????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckDateTimeOrder(strSDate,strEDate,strMsg)
{
    strSDate=strSDate.replace(/\-/,"\/");
    strEDate=strEDate.replace(/\-/,"\/");
    if(strMsg==""||strMsg==null)
    {
       strMsg="????????????????";
    }
   
   //????
    if(new Date(strSDate).getTime()>=new Date(strEDate).getTime())
    {
        alert(strMsg);
        return false;
     }
     else
     {
        return true;
     }
}

/*****************************************************************************
?????fucCheckDateOrder
????????????????????(????????2003-09-01)
??	?strDate,???????
??	?strEDate,???????
??    ??????  true/false
??	?2003-10-21
??    ???
???  ?
???  ?
******************************************************************************/
function fucCheckDateOrder(strSDate,strEDate,strMsg)
{
    strSDate=strSDate.replace(/\-/,"\/");
    strEDate=strEDate.replace(/\-/,"\/");
    
    if(strMsg==""||strMsg==null)
    {
       strMsg="????????????????";
    }
   
   //????
    if(new Date(strSDate).getTime()>new Date(strEDate).getTime())
    {
        alert(strMsg);
        return false;
     }
     else
     {
        return true;
     }
}

/*****************************************************************************
?????fucCheckIDCard
????????????
??	?strIDCard
??    ??????  true/false
??	?2005-02-21
??    ????
???  ?
???  ?
******************************************************************************/
function fucCheckIDCard(strIDCard,strMsg)
{
    strIDCard=strIDCard.replace(/^(\s)*|(\s)*$/g,""); //??????????

    var ruleIDCard=/^\d{15}(\d{2}(\d|[xX]))?$/;
    

	if(ruleIDCard.test(strIDCard)==false)
	{
		alert(strMsg);			
		return false;
	}
}

/*****************************************************************************
?????fucCheckPhone
???????????(?????)
??	?strPhone (0898-66739511)
??    ??????  true/false
??	?2005-02-21
??    ????
???  ?
???  ?
******************************************************************************/
function fucCheckPhone(strPhone)
{
    strPhone=strPhone.replace(/^(\s)*|(\s)*$/g,""); //??????????

    //var rulePhone=/^0\d{2,4}\-\d{6,8}$/;
	var rulePhone=/^[\d()-]{6,30}$/;   
    
	
	if(rulePhone.test(strPhone)==false)
	{
		return false;
	}
	
	
}

function fucCheckMobile(strMobile)
{
	strMobile=strMobile.replace(/^(\s)*|(\s)*$/g,""); //??????????    
    //var ruleMobile=/^13\d{9}$/; 
    var ruleMobile=/^[\d()-]{6,30}$/;    
	
	if(ruleMobile.test(strMobile)==false )
	{
		return false;
	}
}

function fucCheckTicketNO(ticketNO,strMsg)
{
	ticketNO=ticketNO.replace(/^(\s)*|(\s)*$/g,"");
    var ruleTicketNO=/^880(\-)?\d{10}$/;    
	
	if(ruleTicketNO.test(ticketNO)==false)
	{
		alert(strMsg);	
		return false;
	}	
}

function fucCheckName(obj,strAlertMsg)
 {
		strName=obj.value;
		strName=strName.replace(/^(\s)*|(\s)*$/g,"");//??????????
				
		//?????Ö»ÄÜÊä
		//??????????a-z,A-Z,0-9????????email?
		//email????????????????,????.,?????????
		var newPar=/[A-Za-z]{2,}\/[A-Za-z]{2,}/;
		//var testChinese=/^[Ò»-ý›]{1,}$/;
		if(strName.length>0 && (newPar.test(strName)==false))
		{
		   alert(strAlertMsg);
		   obj.focus();	
		   return false;	
		 }
		 else
		 {
		    return true;
		 }
 }
