function indexOfArray (array,o)
{
	for(var i=0;i<array.length;i++)
	{
		if(array[i]==o)
			return i;
	}
	return -1;
}
	function ThkArray()
	{
		this.array=[];
		this.getLength=function(){return this.array.length};
	}

	ThkArray.prototype=new Array();

	ThkArray.prototype.indexOf=function(o)
	{
	 for(var i=0; i<this.length; i++)
	{
		if(this[i]==o)
		return i;
		}
		return-1;
	};
	ThkArray.prototype.lastIndexOf=function(o)
	{
		for(var i=this.length-1;i>=0;i--)
		{
		if(this[i]==o)
		return i;
		}
		return-1;
	};
	ThkArray.prototype.contains=function(o)
	{
		return this.indexOf(o)!= -1;
	};
	ThkArray.prototype.copy=function(o)
	{
		return this.concat();
	};
	ThkArray.prototype.insertAt=function(o,i)
	{
			this.splice(i,0,o);
	};
	ThkArray.prototype.add=function(o)
	{
			this.array[this.array.length]=o;//this.splice(this.base.length-1,0,o);
	};  
	ThkArray.prototype.clear=function()
	{
		this.splice(0,this.length);
	};  
	ThkArray.prototype.insertBefore=function(o,o2)
	{
		var i=this.indexOf(o2);
		if(i==-1)
			this.push(o);
		else 
			this.splice(i,0,o);
	};
	ThkArray.prototype.removeAt=function(i)
	{
		this.splice(i,1);
	};
	ThkArray.prototype.remove=function(o)
	{
		var i=this.indexOf(o);
		if(i!= -1)
			this.splice(i,1);
	};
	ThkArray.prototype.joinToStr=function (str1)
	{
		var result='';
		for(var i=0;i<this.length;i++)
		{
			if(this[i]==null || this[i]==str1)
				continue;
			result+=this[i]+str1;
		}		
		return result;  
	}
	String.prototype.fnIsAscII=function(addition )
	{
		var search = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
		search += addition;
		var len = this.length;

		for( var i = 0; i < len; i++ )
		{
			var ch = this.charAt(i);
			if( search.indexOf( ch ) == -1 )
			{
				return false;
			}
		}		
		return true;
	}
  // 检查是否为中文
	String.prototype.isChinese=function ()
	{
      var reg = /^[u4E00-u9FA5]+$/;
		  var sTemp=this.trim();
      if(!reg.test(sTemp)){
       return false;
      }
      return true;
	}
		String.prototype.splitToArray=function (str1)
		{
		  var result=this.split(str1);
		  for(var i=0;i<result.length;i++)
		  {
		    if(result[i]==null || result[i]=='' || result[i]==str1)
		      result.splice(i,1);
		  }		
		  return result;  
		}
	String.prototype.isIP=function(allWildcard)
	{
		//首先处理ip段
		var minusPos=this.indexOf('-');
		//IP段禁止使用通配符
		if(minusPos>-1)
			allWildcard=false;
		if(minusPos>-1&&minusPos<this.length-1)
		{
			var ips=this.split('-');
			if(ips.length==2)
			{
				if(ips[0].isIP(allWildcard)&&ips[1].isIP(allWildcard))
					return true;
				else
					return false;
			}
		}
		else if(minusPos>-1)
			return false;
		if(!allWildcard)
		{
			var re=/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/g; //匹配IP地址的正则表达式
			var parts=re.exec(this.trim());
			if(parts!=null)
			{
				if((parts[1].toInteger()>255)
					||(parts[2].toInteger()>255)
					||(parts[3].toInteger()>255)
					||(parts[4].toInteger()>255))
				{
					return false;
				}
				else
					return true;
			}
			else
				return false;
		}
		else
		{
			var newStrList=this.split('.');
			//如果ip地址小于4节，则最后一个字符必须是*
			if(newStrList.length<4&&this.substr(this.length-1,1)!='*')
				return false;
			var re=/\*|\?/g;
			newStrList= this.replace(re,'').split('.');
			for(var i=0;i<newStrList.length;i++)
			{
				if(newStrList[i].toInteger()>255)
					return false;
			}
			return true;
		}
	}
	// 去掉前导和末尾空格，和全角空格
	String.prototype.trim = function() 
	{
		var x=this;
		x=x.replace(/^[　\s]*(.*)/, "$1");
		x=x.replace(/(.*?)[　\s]*$/, "$1");
		return x;
	}
	// 去掉前导空格
	String.prototype.trimLeft = function() 
	{
		var x=this;
		x=x.replace(/^\s*(.*)/, "$1");
		return x;
	}
	// 去除末尾的空格
	String.prototype.trimRight = function() 
	{
		var x=this;
		x=x.replace(/(.*?)\s*$/, "$1");
		return x;
	}	
	String.prototype.trimRight=function(aChar)
		{
				for(var i=0;i<this.length;i++)
			{
					if(this.charAt(i)!=aChar)
					return this.substr(i);
			}
			return "";
		}
  String.prototype.trimString=function(strPattern)
  {
      var source=this.trim();
      if(source.length>=strPattern.length)
      {
          while(source.substr(source.length-strPattern.length,strPattern.length).toLowerCase()==strPattern.toLowerCase())
          source=source.substr(0,source.length-strPattern.length);
      }
      if(source.toLowerCase()==strPattern.toLowerCase())
          source="";
      return source;
  }
  //是否已strPattern结尾，不区分大小写
    String.prototype.endWith=function(strPattern)
  {
      var source=this;
      if(strPattern!=null&&source.length>=strPattern.length)
      {
          return source.substr(source.length-strPattern.length,strPattern.length).toLowerCase()==strPattern.toLowerCase()
      }
      return false;
  }
	String.prototype.supressZero=function()
	{
		var temp=this;
		if(temp=="")
			return "";
		var re=new RegExp('^([\\s\\+\\-]*)(0*)');
		re.test(this);
		temp=RegExp.$1+RegExp.rightContext;
		if(temp=="")
			return "0";
		return temp;
	}
	//验证是否为有效的EMail地址
	String.prototype.isEmail = function() 
	{
		if(this.trim()=='')
			return false;
		var x=this.replace(/;/,',').splitToArray(',');
		for(var i=0;i<x.length;i++)
		{
			var re =/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.?)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/ig;
			if( !re.test(x[i]))
				return false;
		}
		return true;
	}
	//验证是否为有效的EMail地址列表，地址之间采用分号作为分割符号	
	String.prototype.isEmailList = function() 
	{
		var emailList;
		emailList = this.split(";");
		for(var i=0;i<emailList.length;i++)
		{
			if(!emailList[i].isEmail())
			return false;
		}
		return true;
	}
	String.prototype.isTelNum = function() 
	{
		//(1)电话号码由数字、"("、")"和"-"构成
		//(2)电话号码为3到8位
		//(3)如果电话号码中包含有区号，那么区号为三位或四位
		//(4)区号用"("、")"或"-"和其他部分隔开
		//支持区号－主机号－分机号:028-83202572-33333,(028)83202572(33333),(028)83202572-33333,028-83202572(33333)
		var re =/^((\(0[0-9]{2,4}\)|0[0-9]{2,4}-)?[^0][0-9]{6,7}){1}(((?:-{1}\d{1,6})|(\({1}\d{1,6}\){1})))?$/;
		var temp=this.trim().replace(/\s/g,'');
		return re.test(temp);
	}
	String.prototype.isMobile = function() 
	{
		var re =/^([0]|\(0\))?1[3-5][0-9][0-9]{8}$/;
		var temp=this.trim().replace(/\s/g,'');
		return re.test(temp)||this.isTelNum();
	}
	String.prototype.isZip = function() 
	{
		var re =/^[1-9]\d{5}$/;
		var temp=this.trim().replace(/\s/g,'');
		return re.test(temp);
	}
	String.prototype.isIndentityCardCode = function() 
	{
		var re =/^[1-9]\d{5}$/;
		var temp=this.trim();
		return re.test(temp);
	}
	String.prototype.isWellFormID = function() 
	{
			var re=new RegExp("^[a-zA-Z_]{1}[a-zA-Z_0-9]{1,19}$");
			if(!re.test(this))
				return false;
			if(this.toLowerCase()=="anonymous")
				return false;
			return true;
	}
	String.prototype.isWellLoginID = function() 
	{
			var re=new RegExp("^[a-zA-Z_0-9]{1}[a-zA-Z_0-9]{0,19}$");
			if(!re.test(this))
				return false;
			if(this.toLowerCase()=="anonymous")
				return false;
			return true;
	}
	
 //检测一个给定的字符串是否是一个整数包括，负数，0，整数
	String.prototype.isInteger=function ()
	{
		//var regexp=new RegExp("(^[ ]*)([0-9]+)([ ]*$)");
		//整数模板(没有后导空格）：（^[ ]*)([0-9]+$)
		//浮点数模板(没有后导空格）：((^[ ]*)([0-9]+)([.]?)([0-9]*$))
		//有后导空格的浮点数：((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))
		//var regexp=new RegExp("((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var re=/^\s*[\-\+]?[0-9]+\s*$/;
		var sTemp=this.trim();
		if(sTemp==""||sTemp=="-"||sTemp=="+")
		return true;
		var returnValue=false;
		returnValue=re.test(sTemp);
		if(returnValue)
		{
			returnValue=!isNaN(parseInt(sTemp));
		}
		return returnValue;				
	}
	String.prototype.isPositiveInteger=function()
	{
		//var regexp=new RegExp("(^[ ]*)([0-9]+)([ ]*$)");
		//整数模板(没有后导空格）：（^[ ]*)([0-9]+$)
		//浮点数模板(没有后导空格）：((^[ ]*)([0-9]+)([.]?)([0-9]*$))
		//有后导空格的浮点数：((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))
		//var regexp=new RegExp("((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var returnValue=false;
		var iTemp;
		var re=/^\s*\+?[0-9]+\s*$/;
		var sTemp=this.trim();
		if(sTemp==""||sTemp=="+")
		return true;
		returnValue=re.test(sTemp);
		if(returnValue)
		{
			iTemp=parseInt(sTemp);
			if(!isNaN(iTemp))
				returnValue=(iTemp>=0);
			else
				returnValue=false;
		}
		window.status=returnValue;
		return returnValue;	
	}
	String.prototype.isNegativeInteger=function()
	{
		//var regexp=new RegExp("(^[ ]*)([0-9]+)([ ]*$)");
		//整数模板(没有后导空格）：（^[ ]*)([0-9]+$)
		//浮点数模板(没有后导空格）：((^[ ]*)([0-9]+)([.]?)([0-9]*$))
		//有后导空格的浮点数：((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))
		//var regexp=new RegExp("((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var regexp=/^\s*[\-]{1}[0-9]+\s*$/;
		var sTemp=this.trim();
		if(sTemp==""||sTemp=="-")
		return true;
		var returnValue=false;
		var iTemp;
		returnValue=regexp.test(sTemp);
		if(returnValue)
		{
			iTemp=parseInt(sTemp);
			if(!isNaN(iTemp))
				returnValue=(iTemp<=0);
			else
				returnValue=false;
		}
		return returnValue;	
	}
	String.prototype.isFloat=function()
	{
		//var regexp=new RegExp("(^[ ]*)([0-9]+)([ ]*$)");
		//整数模板(没有后导空格）：（^[ ]*)([0-9]+$)
		//浮点数模板(没有后导空格）：((^[ ]*)([0-9]+)([.]?)([0-9]*$))
		//有后导空格的浮点数：((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))
		//var regexp=new RegExp("((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var regexp=new RegExp("((^[ ]*)[\-\+]?([0-9]*)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var sTemp=this.trim();
		if(sTemp==""||sTemp=="+"||sTemp=="-")
		return true;
		var returnValue=false;
		returnValue=regexp.test(sTemp);
		if(returnValue)
		{
			returnValue=!isNaN(parseFloat(sTemp));
		}
		return returnValue;	
		
	}
	String.prototype.isPositiveFloat=function()
	{
		//var regexp=new RegExp("(^[ ]*)([0-9]+)([ ]*$)");
		//整数模板(没有后导空格）：（^[ ]*)([0-9]+$)
		//浮点数模板(没有后导空格）：((^[ ]*)([0-9]+)([.]?)([0-9]*$))
		//有后导空格的浮点数：((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))
		//var regexp=new RegExp("((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var regexp=new RegExp("((^[ ]*)[\+]?([0-9]*)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var sTemp=this.trim();
		if(sTemp==""||sTemp=="+")
		return true;
		var returnValue=false;
		var iTemp;
		returnValue=regexp.test(sTemp);
		if(returnValue)
		{
			iTemp=parseFloat(sTemp);
			if(!isNaN(iTemp))
				returnValue=(iTemp>=0);
			else
				returnValue=false;
		}
		return returnValue;	
	}
	String.prototype.isNegativeFloat=function()
	{
		//var regexp=new RegExp("(^[ ]*)([0-9]+)([ ]*$)");
		//整数模板(没有后导空格）：（^[ ]*)([0-9]+$)
		//浮点数模板(没有后导空格）：((^[ ]*)([0-9]+)([.]?)([0-9]*$))
		//有后导空格的浮点数：((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))
		//var regexp=new RegExp("((^[ ]*)[\-]?([0-9]+)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var regexp=new RegExp("((^[ ]*)[\-]{1,1}([0-9]*)([.]?)(([0-9]*$)|([0-9]*[ ]*$)))");
		var sTemp=this.trim();
		if(sTemp==""||sTemp=="-")
		return true;
		var returnValue=false;
		var iTemp;
		returnValue=regexp.test(sTemp);
		if(returnValue)
		{
			iTemp=parseFloat(sTemp);
			if(!isNaN(iTemp))
				returnValue=(iTemp<=0);
			else
				returnValue=false;
		}
		return returnValue;					
		}
		 String.prototype.toInteger=function()
		{				
			var sTemp=this.trim();
			if(sTemp==""||sTemp=="-"||sTemp=="+")
				return 0;			

			if(sTemp.isInteger())
				return parseInt(sTemp.supressZero());
			window.status="“"+this+"”不是能够转换为整数类型的字符串！";
			return 0;				
		}	
		String.prototype.toPositiveInteger=function()
		{
			var sTemp=this.trim();
			if(sTemp==""||sTemp=="+")
				return 0;			
			if(sTemp.isPositiveInteger())
				return parseInt(sTemp.supressZero());
			window.status="“"+this+"”不是能够转换为正整数类型的字符串！";
			return 0;	
		}
		String.prototype.toNegativeInteger=function()
		{				
			var sTemp=this.trim();
			if(sTemp==""||sTemp=="-")
				return 0;			
			if(sTemp.isNegativeInteger())
				return parseInt(sTemp.supressZero());
			window.status="“"+this+"”不是能够转换为负整数类型的字符串！";
			return 0;				
		}	
												
		String.prototype.toFloat=function()
		{	
			var sTemp=this.trim();
			if(sTemp==""||sTemp=="-"||sTemp=="+")
				return 0;			
			if(sTemp.isFloat())
				return parseFloat(sTemp.supressZero());
			window.status="“"+this+"”不是能够转换为浮点数类型的字符串！";
			return 0;	
		}	
		String.prototype.toPositiveFloat=function()
		{				
			var sTemp=this.trim();
			if(sTemp==""||sTemp=="+")
				return 0;			
			if(sTemp.isPositiveFloat())
				return parseFloat(sTemp.supressZero());
			window.status="“"+this+"”不是能够转换为正浮点数类型的字符串！";
			return 0;						
		}
		String.prototype.toNegativeFloat=function()
		{				
			var sTemp=this.trim();
			if(sTemp==""||sTemp=="-"||sTemp=="+")
				return 0;			
			if(sTemp.isNegativeFloat())
				return parseFloat(sTemp.supressZero());
			window.status="“"+this+"”不是能够转换为负浮点数类型的字符串！";
			return 0;			
		}
	String.prototype.isBool=function()
	{
		var re=/^true|false|1|0/i;
		return re.test(this.trim());
	}

	String.prototype.parseBool=function()
	{
		var re=/^true|[1-9]/i;
		return re.test(this.trim());
	}
	//设定浮点数的精确位数	
	Number.prototype.round=function(iDigit)  
	{
	  var iTempNumber=this;
	  var sNumber=this.toString();
		if(iDigit>=0)
		{
		  iTempNumber=Math.round(this*Math.pow(10,iDigit));
		  sNumber = iTempNumber.toString();
		  sNumber = sNumber.substr(0,sNumber.length-iDigit)+"."+
					sNumber.substr(sNumber.length-iDigit,iDigit);
		}
		return parseFloat(sNumber);
	}	
	//**********************************************************************************************************
	//功能：判断intYear年intMonth月的天数
	//返回值：intYear年intMonth月的天数
	function fnComputerDay(intYear,intMonth)
	{
		var dtmDate = new Date(intYear,intMonth,-1);
		var intDay = dtmDate.getDate() + 1;    
		return intDay;    
	}
	var MonthNames_CN=['〇','一','二','三','四','五','六','七','八','九','十'];
	var MonthNames_BigCN=['零','壹','贰','叁','肆','伍','陆','柒','捌','玖','拾'];
	var MonthNames_NumCN=['０','１','２','３','４','５','６','７','８','９'];
	
	//将一个10位数字装换位中文数字
	function numConvertToCN(strNum,mode)
	{
		var result="";
		strNum=''+strNum;
		var num=strNum.toInteger();
		switch(mode)
		{
			case 1:
				for(var i=0;i<strNum.length;i++)
					result+=MonthNames_NumCN[strNum.charAt(i).toInteger()];
					return result;
			case 2:
				if(num<10||num>100)
				{
					for(var i=0;i<strNum.length;i++)
					{
							result+=MonthNames_CN[strNum.charAt(i).toInteger()];
					}
				}
				else
				{
					var ch=strNum.charAt(0);
					result=MonthNames_CN[parseInt(ch)];
					result+=MonthNames_CN[10];
					if(num%10!=0)
					result+=MonthNames_CN[strNum.charAt(1).toInteger()]
				}
				return result;
			case 3:
				if(num<10||num>100)
				{
					for(var i=0;i<strNum.length;i++)
					{
							result+=MonthNames_BigCN[strNum.charAt(i).toInteger()];
					}
				}
				else
				{
					var ch=strNum.charAt(0);
					result=MonthNames_BigCN[parseInt(ch)];
					result+=MonthNames_BigCN[10];
					if(num%10!=0)
					result+=MonthNames_BigCN[strNum.charAt(1).toInteger()]
				}
				return result;
			default:
				return strNum;
		}
	}
/*
*mode数字模式，0：罗马数字，1：全角数字，2：为中文小写数字，3：中文大写数字
*/
Date.prototype.toString=function(format,mode)
{
	if(arguments.length==0||format.trim()=="")
		return this.toLocaleString();
	if(arguments.length==1)
	  var mode=0;
	var year=this.getFullYear().toString();
	//format=format.toLowerCase();
	format=format.replace(/yyyy/ig,numConvertToCN(year,mode));
	format=format.replace(/yy/ig,numConvertToCN(year.substr(2,2),mode));
	format=format.replace(/y/ig,numConvertToCN(year.substr(2,2).toInteger().toString(),mode));

	var minutes=this.getMinutes().toString();
	if(minutes.length<2)
		minutes='0'+minutes;
	format=format.replace(/mm/g,numConvertToCN(minutes,mode));
	format=format.replace(/m/g,numConvertToCN(this.getMinutes().toString(),mode));

	var month=(this.getMonth()+1).toString();
	if(month.length<2)
		month='0'+month;
	format=format.replace(/MM/g,numConvertToCN(month,mode));
	format=format.replace(/M/g,numConvertToCN((this.getMonth()+1).toString(),mode));

	var day=this.getDate().toString();
	if(day.length<2)
		day='0'+day;
	format=format.replace(/dd/ig,numConvertToCN(day,mode));
	format=format.replace(/d/ig,numConvertToCN(this.getDate().toString(),mode));
	

	var hours=this.getHours().toString();
	if(hours.length<2)
		hours='0'+hours;
	format=format.replace(/hh/ig,numConvertToCN(hours,mode));
	format=format.replace(/h/ig,numConvertToCN(this.getHours().toString(),mode));

	var seconds=this.getSeconds().toString();
	if(seconds.length<2)
		seconds='0'+seconds;
	format=format.replace(/ss/ig,numConvertToCN(seconds,mode));
	format=format.replace(/s/ig,numConvertToCN(this.getSeconds().toString(),mode));
	return format;
}
String.prototype.isDateTime=function()
{
	return this.toDateTime()!=null;
}
function isLeap(year)
{
  return (year%400==0||year%4==0&&year%100!=0);
}
String.prototype.toDateTime=function()
{   
  var result=null;
	if(this.trim()=="")
		return result;
	result= toDate(this);
	if(result.result)
	{
		return result.theDateTime;
	}
	else
		return null;
}

//对数字中的十进行处理
function arrangeTenDigital(strSource,strFlag)
{
	var tenPos=strSource.indexOf(strFlag);
	while(tenPos>-1&&tenPos<strSource.length-1)
	{
		if(digitalPattern.indexOf(strSource.substr(tenPos+1,1))==-1)//后面没有数字，这个十应该替换为0需要
			strSource=strSource.substr(0,tenPos)+'0'+strSource.substr(tenPos+1);
		else
			strSource=strSource.substr(0,tenPos)+strSource.substr(tenPos+1);//后面有数字，这个十应该去掉

		if(tenPos==0)
			strSource="1"+strSource;
		else	 if(digitalPattern.indexOf(strSource.substr(tenPos-1,1))==-1)////前面没有数字，这个十应该替换为1需要
			strSource=strSource.substr(0,tenPos-1)+'1'+strSource.substr(tenPos);
 	 tenPos=strSource.indexOf(strFlag,tenPos+1);
	}
	return strSource;
}
var digitalPattern="0123456789０１２３４５６７８９〇一二三四五六七八九零壹贰叁肆伍陆柒捌玖";
	function toDate(strSource)
	{
		var year=new Date().getFullYear();
		var month=new Date().getMonth()+1;
		var day=new Date().getDate();
		var strMached=null;
		var theDate=null;
		strSource=strSource.trim();
		strSource=arrangeTenDigital(strSource,MonthNames_CN[10]);
		strSource=arrangeTenDigital(strSource,MonthNames_BigCN[10]);

		var re=new RegExp('^(['+digitalPattern+']{4})(?:[-./年－．／]){1}','i');
		//re.exec(strSource);
		if(!re.test(strSource))
		{
			//测试只有两位年份
			re=new RegExp('^(['+digitalPattern+']{1,2})(?:[-./年－．／]){1}','i');
			re.exec(strSource);
			if(re.test(strSource))
			{
				//return {result:false,theDateTime:'日期格式的年份不正确'};
			strMached='20'+RegExp.$1;
			strSource=RegExp.rightContext;
			}
		}
		else
		{
		strMached=RegExp.$1;
		strSource=RegExp.rightContext;
		}
		if(strMached!=null)
		{
			year=(''+digitalPattern.indexOf(strMached.substr(0,1))%10+
			digitalPattern.indexOf(strMached.substr(1,1))%10+
			digitalPattern.indexOf(strMached.substr(2,1))%10+
			digitalPattern.indexOf(strMached.substr(3,1))%10).toInteger();
			
				if(strSource.trim()=="")
				{
					theDate=new Date(year,0,0,0,0,0,0);
					return {result:true,theDateTime:theDate};
				}
		}

		re=new RegExp('^(['+digitalPattern+']{1,2})(?:[-./月－．／]){1}','i');
		//re.exec(strSource);
		if(re.test(strSource))
		{
				//return {result:false,theDateTime:'日期格式的月份不正确'};
			strMached=RegExp.$1;
			strSource=RegExp.rightContext;
			month=''+digitalPattern.indexOf(strMached.substr(0,1))%10;
			if(strMached.length>1)
			month+=digitalPattern.indexOf(strMached.substr(1,1))%10;
			month=month.toInteger();
			if(month>12)
					return {result:false,theDateTime:'日期格式的月份不正确'};
			if(strSource.trim()=="")
			{
				theDate=new Date(year,month-1,0,0,0,0,0);
				return {result:true,theDateTime:theDate};
			}
		}
		//三种情况：日期后面没有字符，带字符“日”，后面是时间（与日期之间必须有一个空格）
		re=new RegExp('^(['+digitalPattern+']{1,2})(?:(?:[日\\s]*$)|(?:[日\\s]+([\\S]+))$)','i');
		//re.exec(strSource);
		if(re.test(strSource))
		{
				//return {result:false,theDateTime:'日期格式的日期不正确'};
			strMached=RegExp.$1;
			strSource=RegExp.$2+RegExp.rightContext;
			day=''+digitalPattern.indexOf(strMached.substr(0,1))%10;
			if(strMached.length>1)
				day+=digitalPattern.indexOf(strMached.substr(1,1))%10;
			day=day.toInteger();
			
			if(day>31
					||(indexOfArray(['4','6','9','11'],month.toString())>-1&&day==31)
					||(month==2&&(isLeap(year)&&day>29||!isLeap(year)&&day>28)))
				return {result:false,theDateTime:'日期格式的日期不正确'};
		}

		theDate=new Date(year,month-1,day,0,0,0,0);
		if(strSource.trim()=="")
		{
			return {result:true,theDateTime:theDate};
		}
		if(strSource.trim()!="")
		{
			var theTime=toTime(strSource);
			if(!theTime.result)
				return theTime;
				theDate.setHours(theTime.theDateTime.getHours());
				theDate.setMinutes(theTime.theDateTime.getMinutes());
				theDate.setSeconds(theTime.theDateTime.getSeconds());
		}
		return {result:true,theDateTime:theDate};
	}
	function toTime(strSource)
	{
		var hour;
		var minute;
		var seconds;
		var strMached;
		var theTime=null;
		//var digitalPattern="0123456789０１２３４５６７８９〇一二三四五六七八九零壹贰叁肆伍陆柒捌玖";
		var re=new RegExp('^(['+digitalPattern+']{1,2})(?:[:：点时]){0,1}','i');
		strSource=strSource.trim();
		//re.exec(strSource);
		if(!re.test(strSource))
			return {result:false,theDateTime:'日期格式的小时不正确'};
		strMached=RegExp.$1;
		strSource=RegExp.rightContext;
		hour=''+digitalPattern.indexOf(strMached.substr(0,1))%10;
		if(strMached.length>1)
			hour+=digitalPattern.indexOf(strMached.substr(1,1))%10;
		hour=hour.toInteger();
		if(hour>23)
			return {result:false,theDateTime:'日期格式的小时不正确'};
		if(strSource.trim()=="")
		{
			theTime=new Date(0,0,0,hour,0,0,0);
			return {result:true,theDateTime:theTime};
		}
		 re=new RegExp('^(['+digitalPattern+']{1,2})(?:[:：分]){0,1}','i');
		//re.exec(strSource);
		if(!re.test(strSource))
			return {result:false,theDateTime:'日期格式的分钟不正确'};
		strMached=RegExp.$1;
		strSource=RegExp.rightContext;
		minute=''+digitalPattern.indexOf(strMached.substr(0,1))%10;
		if(strMached.length>1)
			minute+=digitalPattern.indexOf(strMached.substr(1,1))%10;
		minute=minute.toInteger();
		if(minute>59)
			return {result:false,theDateTime:'日期格式的分钟不正确'};
	//re=new RegExp('^([0123456789０１２３４５６７８９〇一二三四五六七八九零壹贰叁肆伍陆柒捌玖]{1,2})$','i');
		if(strSource.trim()=="")
		{
			theTime=new Date(0,0,0,hour,minute,0,0);
			return {result:true,theDateTime:theTime};
		}
		 re=new RegExp('^(['+digitalPattern+']{1,2})(?:[:：秒]){0,1}','i');
		//re.exec(strSource);
		if(!re.test(strSource))
			return {result:false,theDateTime:'日期格式的秒不正确'};
		strMached=RegExp.$1;
		strSource=RegExp.rightContext;
		seconds=''+digitalPattern.indexOf(strMached.substr(0,1))%10;
		if(strMached.length>1)
			seconds+=digitalPattern.indexOf(strMached.substr(1,1))%10;
		seconds=seconds.toInteger();
		if(minute>59)
			return {result:false,theDateTime:'日期格式的秒不正确'};
		theTime=new Date(0,0,0,hour,minute,seconds,0);
		return {result:true,theDateTime:theTime};
}



	function thkAttachEvent (obj, evType, fn, useCapture)
	{
		if (obj.addEventListener)
		{
			obj.addEventListener(evType, fn, useCapture ? true : useCapture);
			return true;
		}
		else if (obj.attachEvent)
		{
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		}
		else 
		{
			return false;
		}
	}
		
	function  thkDetachEvent  (obj, evType, fn, useCapture)
	{
		if (obj.removeEventListener)
		{
			obj.removeEventListener(evType, fn, useCapture);
			return true;
		}
		else if (obj.detachEvent)
		{
			var r = obj.detachEvent("on"+evType, fn);
			return r;
		}
		else
		{
			alert("Handler could not be removed");
		}
	}

	function WebCookie()
	{
		if (document.cookie.length) 
		{
			this.cookies = ' ' + document.cookie;
		}
	}
	WebCookie.prototype.setCookie = function (key, value) 
	{
		document.cookie = key + "=" + escape(value);
	}
	WebCookie.prototype.getCookie = function (key) 
	{
		if (this.cookies) 
		{
			var start = this.cookies.indexOf(' ' + key + '=');
			if (start == -1) { return null; }
			var end = this.cookies.indexOf(";", start);
			if (end == -1) { end = this.cookies.length; }
			end -= start;
			var cookie = this.cookies.substr(start,end);
			return unescape(cookie.substr(cookie.indexOf('=') + 1, cookie.length - cookie.indexOf('=') + 1));
		}
		else
		{
			return null; 
		}
	}
	/*****************
	请求一个url定义的服务，如果失败，可以有showError控制是否弹出警告
	服务需要返回：<info><result>true或false<result><error>如果请求有错，错误内容</error></info>
	返回值:true:请求的操作成功，false，失败
	*/
	function RequestWithAJAX(requestedUrl,showError)
	{
			var httpHandlerDoc=document.createElement("xml");
			document.body.insertAdjacentElement("afterBegin",httpHandlerDoc);
			httpHandlerDoc.setProperty("SelectionLanguage", "XPath");
			httpHandlerDoc.async = false;
			try
			{
				httpHandlerDoc.load(requestedUrl);
				var result=httpHandlerDoc.selectSingleNode("//info/result").text.parseBool();
				if(result==false&&showError)
					alert('出错：\r\n'+httpHandlerDoc.selectSingleNode("//info/error").text);
				httpHandlerDoc.removeNode(true);
				return result;
			}
			catch(e)
			{
				alert('请求服务出错，错误原因是：\r\n'+e.message);
				return false;
			}
	}
	////////////
/// 根据文件名获取一个文件的MIME类型
///////////
function getContentType(fileName)
{
	if(ThkCOS&&ThkCOS.Components&&ThkCOS.Components.ThkCOSPage&&ThkCOS.Components.ThkCOSPage.GetContentType)
	{
		var response=ThkCOS.Components.ThkCOSPage.GetContentType(fileName);
		if(response.error!=null)
		return '';
		else
		return response.value;
	}
	else
		return '';
}
//将字符串进行HTML编码
function HtmlEncode(unencodedString)
{
   return HTMLEncode(unencodedString);
   //return ThkCOS.Components.ThkCOSPage.HtmlEncode(unencodedString).value;
}
//将字符串进行HTML编码
function HtmlDecode(encodedString)
{
   return HTMLDecode(encodedString);
//   return ThkCOS.Components.ThkCOSPage.HtmlDecode(encodedString).value;
}

//获取一个新的GUID
function GetGuid()
{
   return ThkCOS.Components.ThkCOSPage.GetGuid().value;
}
//获取服务器的当前时间
function GetServerTime(strFormat)
{
   return ThkCOS.Components.ThkCOSPage.GetServerTime(strFormat).value;
}
function DeleteAttachment(strAttachmentID,noPrompt)
{
	if(ThkCOS&&ThkCOS.Components&&ThkCOS.Components.ThkCOSPage&&ThkCOS.Components.ThkCOSPage.DeleteAttachment)
	{
		var doDel=noPrompt;
		if(!doDel)
			doDel=confirm("确实要删除吗?")
		if(doDel)
		{
			try
			{
				var response= ThkCOS.Components.ThkCOSPage.DeleteAttachment(strAttachmentID);
				if(response.error!=null)
				{
					alert('删除附件失败\r\n'+response.error.Message);
					return false;
				}
				else if(!response.value)
				{
					alert('删除附件失败，可能是服务器上不存在该附件');
					return true;
				}
				else
				return true;  
			}
			catch(e)
			{
				alert('删除附件失败\r\n'+e.message);
				return false;
			}
		}
  }
  return false;
}


/*	function GetServerTime()
	{
	  return new Date();
	}*/
/*TITLE: Client-Side Request Object for javascript by Andrew Urquhart (UK)
HOME: http://andrewu.co.uk/tools/request/
COPYRIGHT: You are free to use this script for any use you wish, the only
thing I ask you do is keep this copyright message intact with the script.
Please don't pass it off as your own work, but feel free to enhance it and send
me the updated version. Please don't redistribute - it makes it harder to distribute
new versions of the script. This script is provided as is, with no warranty of any
kind. Use it at your own risk. Copyright Andrew R Urquhart
VERSION: #1.3 2005-05-11 17:52 UTC*/
function RObj(ea) {
	var LS	= "";
	var QS	= new Object();
	var un	= "undefined";
	var x	= null; // On platforms that understand the 'undefined' keyword replace 'null' with 'undefined' for maximum ASP-like behaviour.
	var f	= "function";
	var n	= "number";
	var r	= "string";
	var e1	= "ERROR: Index out of range in\r\nRequest.QueryString";
	var e2	= "ERROR: Wrong number of arguments or invalid property assignment\r\nRequest.QueryString";
	var e3	= "ERROR: Object doesn't support this property or method\r\nRequest.QueryString.Key";

	function Err(arg) {
		if (ea) {
			alert("Request Object:\r\n" + arg);
		}
	}
	function URID(t) {
		var d = "";
		if (t) {
			for (var i = 0; i < t.length; ++i) {
				var c = t.charAt(i);
				d += (c  ==  "+" ? " " : c);
			}
		}
		return unescape(d);
	}
	function OL(o) {
		var l = 0;
		for (var i in o) {
			if (typeof o[i] != f) {
				l++;
			}
		}
		return l;
	}
	function AK(key) {
		var auk = true;
		for (var u in QS) {
			if (typeof QS[u] != f && u.toString().toLowerCase() == key.toLowerCase()) {
				auk = false;
				return u;
			}
		}
		if (auk) {
			QS[key] = new Object();
			QS[key].toString = function() {
				return TS(QS[key]);
			}
			QS[key].Count = function() {
				return OL(QS[key]);
			}
			QS[key].Count.toString = function() {
				return OL(QS[key]).toString();
			}
			QS[key].Item = function(e) {
				if (typeof e == un) {
					return QS[key];
				}
				else {
					if (typeof e == n) {
						var a = QS[key][Math.ceil(e)];
						if (typeof a == un) {
							Err(e1 + "(\"" + key + "\").Item(" + e + ")");
						}
						return a;
					}
					else {
						Err("ERROR: Expecting numeric input in\r\nRequest.QueryString(\"" + key + "\").Item(\"" + e + "\")");
					}
				}
			}
			QS[key].Item.toString = function(e) {
				if (typeof e == un) {
					return QS[key].toString();
				}
				else {
					var a = QS[key][e];
					if (typeof a == un) {
						Err(e1 + "(\"" + key + "\").Item(" + e + ")");
					}
					return a.toString();
				}
			}
			QS[key].Key = function(e) {
				var t = typeof e;
				if (t == r) {
					var a = QS[key][e];
					return (typeof a != un && a && a.toString() ? e : "");
				}
				else {
					Err(e3 + "(" + (e ? e : "") + ")");
				}
			}
			QS[key].Key.toString = function() {
				return x;
			}
		}
		return key;
	}
	function AVTK(key, val) {
		if (key != "") {
			var key = AK(key);
			var l = OL(QS[key]);
			QS[key][l + 1] = val;
		}
	}
	function TS(o) {
		var s = "";
		for (var i in o) {
			var ty = typeof o[i];
			if (ty == "object") {
				s += TS(o[i]);
			}
			else if (ty != f) {
				s += o[i] + ", ";
			}
		}
		var l = s.length;
		if (l > 1) {
			return (s.substring(0, l-2));
		}
		return (s == "" ? x : s);
	}
	function KM(k, o) {
		var k = k.toLowerCase();
		for (var u in o) {
			if (typeof o[u] != f && u.toString().toLowerCase() == k) {
				return u;
			}
		}
	}
	if (window.location && window.location.search) {
		LS = window.location.search;
		var l = LS.length;
		if (l > 0) {
			LS = LS.substring(1,l);
			var preAmpAt = 0;
			var ampAt = -1;
			var eqAt = -1;
			var k = 0;
			var skip = false;
			for (var i = 0; i < l; ++i) {
				var c = LS.charAt(i);
				if (LS.charAt(preAmpAt) == "=" || (preAmpAt == 0 && i == 0 && c == "=")) {
					skip=true;
				}
				if (c == "=" && eqAt == -1 && !skip) {
					eqAt=i;
				}
				if (c == "&" && ampAt == -1) {
					if (eqAt!=-1) {
						ampAt=i;
					}
					if (skip) {
						preAmpAt = i + 1;
					}
					skip = false;
				}
				if (ampAt>eqAt) {
					AVTK(URID(LS.substring(preAmpAt, eqAt)), URID(LS.substring(eqAt + 1, ampAt)));
					preAmpAt = ampAt + 1;
					eqAt = ampAt = -1;
					++k;
				}
			}
			if (LS.charAt(preAmpAt) != "=" && (preAmpAt != 0 || i != 0 || c != "=")) {
				if (preAmpAt != l) {
					if (eqAt != -1) {
						AVTK(URID(LS.substring(preAmpAt,eqAt)), URID(LS.substring(eqAt + 1,l)));
					}
					else if (preAmpAt != l - 1) {
						AVTK(URID(LS.substring(preAmpAt, l)), "");
					}
				}
				if (l == 1) {
					AVTK(LS.substring(0,1),"");
				}
			}
		}
	}
	var TC = OL(QS);
	if (!TC) {
		TC=0;
	}
	QS.toString = function() {
		return LS.toString();
	}
	QS.Count = function() {
		return (TC ? TC : 0);
	}
	QS.Count.toString = function() {
		return (TC ? TC.toString() : "0");
	}
	QS.Item = function(e) {
		if (typeof e == un) {
			return LS;
		}
		else {
			if (typeof e == n) {
				var e = Math.ceil(e);
				var c = 0;
				for (var i in QS) {
					if (typeof QS[i] != f && ++c == e) {
						return QS[i];
					}
				}
				Err(e1 + "().Item(" + e + ")");
			}
			else {
				return QS[KM(e, QS)];
			}
		}
		return x;
	}
	QS.Item.toString = function() {
		return LS.toString();
	}
	QS.Key = function(e) {
		var t = typeof e;
		if (t == n) {
			var e = Math.ceil(e);
			var c = 0;
			for (var i in QS) {
				if (typeof QS[i] != f && ++c == e) {
					return i;
				}
			}
		}
		else if (t == r) {
			var e = KM(e, QS);
			var a = QS[e];
			return (typeof a != un && a && a.toString() ? e : "");
		}
		else {
			Err(e2 + "().Key(" + (e ? e : "") + ")");
		}
		Err(e1 + "().Item(" + e + ")");
	}
	QS.Key.toString = function() {
		Err(e2 + "().Key");
	}
	this.QueryString = function(k) {
		if (typeof k == un) {
			return QS;
		}
		else {
			var k = KM(k, QS);
			if (typeof QS[k] == un) {
				t = new Object();
				t.Count = function() {
					return 0;
				}
				t.Count.toString = function() {
					return "0";
				}
				t.toString = function() {
					return x;
				}
				t.Item = function(e) {
					return x;
				}
				t.Item.toString = function() {
					return x;
				}
				t.Key = function(e) {
					Err(e3 + "(" + (e ? e : "") + ")");
				}
				t.Key.toString = function() {
					return x;
				}
				return t;
			}
			if (typeof k == n) {
				return QS.Item(k);
			}
			else {
				return QS[k];
			}
		}
	}
	this.QueryString.toString = function() {
		return LS.toString();
	}
	this.QueryString.Count = function() {
		return (TC ? TC : 0);
	}
	this.QueryString.Count.toString = function() {
		return (TC ? TC.toString() : "0");
	}
	this.QueryString.Item = function(e) {
		if (typeof e == un) {
			return LS.toString();
		}
		else {
			if (typeof e == n) {
				var e = Math.ceil(e);
				var c = 0;
				for (var i in QS) {
					if (typeof QS[i] != f && ++c == e) {
						return QS[i];
					}
				}
				Err(e1 + ".Item(" + e + ")");
			}
			else {
				return QS[KM(e, QS)];
			}
		}
		if (typeof e == n) {
			Err(e1 + ".Item(" + e + ")");
		}
		return x;
	}
	this.QueryString.Item.toString = function() {
		return LS.toString();
	}
	this.QueryString.Key = function(e) {
		var t = typeof e;
		if (t == n) {
			var e = Math.ceil(e);
			var c = 0;
			for (var i in QS) {
				if (typeof QS[i] == "object" && (++c == e)) {
					return i;
				}
			}
		}
		else if (t == r) {
			var e = KM(e, QS);
			var a = QS[e];
			return (typeof a != un && a && a.toString() ? e : "");
		}
		else {
			Err(e2 + ".Key(" + (e ? e : "") + ")");
		}
		Err(e1 + ".Item(" + e + ")");
	}
	this.QueryString.Key.toString = function() {
		Err(e2 + ".Key");
	}
	this.Version = 1.3;
	this.Author = "Andrew Urquhart (www.andrewu.co.uk)";
}
var Request = new RObj(false);


function HTMLDecode(strSource)
{
    if(strSource==null)
    return "";
  strSource=strSource.replace(/&quot;/ig,'"');
  strSource=strSource.replace(/&lt;/ig,'<');
  strSource=strSource.replace(/&gt;/ig,'>');
  strSource=strSource.replace(/&amp;/ig,'&');
  return strSource;
}
function HTMLEncode(strSource)
{
    if(strSource==null)
    return "";
  strSource=strSource.replace(/&/ig,'&amp;');
  strSource=strSource.replace(/"/ig,'&quot;');
  strSource=strSource.replace(/</ig,'&lt;');
  strSource=strSource.replace(/>/ig,'&gt;');
  return strSource;
}

//创建一个节点
function XML_createNode(nodeType,parentNode,nodeName,text,addCDATA)
{
	var node=parentNode.ownerDocument.createNode(nodeType,nodeName,"");
  if(nodeType==1)
  {
	  if(!addCDATA||typeof text=='undefined' ||text==null||text.toString().trim()=='')
	  {
	      if (typeof text == 'undefined' || text == null || text.toString().trim() == '')
	          node.text = '';
          else
	        node.text=text;
	    parentNode.appendChild(node);
	    return node;
	  }
	  else
	  {
	    parentNode.appendChild(node);
	    var CDATASection = parentNode.ownerDocument.createCDATASection(text);
      node.appendChild(CDATASection);
	    return node;
	  
	  }				
  }
  else
  {
	  parentNode.setAttribute(nodeName,text);//node.value=text;
  }
}
//function XML_createNode(nodeType,parentNode,nodeName,text)
//{
//		var node=parentNode.ownerDocument.createNode(nodeType,nodeName,"");
//		if(nodeType==1)
//		{
//			node.text=text;
//			parentNode.appendChild(node);
//			return node;
//		}
//		else
//		{
//			parentNode.setAttribute(nodeName,text);//node.value=text;
//		}
//}


function parseXML(strXMLDoc)
{
  var xmlDoc=document.createElement("xml");
  xmlDoc.loadXML(strXMLDoc);
  if (xmlDoc.parseError.errorCode != 0) {
      var myErr = xmlDoc.parseError;
      alert("解析XML文档错误：\r\n " + myErr.reason);
      return null;
  }
  return xmlDoc;
}	
//联系人对象
function Wab(wabID,name,email,mobile,groupName)
{
  this.WABID = wabID;
  this.Name = name;
  this.EMail = email;
  this.Mobile = mobile;
  this.GroupName = groupName;
}
//hash类
function Hash()
{
	this.length = 0;
	this.items = new Array();
	for (var i = 0; i < arguments.length; i += 2) {
		if (typeof(arguments[i + 1]) != 'undefined') {
			this.items[arguments[i]] = arguments[i + 1];
			this.length++;
		}
	}
   
	this.removeItem = function(in_key)
	{
		var tmp_previous;
		if (typeof(this.items[in_key]) != 'undefined') {
			this.length--;
			var tmp_previous = this.items[in_key];
			delete this.items[in_key];
		}
	   
		return tmp_previous;
	}

	this.getItem = function(in_key) {
		return this.items[in_key];
	}

	this.setItem = function(in_key, in_value)
	{
		var tmp_previous;
		if (typeof(in_value) != 'undefined') {
			if (typeof(this.items[in_key]) == 'undefined') {
				this.length++;
			}
			else {
				tmp_previous = this.items[in_key];
			}

			this.items[in_key] = in_value;
		}
	   
		return tmp_previous;
	}

	this.hasItem = function(in_key)
	{
		return typeof(this.items[in_key]) != 'undefined';
	}
}
//网页编码
_entitiesList =[
"\"-quot", "&-amp", "<-lt", ">-gt", "\u00a0-nbsp", "\u00a1-iexcl", "\u00a2-cent", "\u00a3-pound", "\u00a4-curren", "\u00a5-yen", "\u00a6-brvbar", "\u00a7-sect", "\u00a8-uml", "\u00a9-copy", "\u00aa-ordf", "\u00ab-laquo", 
        "\u00ac-not", "\u00ad-shy", "\u00ae-reg", "\u00af-macr", "\u00b0-deg", "\u00b1-plusmn", "\u00b2-sup2", "\u00b3-sup3", "\u00b4-acute", "\u00b5-micro", "\u00b6-para", "\u00b7-middot", "\u00b8-cedil", "\u00b9-sup1", "\u00ba-ordm", "\u00bb-raquo", 
        "\u00bc-frac14", "\u00bd-frac12", "\u00be-frac34", "\u00bf-iquest", "\u00c0-Agrave", "\u00c1-Aacute", "\u00c2-Acirc", "\u00c3-Atilde", "\u00c4-Auml", "\u00c5-Aring", "\u00c6-AElig", "\u00c7-Ccedil", "\u00c8-Egrave", "\u00c9-Eacute", "\u00ca-Ecirc", "\u00cb-Euml", 
        "\u00cc-Igrave", "\u00cd-Iacute", "\u00ce-Icirc", "\u00cf-Iuml", "\u00d0-ETH", "\u00d1-Ntilde", "\u00d2-Ograve", "\u00d3-Oacute", "\u00d4-Ocirc", "\u00d5-Otilde", "\u00d6-Ouml", "\u00d7-times", "\u00d8-Oslash", "\u00d9-Ugrave", "\u00da-Uacute", "\u00db-Ucirc", 
        "\u00dc-Uuml", "\u00dd-Yacute", "\u00de-THORN", "\u00df-szlig", "\u00e0-agrave", "\u00e1-aacute", "\u00e2-acirc", "\u00e3-atilde", "\u00e4-auml", "\u00e5-aring", "\u00e6-aelig", "\u00e7-ccedil", "\u00e8-egrave", "\u00e9-eacute", "\u00ea-ecirc", "\u00eb-euml", 
        "\u00ec-igrave", "\u00ed-iacute", "\u00ee-icirc", "\u00ef-iuml", "\u00f0-eth", "\u00f1-ntilde", "\u00f2-ograve", "\u00f3-oacute", "\u00f4-ocirc", "\u00f5-otilde", "\u00f6-ouml", "\u00f7-divide", "\u00f8-oslash", "\u00f9-ugrave", "\u00fa-uacute", "\u00fb-ucirc", 
        "\u00fc-uuml", "\u00fd-yacute", "\u00fe-thorn", "\u00ff-yuml", "Œ-OElig", "œ-oelig", "Š-Scaron", "š-scaron", "Ÿ-Yuml", "ƒ-fnof", "ˆ-circ", "˜-tilde", "Α-Alpha", "Β-Beta", "Γ-Gamma", "Δ-Delta", 
        "Ε-Epsilon", "Ζ-Zeta", "Η-Eta", "Θ-Theta", "Ι-Iota", "Κ-Kappa", "Λ-Lambda", "Μ-Mu", "Ν-Nu", "Ξ-Xi", "Ο-Omicron", "Π-Pi", "Ρ-Rho", "Σ-Sigma", "Τ-Tau", "Υ-Upsilon", 
        "Φ-Phi", "Χ-Chi", "Ψ-Psi", "Ω-Omega", "α-alpha", "β-beta", "γ-gamma", "δ-delta", "ε-epsilon", "ζ-zeta", "η-eta", "θ-theta", "ι-iota", "κ-kappa", "λ-lambda", "μ-mu", 
        "ν-nu", "ξ-xi", "ο-omicron", "π-pi", "ρ-rho", "ς-sigmaf", "σ-sigma", "τ-tau", "υ-upsilon", "φ-phi", "χ-chi", "ψ-psi", "ω-omega", "ϑ-thetasym", "ϒ-upsih", "ϖ-piv", 
        " -ensp", " -emsp", " -thinsp", "‌-zwnj", "‍-zwj", "‎-lrm", "‏-rlm", "–-ndash", "—-mdash", "‘-lsquo", "’-rsquo", "‚-sbquo", "“-ldquo", "”-rdquo", "„-bdquo", "†-dagger", 
        "‡-Dagger", "•-bull", "…-hellip", "‰-permil", "′-prime", "″-Prime", "‹-lsaquo", "›-rsaquo", "‾-oline", "⁄-frasl", "€-euro", "ℑ-image", "℘-weierp", "ℜ-real", "™-trade", "ℵ-alefsym", 
        "←-larr", "↑-uarr", "→-rarr", "↓-darr", "↔-harr", "↵-crarr", "⇐-lArr", "⇑-uArr", "⇒-rArr", "⇓-dArr", "⇔-hArr", "∀-forall", "∂-part", "∃-exist", "∅-empty", "∇-nabla", 
        "∈-isin", "∉-notin", "∋-ni", "∏-prod", "∑-sum", "−-minus", "∗-lowast", "√-radic", "∝-prop", "∞-infin", "∠-ang", "∧-and", "∨-or", "∩-cap", "∪-cup", "∫-int", 
        "∴-there4", "∼-sim", "≅-cong", "≈-asymp", "≠-ne", "≡-equiv", "≤-le", "≥-ge", "⊂-sub", "⊃-sup", "⊄-nsub", "⊆-sube", "⊇-supe", "⊕-oplus", "⊗-otimes", "⊥-perp", 
        "⋅-sdot", "⌈-lceil", "⌉-rceil", "⌊-lfloor", "⌋-rfloor", "〈-lang", "〉-rang", "◊-loz", "♠-spades", "♣-clubs", "♥-hearts", "♦-diams"

     ];
 _entitiesLookupTable=new Hash();
for(var i=0;i<_entitiesList.length;i++)
{
  _entitiesLookupTable.setItem(_entitiesList[i].substr(2),_entitiesList[i].charAt(0));
}
function indexOfAny(chars,s,startIndex)
{
  if(arguments.length<3)
    startIndex=0;
  if(s!=null)
  {
	   for(var j=0;j<chars.length;j++)
	   {
		 for(var i=startIndex;i<s.length;i++)
		 {
		   if(s.charAt(i)==chars[j])
		     return i;
		 }
	   }
	   return -1;
  }
  else
  {
	return -1;
  }
}
    function IndexOfHtmlEncodingChars(s, startPos)
    {
        var num = s.length - startPos;
        for(var i= startPos;i<s.length;i++)
        {
            var ch=s.charAt(i);
            var charCode=ch.charCodeAt(0);
            if(ch<='>')
            {
                switch(ch)
                {
                    case '<':
                    case '>':
                    case '"':
                    case '&':
                        return i;
                }
            }
            else if ( charCode>=0xa0 && charCode < 'ā')
            {
                return i;
            }
         }
         return -1;
    }

function HTMLEncode(s)
{
     if (s == null)
    {
        return null;
    }
    if (typeof s != "string")
        return s;
    var num = IndexOfHtmlEncodingChars(s, 0);
    if (num == -1)
    {
        return s;
    }
    var result=new Array();
    var length = s.length;
    var startIndex = 0;
    while(num != -1)
    {
        if (num > startIndex)
        {
            result[result.length]=s.substr(startIndex, num - startIndex);
        }
        var ch = s.charAt(num);
        if (ch > '>')
        {
            result[result.length]="&#"+ch.charCodeAt(0)+";"
        }
        else
        {
            var ch2 = ch;
            if (ch2 != '"')
            {
                switch (ch2)
                {
                    case '<':
                        result[result.length]="&lt;";
                        break;

                    case '>':
                        result[result.length]="&gt;";
                        break;;

                    case '&':
                        result[result.length]="&amp;";
                        break;;
                }
            }
            else
            {
                result[result.length]="&quot;";
            }
        }
        startIndex = num + 1;
        if (startIndex < length)
        {
            num = IndexOfHtmlEncodingChars(s, startIndex);
        }
        else 
          break;
    }
    if (startIndex < length)
      result[result.length]=s.substr(startIndex, length - startIndex);
    result=result.join('')
    return result;
}
function HTMLDecode(s)
{
    var s_entityEndingChars=[ ';', '&' ];
	if(s==null)
	    return null;
	if (typeof s != "string")
	    return s;
	if (s.indexOf('&') < 0)
	{
		return s;
	}
	else
	{
		var length = s.length;
		var result=new Array();
		for (var i = 0; i < length; i++)
		{
			var ch = s.charAt(i);
			if (ch == '&')
			{
				var num3 = indexOfAny(s_entityEndingChars,s, i + 1);
				if ((num3 > 0) && (s.charAt(num3) == ';'))
				{
					var entity = s.substr(i + 1, (num3 - i) - 1);
					if ((entity.length > 1) && (entity.charAt(0) == '#'))
					{
						if ((entity.charAt(1) == 'x') || (entity.charAt(1) == 'X'))
						{
						  var char_Code='0x'+entity.substr(2)
						  char_Code =parseInt(char_Code);
						  if(isNaN(char_Code))
							i++
						  else
							ch=String.fromCharCode(char_Code);
						}
						else
						{
						  var char_Code='0x'+entity.substr(1)
						  char_Code =parseInt(char_Code);
						  if(isNaN(char_Code))
							i++
						  else
							ch=String.fromCharCode(char_Code);

						}
						i = num3;
					}
					else
					{
						i = num3;
						var ch2 =_entitiesLookupTable.getItem(entity);
						if (ch2 != '\0')
						{
							ch = ch2;
						}
						else
						{
							ch='&'+entity+';';
						}
					}
				}
			}
			result[result.length]=ch;
		}
		result=result.join('');
		return result;
	}

}
