 //去掉左右空格
 function trimFunc(strInfo)
 { 
   return leftTrim(rightTrim(strInfo));
 }
           
 //去掉右空格
 function rightTrim(strInfo)
 {
   var num;
   var strBackInfo;
   num = strInfo.length;
   while(strInfo.charAt(num - 1) == " ")
   {
         num--;
	}
   strBackInfo = strInfo.substring(0, num);
   return strBackInfo;
  }

  //去掉左空格
  function leftTrim(strInfo)
  {
    var num;
	var strBackInfo;
    num= 0;
	while(strInfo.charAt(num) == " ")
	{
	 num++;
	}
	strBackInfo = strInfo.substring(num);
	return strBackInfo;
  }


 //验证是否为合法字符[只能由英文字母和阿拉伯数字，以\n及下划线（'_'、'-'、'.' ）构成](用户登陆)
 function IsValidChar(strchar) 
 {
   for(i=0;i<strchar.length;i++) {
	 atChr = strchar.charCodeAt(i);
	 if(atChr>47 && atChr<58) continue;
	 if(atChr>64 && atChr<91) continue;
	 if(atChr>96 && atChr<123) continue;
	 if(atChr==46 || atChr==95 || atChr==45) continue;
	return(false);
  }
	return(true);
 }

 //验证是否为数字合法性(数字含小数)
 function isValidMaths(strchar) 
   {
      var dotnum;
	  dotnum=0;
	  for(i=0;i<strchar.length;i++) {
	 	  atChr = strchar.charCodeAt(i);
		  if(atChr==46){
		     if (dotnum==0){
			     dotnum=1;
			     continue;
			 }else{
                 return(false);
			 }
		  }
		  if(atChr>47 && atChr<58) continue;
		  return(false);
	      }
	   return(true);
   }

  //验证是否为数字合法性(数字不含小数点)
   function isValidMathsNoDot(strchar) 
   {
	  for(i=0;i<strchar.length;i++) {
	 	  atChr = strchar.charCodeAt(i);
		  if(atChr>47 && atChr<58) continue;
		  return(false);
	      }
	   return(true);
   }




//验证选择的日期是否正确
 function isValidData(stryear,strmonth,strday){
          
		  var yearnum;
          var monthnum;
          var daynum;

          var flag=true;
          
		  //判断是否为空
          if ((stryear=="")||(strmonth=="")||(strday==""))
          {
			  return(false);
          }

		  yearnum=parseInt(stryear)  
		  monthnum=parseInt(strmonth) 
		  daynum=parseInt(strday)

         //判断是否是瑞年 
           if (((yearnum%4)==0)&&((yearnum%100)!=0)||((yearnum%400)==0)){
                  if ((monthnum==1)||(monthnum==3)||(monthnum==5)||(monthnum==7)||(monthnum==8)||(monthnum==10)||(monthnum==12)){
					   if (daynum>=32){return(false);}
			      }
                  else if ((monthnum==4)||(monthnum==6)||(monthnum==9)||(monthnum==11)){
					   if (daynum>=31){return(false);}
			      }
                  else if (monthnum==2) {
                       if (daynum>=30){return(false);}
				   }
		    }else{
                  if ((monthnum==1)||(monthnum==3)||(monthnum==5)||(monthnum==7)||(monthnum==8)||(monthnum==10)||(monthnum==12)){
					   if (daynum>=32){return(false);}
			      }
                  else if ((monthnum==4)||(monthnum==6)||(monthnum==9)||(monthnum==11)){
					   if (daynum>=31){return(false);}
			      }
                  else if (monthnum==2) {
                       if (daynum>=29){return(false);}
				  }
		   
		   } 
		   
      return(true);
  }

//只能提交一次，提交后屏蔽按钮
function submitonce(Frm){
    if (document.all||document.getElementById)
    {
      for (i=0;i<Frm.length;i++)
      {
        var tempobj=Frm.elements[i]
        if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") { tempobj.disabled=true; }
      }
   }
}

//取消提交后打开屏蔽按钮
function submitopen(Frm){
    if (document.all||document.getElementById)
    {
      for (i=0;i<Frm.length;i++)
      {
        var tempobj=Frm.elements[i]
        if(tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") { tempobj.disabled=false; }
      }
   }
}

//邮件地址验证 
function IsEmail(str){ 
  //邮件地址正则表达式 
   isEmail1=/^\w+([\.\-]\w+)*\@\w+([\.\-]\w+)*\.\w+$/; 
   //邮件地址正则表达式 
   isEmail2=/^.*@[^_]*$/; 
   //验证邮件地址，返回结果 
   return (isEmail1.test(str)&&isEmail2.test(str)); 
} 



function CheckChar(str) {
    var wordsArray = new Array(":", "：", "*", "●", "▲", "■", "@", "＠", "◎", "★", "※", "＃", "〓", "＼", "§", "☆", "○", "◇", "◆", "□", "△", "＆", "＾", "￣", "＿","♂","♀","Ю","┭","①","「","」","≮","§","￡","∑","『","』","⊙","∷","Θ","の","↓","↑","Ф","~","Ⅱ","∈","┣","┫","╋","┇","¤","▃","▌");
    var len = wordsArray.length;
    for (var i = 0; i < len; i++) {
        if (str.indexOf(wordsArray[i]) != -1) {
            return wordsArray[i];
        }
    }
    return "";
}


function ClearWordCode(oldString) {
	var newString = oldString;

	//清理word，excel里面复制过来的table html垃圾代码
	newString = newString.replace("x:str", "");
	newString = newString.replace("border=0", "border=0");

    // Remove Style attributes
    newString = newString.replace(/<(\w[^>]*) style="([^"]*)"/gi,  "<$1")   

    //Remove  all  SPAN  tags  
    newString = newString.replace(/<\/?SPAN[^>]*>/gi,  ""  );    
	
	//Remove Lang attributes  
    newString = newString.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;  

    //Remove Class attributes 
    newString = newString.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3"); 

	//Remove XML elements and declarations
	newString = newString.replace(/<\\?\?xml[^>]*>/gi, "") ;

	//Remove Tags with XML namespace declarations: <o:p></o:p>
	newString = newString.replace(/<\/?\w+:[^>]*>/gi, "") ;

	if(newString=="<P>&nbsp;</P>"){
		newString="";
	}else{
        newString = newString.replace(/<P>&nbsp;<\/P>/gi, "<BR>"); 
	}

	return newString;
}
