//*****************************************************
//* FunctionName:	PhoneCheck
//* Purpose:		check telephone
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		
//*****************************************************
function PhoneCheck(s)
{
	var str=s;
	var reg=/(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)|(^[0-9]{10,11}$)/
	if (!reg.test(str))
	{
		return false;
	}
	else
	{
		return true;
	}
}
//*****************************************************
//* FunctionName:	GetValueChoose
//* Purpose:		check if checked
//* Modified:
//* Parameter1:		
//* Return:			1/0
//* Example:		
//*****************************************************
function GetValueChoose(el)
{
	var sValue = 0;
    for(var i=0;i<el.length;i++)
    {
		if(el[i].checked)
        {
			sValue += 1;
        }
    }
    return sValue;
}
//*****************************************************
//* FunctionName:	ismail
//* Purpose:		check email
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		
//*****************************************************
function ismail(mail)
{
	return(new RegExp(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/).test(mail));
}
//*****************************************************
//* FunctionName:	CnWordRegCheck
//* Purpose:		check chinese
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		
//*****************************************************
function CnWordRegCheck(obj)
{
	var str = obj
	var reg=/^[\u4e00-\u9fa5](\s*[\u4e00-\u9fa5])*$/;
	var flag = reg.test(str);
	return flag;
}
//*****************************************************
//* FunctionName:	NumRegCheck
//* Purpose:		check int
//* Modified:
//* Parameter1:		
//* Return:			1/0
//* Example:		
//*****************************************************
function NumRegCheck(NUM)
{
	var i,j,strTemp;
	strTemp="0123456789";
	if ( NUM.length == 0)
	{
		return 1;
	}
	else
	{
		for (i=0;i<NUM.length;i++)
		{
			j=strTemp.indexOf(NUM.charAt(i)); 
			if (j==-1)
			{
				return 0;
			}
	    }
	    return 1;
    }
}
//*****************************************************
//* FunctionName:	isFloat
//* Purpose:		check float
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		
//*****************************************************
function isFloat(s)
{	
	var str=s;
	var reg=/^\+?(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/;
	if (!reg.test(str))
	{
		return false;
	}
	else
	{
		return true;
	}
}
//*****************************************************
//* FunctionName:	IdCardRegCheck
//* Purpose:		check id card
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		
//*****************************************************
function IdCardRegCheck(obj)
{
	var str = obj
	var reg = /^([0-9]{15}|[0-9]{18})$/;
	var flag = reg.test(str);
	return flag; 
}
//*****************************************************
//* FunctionName:	checkHTTP
//* Purpose:		check http url
//* Modified:
//* Parameter1:		
//* Return:			1/0
//* Example:		
//*****************************************************
function checkHTTP(string)
{
	
	//re1= /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/; //Email
	re1= /http:\/\/([\w-]+\.)+[\w-]+([\w- ./?%&=]*)?/;	//URL
	if (re1.test(string))
	{
		return 1;
	}
	else
	{
		return 0;
	}
	
}
//*****************************************************
//* FunctionName:	isNumber
//* Purpose:		1234
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		isNumber(document.MyForm.Num.value)
//*****************************************************
function isNumber( data )
{
  var tempStr = "-0123456789" ;
  var thisChar ;
  for( var i=0 ; i < data.length ; i++ )
  {
	thisChar = data.substring( i, i+1 ) ;
	if ( tempStr.indexOf(thisChar, 0) == -1 )
	{
	  return( false ) ;
	}
  }
  return( true ) ;
}

//******************************************************************
//* FunctionName:	isPointNum
//* Purpose:		"123.45"
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		isPointNum(document.MyForm.number.value,5,2)
//******************************************************************
function isPointNum( usngNum,uintBefPoint,uintAftPoint )
{
    if(isPoint(usngNum) == true){
	 if(usngNum.indexOf(".")!="-1"){
	 	if(usngNum.indexOf(".")==usngNum.lastIndexOf(".")){
		    if(usngNum.indexOf(".") == 0){
		    	return false ; 	
		    }else{
			var wstrBefPoint  = usngNum.substring(0,usngNum.indexOf(".")); 
			var wstrAftPoint= usngNum.substring(usngNum.indexOf(".")+1); 
			if( wstrBefPoint.substring(0,1) == 0 && wstrBefPoint.length > 1){
			    return false ;	    	
			}else{
			    if(wstrAftPoint.length == 0 ){
			    	return false;	
			    }else{
				if(wstrBefPoint.length <= uintBefPoint-uintAftPoint && wstrAftPoint.length <= uintAftPoint){
				    return true ;
				}else{
				    return false;
				}
			    }
			}
		    }
		}else{
		    return false ;
		}
	 }else{
	    	if(usngNum.length>uintBefPoint-uintAftPoint){
	    		return false ;	
	    	}else{
	    		return true ;
	    	}
	}
     }else{
     	return false ;
     }

}
//*****************************************************
//* FunctionName:	isPoint
//* Purpose:		
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		isPoint(document.MyForm.Num.value)
//*****************************************************
function isPoint( data )
{
  var tempStr = "-0123456789." ;
  var thisChar ;
  for( var i=0 ; i < data.length ; i++ )
  {
	thisChar = data.substring( i, i+1 ) ;
	if ( tempStr.indexOf(thisChar, 0) == -1 )
	{
	  return( false ) ;
	}
  }
  return( true ) ;
}
//*****************************************************
//* FunctionName:	delLastSpace
//* Purpose:		del space	
//* Modified:
//* Parameter1:		document.MyForm.Num
//* Return:			
//* Example:		isDateTime(document.MyForm.Num.value
function delLastSpace( strField ){
    if( strField.value.match("[ ]$") != null ){
        while(1){
            if( strField.value.match("[ ]$") == null )    break;
            strNew = strField.value.substring(0,(strField.value.length-1));
            strField.value = strNew;
        }
    }

}

//*****************************************************
//* FunctionName:	isNull
//* Purpose:		
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		isNull(document.MyForm.Num)
//*****************************************************
function isNull(inField){
  delLastSpace(inField);
  if (inField.value=="" || inField.length==0)
    return false;
  else
    return true;
}

//*****************************************************
//* FunctionName:	getLength
//* Purpose:		
//* Modified:
//* Parameter1:		
//* Return:			int
//* Example:		getLength(document.MyForm.Text1.value)
//*****************************************************
function getLength(data)
{
	var len = 0 ;
	len = data.length ;
	return ( len ) ;
}

//*****************************************************
//* FunctionName:	getLengthB
//* Purpose:		byte
//* Modified:
//* Parameter1:		
//* Return:			int
//* Example:		getLengthB(document.MyForm.Text1.value)
//*****************************************************
function getLengthB(data)
{
  var i,cnt = 0;
  for(i=0; i< data.length; i++)
  {	
  	if (checkFullHalf(data.charAt(i))){
  		cnt+=2;
  	}else{
		if (escape(data.charAt(i)).length >= 4 )
		{
		  if (escape(data.charAt(i)) >= "%uFF65" && escape(data.charAt(i)) <= "%uFF9F")
		  {
			cnt++;
		  }
		  else
		  {
			cnt+=2;
		  }
		}
		else
		{
		  cnt++;
		}
	}
   }
  return cnt;
}

//*****************************************************
//* FunctionName:	isDate
//* Purpose:		"YYYY-MM-DD"
//* Modified:
//* Parameter1:		"YYYY-MM-DD"
//* Return:			true/false
//* Example:		isDate(document.MyForm.Num.value)
//*****************************************************
function isDate( ustrDate )
{
	if(ustrDate.length != 0){
	    //if(ustrDate.length != 8){
	    //	return false ;
	    //} 
		var myYear = parseInt(ustrDate.indexOf('-'));
		var myDay = parseInt(ustrDate.lastIndexOf('-'))+1
		
	    var wstrYear  = ustrDate.substring(0,myYear); 
	    var wstrMonth = ustrDate.substring(myYear+1,myDay-1); 
	    var wstrDay   = ustrDate.substr(myDay); 
	    
	    var wstrDate  = new Date(wstrYear+"/"+wstrMonth+"/"+wstrDay);
		
	    if(wstrDate.getFullYear() == wstrYear && wstrDate.getMonth()+1==wstrMonth && wstrDate.getDate() == wstrDay){
			return true ;	    	
	    }else{
	    	return false ;
	    }
	}else{
		return true ;
	}
}

//*****************************************************
//* FunctionName:	isDateYMD
//* Purpose:		"YYYYMMDD"
//* Modified:
//* Parameter1:		
//* Return:			true/false
//* Example:		isDate(document.MyForm.Num.value)
//*****************************************************
function isDateYMD( ustrDate )
{
	if(ustrDate.length != 0){
	    if(ustrDate.length != 8){
	    	return false ;
	    } 
	    var wstrYear  = ustrDate.substring(0,4); 
	    var wstrMonth = ustrDate.substring(4,6); 
	    var wstrDay   = ustrDate.substring(6,8); 
	    
	    var wstrDate  = new Date(wstrYear+"/"+wstrMonth+"/"+wstrDay);
	    if(wstrDate.getFullYear() == wstrYear && wstrDate.getMonth()+1==wstrMonth && wstrDate.getDate() == wstrDay){
			return true ;	    	
	    }else{
	    	return false ;
	    }
	}else{
		return true ;
	}
}
//*****************************************************
//* FunctionName:	isDateTime
//* Purpose:		"YYYY-MM-DD HH:MM:SS"
//* Modified:
//* Parameter1:		"YYYY-MM-DD HH:MM:SS"
//* Return:			true/false
//* Example:		isDateTime(document.MyForm.Num.value)
//*****************************************************
function isDateTime( ustrDate )
{
	if(ustrDate.length != 0){
	    //if(ustrDate.length != 8){
	    //	return false ;
	    //} 
		var myYear = parseInt(ustrDate.indexOf('-'));
		var myDay = parseInt(ustrDate.lastIndexOf('-'))+1
		var myBlank = parseInt(ustrDate.indexOf(' '));
		
	    var wstrYear  = ustrDate.substring(0,myYear); 
	    var wstrMonth = ustrDate.substring(myYear+1,myDay-1); 
	    var wstrDay   = ustrDate.substring(myDay,myBlank); 
	    var wstrTime  = ustrDate.substr(myBlank);
	    
	    var myHour = parseInt(wstrTime.indexOf(':'));
	    var mySecond = parseInt(wstrTime.lastIndexOf(':'))+1;
	    var wstrHour  = wstrTime.substring(0,myHour); 
	    var wstrMinute = wstrTime.substring(myHour+1,mySecond-1); 
	    var wstrSecond   = wstrTime.substr(mySecond); 
	    
	    var wstrDate  = new Date(wstrYear+"/"+wstrMonth+"/"+wstrDay);

	    if(wstrDate.getFullYear() == wstrYear && wstrDate.getMonth()+1==wstrMonth && wstrDate.getDate() == wstrDay && wstrHour<24 && wstrMinute<60 && wstrSecond<60){
			return true ;	    	
	    }else{
	    	return false ;
	    }
	    
	    
	}else{
		return true ;
	}
}
