<!--
function Jtrim(str)
{

        var i = 0;
        var len = str.length;
        if ( str == "" ) return( str );
        j = len -1;
        flagbegin = true;
        flagend = true;
        while ( flagbegin == true && i< len)
        {
           if ( str.charAt(i) == " " )
                {
                  i=i+1;
                  flagbegin=true;
                }
                else
                {
                        flagbegin=false;
                }
        }

        while  (flagend== true && j>=0)
        {
            if (str.charAt(j)==" ")
                {
                        j=j-1;
                        flagend=true;
                }
                else
                {
                        flagend=false;
                }
        }

        if ( i > j ) return ("")

        trimstr = str.substring(i,j+1);
        return trimstr;
}
//检测Email是否合法
function checkmail(email)
{
if (email=="" )
return false;


	invalidChars = " /:"

	if (email == "") {
		return (false);
	}

	for (i=0; i < invalidChars.length; i++) {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) != -1) {
			return (false);
		}
	}

	atPos = email.indexOf("@", 1)
	if (atPos == -1) {
		return (false);
	}

	//if (email.indexOf("@", atPos + 1) != -1) {
	//	return (false);
	//}

	periodPos = email.indexOf(".", atPos)
	if (periodPos == -1) {
		return (false);
	}

	if (periodPos + 3 > email.length) {
		return (false);
	}

	return (true);
}
//检测输入日期是否合法
function istrueDate(inputyear,inputmonth,inputday)
{
	var nowdate=new Date();
	var result;
	var varleap_year;
	result=true;
	if ((inputyear<1850)||(inputyear>2500)||(!isDigital(inputyear)))
	{
		result=false;
	}
	if ((((parseInt(inputyear)%4)==0)&&((parseInt(inputyear)%100)!=0))||((parseInt(inputyear)%400)==0))	
	{
		if ((parseInt(inputmonth)==2)&&(parseInt(inputday)>29))
		{
		      result=false;
		}
		switch(parseInt(inputmonth))
		{
			case 4: 
			if (parseInt(inputday)>30)
			{
				result=false;break;
			}
			case 6: 
			if (parseInt(inputday)>30)
			{
				result=false;break;
			}
			case 9: 
			if (parseInt(inputday)>30)
			{
				result=false;break;
			}
			case 11: 
			if (parseInt(inputday)>30)
			{
				result=false;break;
			}
		}
	}
	else
	{
		switch(parseInt(inputmonth))
		{
			case 2: 
			if (parseInt(inputday)>28)
			{
				result=false;break;
			}
			case 4: 
			if (parseInt(inputday)>30)
			{
				result=false;break;
			}
			case 6: 
			if (parseInt(inputday)>30)
			{
				result=false;break;
			}
			case 9: 
			if (parseInt(inputday)>30)
			{
				result=false;break;
			}
			case 11: 
			if (parseInt(inputday)>30)
			{
				result=false;break;
			}
		}
	}
	return result;
}
function isTel(checkStr)
{
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 getStrLength(str)
{
	var L;
	var arr;
	L=0;
	arr=str.split("");
	for (var I=0;I<=arr.length-1;I++)
	{
		if (arr[I].charCodeAt(0)<129)
			L++;
		else
			L=L+2;
	}
	return L
}

function isEmail(s)
{
        if (s.length > 100)
                return false;
         var regu = "^(([0-9a-zA-Z]+)|([0-9a-zA-Z]+[_.0-9a-zA-Z-]*[_.0-9a-zA-Z]+))@([a-zA-Z0-9-]+[.])+([a-zA-Z]{2}|net|NET|com|COM|gov|GOV|mil|MIL|org|ORG|edu|EDU|int|INT)$";
         var re = new RegExp(regu);
         if (s.search(re) != -1)
              return true;
          else 
             return false;
}


function chooseAll(chooseMode,flag,key){
	for(var i=0;i<=document.thisForm.elements.length-1;i++){
		var e=document.thisForm.elements[i];
		if((e.name).indexOf(key)!=-1) 
		switch(chooseMode){
			case "all":
				e.checked=flag;
			break;
			case "other":
				if(e.checked==true)
					e.checked=false;
				else
					e.checked=true;
			break;
		}
	}
}
//******************************************************//
// 去掉前后空格
//******************************************************//

function isDate(str)
{var regstr=/^\d{4}-(\d{1}|11|12)-([1-2]?\d{1}|3[0-1])$/;
 return regstr.test(str);
}
function chk_mail(theForm)
{var reg=/^\D.*/;
 if (reg.test(theForm.Name.value)) theForm.choice.selectedIndex=3;
}

function isDigital(checkStr)
{
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 check_emptydata(obj) {
	var checkobjvalue;
	checkobjvalue=obj.value;
	if (obj.type=="text") {
		if (checkobjvalue.length>1)
			return true;
		else
			return false; 
	}
	if (obj.type=="checkbox" || obj.type=="radio") {
		if (obj.checked==true)
			return true;
		else
			return false; 
	}
}


/**
*测试中英文长度，
*返回值为字符串（包括中文）的长度
*/
function strLen(s)
{
    var i,str1,str2,str3,nLen;
    str1 = s;
    nLen = 0;
    for(i=1;i<=str1.length;i++)
    {
        str2=str1.substring(i-1,i)
        str3=escape(str2);
        if(str3.length>3)
        {
            nLen = nLen + 2;
        }
        else
        {
            nLen = nLen + 1;
        }
    }
    return nLen;
}


function IsValidString(checkStr)
{
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
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 checkIdCard(s, s1)
    {
        var flag;
        var s2;
        var s5;
        var s8;
        var s11;
       var s_year;
       var s_month;
       var s_day;
       flag=true;
	s_year=s1.substring(0,4);
	s_month=s1.substring(5,7);
	s_day=s1.substring(8,10);
        if(s.length!= 15 && s.length!= 18 || !istrueDate(s_year,s_month,s_day))
            flag = false;
        else
        if(s.length == 15)
        {
            if(!isDigital(s))
            {
                flag = false;
            } else
            {
                var s3 = "19" + s.substring(6, 8);
                var s6 = s.substring(8, 10);
                var s9 = s.substring(10, 12);
                var s12 = s3 + "-" + s6 + "-" + s9;
                if(s12!=s1)
                    flag = false;
            }
        } else
        if(s.substring(17,18)=="X" || s.substring(17,18)=="x")
        {
            if(!isDigital(s.substring(0,17))) {
                flag = false;
            }
        } else
        if(!isDigital(s))
        {
            flag = false;
        } else
        {
            var s4 = s.substring(6,10);
            var s7 = s.substring(10,12);
            var s10 = s.substring(12,14);
            var s13 = s4 + "-" + s7 + "-" + s10;
            if(s13!=s1)
                flag = false;
        }
        return flag;
}
//-->