<!--
function jsLTrim(str){
var rtnStr;
rtnStr=""
for (var i=0;i<=str.length-1;i++){
//先运行一遍,i再加1
if (str.charAt(i)!=" "){
rtnStr=str.substr(i);
break;
}
}
return rtnStr;
}
function jsRTrim(str){
var rtnStr;
rtnStr=""
for (var i=str.length-1;i>=0;i--){
//先运行一遍,i再减1
if (str.charAt(i)!=" "){
rtnStr=str.substring(0,i+1);
break;
}
}
return rtnStr;
}
function jsTrim(str){
return(jsLTrim(jsRTrim(str)));
}

function CheckMail(email)
{
	if (email == "") {
		return (false);
	}
   var validChars;
	validChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-.@";
	for (i=0;i < email.length; i++) {
		email_test = email.charAt(i)
		if (validChars.indexOf(email_test,0) == -1) {
			return (false);
		}
	}
	atPos = email.indexOf("@", 1);
	if (atPos == -1) {
		return (false);
	}
	periodPos = email.indexOf(".", atPos);
	if (periodPos == -1) {
		return (false);
	}

	if (periodPos + 3 > email.length) {
		return (false);
	}
	return (true);
}

function isDigital(checkStr)
//例如checkStr值为32A566
//例如checkStr值不可以为0
{
var checkOK = "0123456789.";
var allValid = true;
if (checkStr.length<1)
 allValid=false;
 
  for (i=0;i<checkStr.length;i++)
  {
    ch=checkStr.charAt(i);
	if ((ch==0)&&(i==0)){
	 allValid = false;
	 break;
	 }
    for(j=0;j<checkOK.length;j++)
      if(ch==checkOK.charAt(j))
        break;
    if(j==checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  return allValid;
}

function isDigital2(checkStr)
//例如checkStr值为32A566
//例如checkStr值可以为0
{
var checkOK = "0123456789.";
var allValid = true;
if (checkStr.length<1)
 allValid=false;
 
  for (i=0;i<checkStr.length;i++)
  {
    ch=checkStr.charAt(i);
    for(j=0;j<checkOK.length;j++)
      if(ch==checkOK.charAt(j))
        break;
    if(j==checkOK.length)
    {
      allValid = false;
      break;
    }
  }

  return allValid;
}


//判别固定电话
function isDigital3(checkStr){

//----------------1

var checkOK = "0123456789 -";
var allValid = true;
var SpaceCount=0 

if(Trim(checkStr)==""){
allValid = false;
}
checkStr=Trim(checkStr)

if (checkStr.length<7){
allValid = false;
}

//---------------1

//---------------2
for (i=0;i<checkStr.length;i++)
  {
    ch=checkStr.charAt(i);
	//计算空格个数
	  if (ch==" ")
      {
	   SpaceCount=SpaceCount+1;
      } 
	  
    for(j=0;j<checkOK.length;j++)
	
      if(ch==checkOK.charAt(j))
        break;
    if(j==checkOK.length)
    {
      allValid = false;
      break;
    }
	
  }
//---------------2

//---------------3
   //例如：0769-22255776 22634378 22386378
	HxPos = checkStr.indexOf("-", 0);
	//0769-  HxPos为4
	TelCode=checkStr
	if (HxPos >=0) {
	AreaCode=checkStr.substring(0,HxPos);
	//0769
	if ((AreaCode.length<3)||(AreaCode.length>4)){
	    allValid = false;
	}
	
   TelCode=checkStr.substr(HxPos+1);
 if (SpaceCount==0){
   //只有一个电话
	  if ((TelCode.length>8)||(TelCode.length<7)){
	    allValid = false;
	  }
    }
  }
//---------------3

//---------------4
    //22255776 22634378 22386378
     if (SpaceCount>0){
	 //多个电话
	  m=0
      for (s=1;s<=SpaceCount;s++){
  	       SpacePos=TelCode.indexOf(" ", 0);
		   
	       TelCodeFront=TelCode.substring(0,SpacePos);
		   TelCodeLeave=TelCode.substr(SpacePos+1);
		   
	   if ((TelCodeFront.length>8)||(TelCodeFront.length<7)){
	    allValid = false;
	   }
	   
	   TelCode=TelCodeLeave
	      m=m+1
          if (m==SpaceCount){
	      if ((TelCode.length>8)||(TelCode.length<7)){
		   //  document.location.href="../default.asp"
	         allValid = false;
	       }
	      }
		  
      } 
    }
//---------------4

  return allValid;
}




//判别移动电话
function isDigital4(checkStr){

//----------------1
var checkOK = "0123456789 -";
var allValid = true;
var SpaceCount=0 

if(Trim(checkStr)==""){
allValid = false;
}
checkStr=Trim(checkStr)
//---------------1

//---------------2
for (i=0;i<checkStr.length;i++)
  {
    ch=checkStr.charAt(i);
	//计算空格个数
	  if (ch==" ")
      {
	   SpaceCount=SpaceCount+1;
      } 

    for(j=0;j<checkOK.length;j++)
      if(ch==checkOK.charAt(j))
        break;
    if(j==checkOK.length)
    {
      allValid = false;
      break;
    }
  }
//---------------2




//---------------4
    //22255776 22634378 22386378
     if (SpaceCount>0){
	 //多个电话
	  m=0
      for (s=1;s<=SpaceCount;s++){
  	       SpacePos=checkStr.indexOf(" ", 0);

	       TelCodeSpaceFront=checkStr.substring(0,SpacePos);
		   TelCodeLeave=checkStr.substr(SpacePos+1);
    
	 //引用函数
    if (!isDigital4Fun(TelCodeSpaceFront))
	{
    allValid = false;
    }
	   checkStr=TelCodeLeave
	 m=m+1
    if (m==SpaceCount){
	//引用函数
    if (!isDigital4Fun(checkStr))
	{
    allValid = false;
    }

	      }
      } 
    }
//---------------4


//----------------5
//只有一个电话
 if (SpaceCount==0){
//引用函数
    if (!isDigital4Fun(checkStr))
	{
    allValid = false;
    }
}
//----------------5

  return allValid;
}


function isDigital4Fun(checkStr){
var FunAllValid = true;
//---------------3c
//例如：0769-22255776
HxPos = checkStr.indexOf("-", 0);
//有"-"
if (HxPos>=0) {
	AreaCode=checkStr.substring(0,HxPos);
	//0769
	if ((AreaCode.length<3)||(AreaCode.length>4)){
	    FunAllValid = false;
	}
   TelCodeHxBack=checkStr.substr(HxPos+1);
    if ((TelCodeHxBack.length>8)||(TelCodeHxBack.length<7)){
	    FunAllValid = false;
	   }
}
//没有"-"
if (HxPos==-1) {
	   if ((checkStr.length>12)||(checkStr.length<7)){
	    FunAllValid = false;
	   }
}
//---------------3c
  return FunAllValid;
}


function isDigital5(checkStr)
//例如checkStr值为32A566
//例如checkStr值不可以为0,也没有点号"."
{
var checkOK = "0123456789";
var allValid = true;
if (checkStr.length<1)
 allValid=false;
 
  for (i=0;i<checkStr.length;i++)
  {
    ch=checkStr.charAt(i);
	if ((ch==0)&&(i==0)){
	 allValid = false;
	 break;
	 }
    for(j=0;j<checkOK.length;j++)
      if(ch==checkOK.charAt(j))
        break;
    if(j==checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  
  return allValid;
}









function Trim(str){
 if(str.charAt(0) == " "){
  str = str.slice(1);
  str = Trim(str); 
 }
 return str;
}

function isLeapYear(year) 
{ 
//润年
 if((year%4==0&&year%100!=0)||(year%400==0)) 
 { 
 return true; 
 }  
 return false; 
} 


function isDate(checktext){
var datetime;
var year,month,day;
var gone,gtwo;
if(Trim(checktext)!=""){
 datetime=Trim(checktext);
 
 MonthStr=datetime.substring(5,6);
 if(MonthStr=="0"){
    return false;
 }

 if(datetime.length==8){
  //例如:2005-3-1
  year=datetime.substring(0,4);
  if(isNaN(year)==true){
   return false;
  }
  gone=datetime.substring(4,5);
  month=datetime.substring(5,6);
  if(isNaN(month)==true){
   return false;
  }
  gtwo=datetime.substring(6,7);
  day=datetime.substring(7,8);
  if(isNaN(day)==true){
   return false;
  }
  
  if((gone=="-")&&(gtwo=="-")){
  
   if(month<1||month>12) { 
    return false; 
    } 
	
	if(day<1||day>31){
    return false; 
    }
	
	 if(month==2){  
     if(isLeapYear(year)&&day>29){ 
       return false; 
     }       
     if(!isLeapYear(year)&&day>28){ 
       return false; 
     } 
    } 
    if((month==4||month==6||month==9||month==11)&&(day>30)){ 
     return false; 
    } 
     return true;
    }
	 return true;
    }
 
if(datetime.length==9){
  //例如:情况A 2005-3-10
  year=datetime.substring(0,4);
  if(isNaN(year)==true){
   return false;
  }
  gone=datetime.substring(4,5);

gtwo=datetime.substring(6,7);
if (gtwo=="-"){

  month=datetime.substring(5,6);
  if(isNaN(month)==true){
   return false;
  }
  
  day=datetime.substring(7,9);
  if(isNaN(day)==true){
   return false;
  }
  
  dayInitial=datetime.substring(7,8);
  if(dayInitial=="0"){
   return false;
  }

  if((gone=="-")&&(gtwo=="-")){
  
   if(month<1||month>12) { 
    return false; 
    } 
	if(day<1||day>31){
    return false; 
    }
	
	 if(month==2){  
     if(isLeapYear(year)&&day>29){ 
       return false; 
     }       
     if(!isLeapYear(year)&&day>28){ 
       return false; 
     } 
    } 
	
    if((month==4||month==6||month==9||month==11)&&(day>30)){ 
     return false; 
    } 
     return true;
    }
}
//例如:情况B 2005-12-1
gtwo=datetime.substring(7,8);
if (gtwo=="-"){
  month=datetime.substring(5,7);
  if(isNaN(month)==true){
   return false;
  }
  day=datetime.substring(8,9);
  if(isNaN(day)==true){
   return false;
  }

  if((gone=="-")&&(gtwo=="-")){
  
   if(month<1||month>12) { 
    return false; 
    } 
	if(day<1||day>31){
    return false; 
    }
	
	 if(month==2){  
     if(isLeapYear(year)&&day>29){ 
       return false; 
     }       
     if(!isLeapYear(year)&&day>28){ 
       return false; 
     } 
    } 
	
    if((month==4||month==6||month==9||month==11)&&(day>30)){ 
     return false; 
    } 
     return true;
    }
}
	 return true;
    }

 if(datetime.length==10){
//例如:情况B 2005-12-11
  year=datetime.substring(0,4);
  if(isNaN(year)==true){
   return false;
  }
  gone=datetime.substring(4,5);
  month=datetime.substring(5,7);
  if(isNaN(month)==true){
   return false;
  }
  gtwo=datetime.substring(7,8);
  day=datetime.substring(8,10);
  if(isNaN(day)==true){
   return false;
  }
  
  dayInitial=datetime.substring(8,9);
  if(dayInitial=="0"){
   return false;
  }
  
  if((gone=="-")&&(gtwo=="-")){
   if(month<1||month>12) { 
    return false; 
    } 
   if(day<1||day>31){ 
    return false; 
   }else{
    if(month==2){  
     if(isLeapYear(year)&&day>29){ 
       return false; 
     }       
     if(!isLeapYear(year)&&day>28){ 
       return false; 
     } 
    } 
    if((month==4||month==6||month==9||month==11)&&(day>30)){ 
     return false; 
    } 
   }
  }else{
   return false;
  }
 }else{
  return false;
 }
}else{
 return true;
}
return true;
}

//-->