function BASEtrim(str){
	  lIdx=0;rIdx=str.length;
	  if (BASEtrim.arguments.length==2)
	    act=BASEtrim.arguments[1].toLowerCase()
	  else
	    act="all"
      for(var i=0;i<str.length;i++){
	  	thelStr=str.substring(lIdx,lIdx+1)
		therStr=str.substring(rIdx,rIdx-1)
        if ((act=="all" || act=="left") && thelStr==" "){
			lIdx++
        }
        if ((act=="all" || act=="right") && therStr==" "){
			rIdx--
        }
      }
	  str=str.slice(lIdx,rIdx)
      return str
}
function BASEisNotNum(theNum){
	if (BASEtrim(theNum)=="")
		return true
	for(var i=0;i<theNum.length;i++){
	    oneNum=theNum.substring(i,i+1)
        if (oneNum<"0" || oneNum>"9")
          return true
    }
	return false
}
function parseNum(theNum){
  if (theNum.substring(0,1)==0)
    theNum=theNum.substring(1)
  return theNum
}
function BASEisNotInt(theInt){
	theInt=BASEtrim(theInt)
	if ((theInt.length>1 && theInt.substring(0,1)=="0") || BASEisNotNum(theInt)){
		return true
	}
	return false
}
function BASEisNotFloat(theFloat){
	len=theFloat.length
	dotNum=0
	if (len==0)
		return true
	for(var i=0;i<len;i++){
	    oneNum=theFloat.substring(i,i+1)
		if (oneNum==".")
			dotNum++
        if ( ((oneNum<"0" || oneNum>"9") && oneNum!=".") || dotNum>1)
          return true
    }
	if (len>1 && theFloat.substring(0,1)=="0"){
		if (theFloat.substring(1,2)!=".")
			return true
	}
	return false
}
function parseYMD(theYear,theMonth,theDay) {
  theYear=parseNum(theYear)
  theMonth=parseNum(theMonth)
  theDay=parseNum(theDay)
  if ((theYear < 1900) || (theYear > 3000)){
    return 1
  }
  if (theMonth < 1 || theMonth > 12){
    return 2
  }
  if ((theMonth==1 || theMonth==3 || theMonth==5 || theMonth==7 || theMonth==8 || theMonth==10 || theMonth==12) &&
      (theDay <1 || theDay > 31)
     ){
    return 3
  }
  if ((theMonth==4 || theMonth==6 || theMonth==9 || theMonth==11) &&
      (theDay <1 || theDay > 30)
     ){
    return 3
  }
  if (theYear%400==0 || (theYear%4==0 && theYear%100!=0)){  //闰年
    if (theMonth==2 && (theDay <1 || theDay > 29) )
      return 3
  }
  else  //平年
    if (theMonth==2 && (theDay <1 || theDay > 28) )
      return 3
  return 0
}
function isInvalidDate(theDate,separator){
  default_style=1
  if (theDate.length>10 || theDate.length<8)
    return true
  idx1=theDate.indexOf(separator)
  if (idx1==-1)
    return true
  idx2=theDate.indexOf(separator,idx1+1)
  if (idx2==-1)
    return true
  if (isInvalidDate.arguments.length>2)
  	default_style=isInvalidDate.arguments[2]
  if (default_style<1 || default_style>9){
  	alert("传入参数有误！请检查。")
	return true
  }
  if (default_style==1){
  theYear=theDate.substring(0,idx1)
  theMonth=theDate.substring(idx1+1,idx2)
  theDay=theDate.substring(idx2+1)
  }
  if (default_style==2){
  theMonth=theDate.substring(0,idx1)
  theDay=theDate.substring(idx1+1,idx2)
  theYear=theDate.substring(idx2+1)
  }
  if (theDay.length>2)
    return true
  if (parseYMD(theYear,theMonth,theDay)>0)
    return true
  else
    return false
}
function BASEalert(theText,notice){  
	  alert(notice)
	  theText.focus()
	  theText.select()
	  return false
}
function BASEreal_len(theText){ 
	  var real_len=0;
	  text_val=theText.value;
	  text_len=theText.value.length;
	  for(i=0;i<text_len;i++){
	    if (text_val.charCodeAt(i)>127){
		  real_len=real_len+2;
		}
	    else{
		  real_len++;
		}
  	  }
	  return(real_len);
}
function Check_Email(string){ 
	var str_len = string.length;
	if (str_len<=5){
	   return true
    	}  
	for(i=0;i<str_len;i++){
	    if (string.charCodeAt(i)>127){
		return true 	
		}
	}
	if (string.indexOf("@")<2){
	    return true
    	}  
        if (string.indexOf(".")==1){
	    return true
    	}  
	if (string.indexOf(":")!=-1){
	    return true
	}
}
