// JavaScript Document
//切换广告
function ad(sId,aList){
	this.oDiv = document.getElementById(sId);
	if(this.oDiv){
		this.oDiv.innerHTML = "广告加载中...";
		this.list = aList;
		this.i = 0;
		this.show();
	}else{
		//alert("广告未找到！");
	}
}
ad.prototype.show = function(){
	var str = "";
	var sSrc = this.list[this.i][0];
	var sUrl = this.list[this.i][1];
	var iWidth = this.list[this.i][2];
	var iHeight = this.list[this.i][3];
	var iTime = this.list[this.i][4];
	var adtype = sSrc.split(".")[sSrc.split(".").length-1].toLowerCase();
	if(adtype=="swf"){
		str = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+iWidth+"' height='"+iHeight+"'>";
		str += "<param name='movie' value='"+sSrc+"' />";
		str += "<param name='quality' value='high' />";
		str += "<embed src='"+sSrc+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+iWidth+"' height='"+iHeight+"'></embed>";
		str += "</object>";
	}else{
		str = "<img src='"+sSrc+"' width='"+iWidth+"' height='"+iHeight+"' border='0'/>"
		if(sUrl.length>0){
			str = "<a href='"+sUrl+"' target='_blank'>"+str+"</a>"
		}
	}
	this.oDiv.innerHTML = str;	
	if(this.list.length>1){
		var _self = this;
		setTimeout(function(){_self.show();},iTime);
		this.i = (this.i >= (this.list.length-1)) ? 0 : this.i+1;
	}
};

/*配置参数*/
var SiteLanguageSupport = ["en","cn"];	//可设计成从xml配置文件中读取或由asp、jsp、php后置
var CurrentLanguage = "cn";							//可由asp、jsp、php后置

Object.prototype.hasConstructor = function hasConstructor()
{
	try
	{
		if("function"==typeof(this.constructor))
			return true;
		else
			return false;
	}
	catch(E)
	{
		return false;
	}
};
Object.prototype.safeToString = function safeToString(d)
{
	try
	{
		return this.toString();
	}
	catch(E)
	{
		return safeToString(d,"");
	}
};
Object.prototype.inheritedFrom = function inheritedFrom(c)
{
	try
	{
		if("function"==typeof(c))
			return c.prototype.isPrototypeOf(this);
		else if(c.hasConstructor())
			return c.constructor.prototype.isPrototypeOf(this);
		else
			return false;
	}
	catch(E)
	{
		return false;
	}
};
Object.prototype.instanceOf = function instanceOf(c)
{
	try
	{
		return this instanceof c;
	}
	catch(E)
	{
		return false;
	}
};
String.prototype.trim=function trim()
{
	return this.replace(/^\s+|\s+$/g,"");
};
String.prototype.ltrim=function ltrim()
{
	return this.replace(/^\s+/g,"");
};
String.prototype.rtrim=function rtrim()
{
	return this.replace(/\s+$/g,"");
};
String.prototype.hasUnicodeChar=function hasUnicodeChar()
{
	return escape( this ).indexOf("%u") >= 0;
};
String.prototype.getUnicodePart=function getUnicodePart()
{
	var ary = escape(this).match( /(%u[0123456789ABCDEF]{4})+/g );
	if(ary) return  unescape( ary.join("") );
	else	return "";
};
String.prototype.getAsciiPart=function getAsciiPart()
{
	var s = escape(this);
	return unescape( s.replace( /(%u[0123456789ABCDEF]{4})+/g, "" ) );
};
String.prototype.compareString=function compareString(s)
{
	s=safeToString(s);
	if(this>s) return 1;
	else if(this==s) return 0;
	else return -1;
};
String.prototype.compareText=function compareText(t)
{
	return this.toLowerCase().compareString(safeToString(t).toLowerCase());
};
String.prototype.equalText=function equalText(t)
{
	return this.toLowerCase()==safeToString(t).toLowerCase();
};
//************************************************************************************************/
//						pat = /([\w\.]+)@(\w+)\.(\w+)((\.(\w+))*)/ig		邮件地址
//						pat = /\w{6,20}/ig								6-20位用户名
//						pat = /\d{4,8}/ig									4-8位邮编
//						pat = /\d{15}|\d{18}/ig						15或18位数字身份证号
//						pat = /(<\/{0,1}[A-Za-z]+[^<>]*>)/ig	html标签
//						pat = /(\key)(\-1|\d{1,20})/ig			ShortCut对象的sKey键值写法 key-1或key4 key5456...
String.prototype.regCompare=function regCompare(pat)
{
	if(!isRegExp(pat)) return false;
	var arr = this.match(pat);
  return isArray(arr)&&1==arr.length&&arr[0]==this;
};
//------------------------------------------------------------------------------------------------/
String.prototype.isEmpty=function isEmpty(btrimed)
{
	if(toBoolean(btrimed))
		return this.trim().length<=0;
	else
		return this.length<=0;
};
String.prototype.notEmpty=function notEmpty(btrimed)
{
	return !this.isEmpty(btrimed);
};
String.prototype.joinString=function joinString() //param: s1[, s2[, . . . [, sN]]], sSep
{
	if(arguments.length<1)
		return this;
	else if(1==arguments.length)
		return this+safeToString(arguments[0]);
	else
	{
		var s=this;
		var sSep = safeToString(arguments[arguments.length-1]);
		var bSepEmpty = sSep.isEmpty();
		for(var i=0; i<arguments.length-1; i++)
		{
			var si = safeToString(arguments[i]);
			if(bSepEmpty||s.isEmpty()||si.isEmpty())
				s+=si;
			else
				s+=sSep+si;
		}
		return s;
	}
};
String.prototype.upperFirstChar=function upperFirstChar()
{
	if(!this.isEmpty())return this.charAt(0).toUpperCase()+this.substring(1,this.length);
	else return this;
};
Number.prototype.sign=function sign()
{
	if(isNaN(this)||0==this) return 0;
	else return (this>0)?1:-1;
};
Array.prototype.indexOf=function indexOf(o)
{
	for(var i=0;i<this.length;i++)
	{
		if(!isValid(o)&&!isValid(this[i])) return i;
		else if(o==this[i]) return i;
	}
	return-1;
};
Array.prototype.indexOfText=function indexOfText(t)
{
	for(var i=0;i<this.length;i++)
	{
		if(safeToString(this[i]).equalText(t)) return i;
	}
	return-1;
};
Array.prototype.lastIndexOf=function lastIndexOf(o)
{
	for(var i=this.length-1;i>=0;i--)
	{
		if(!isValid(o)&&!isValid(this[i])) return i;
		else if(o==this[i]) return i;
	}
	return-1;
};
Array.prototype.lastIndexOfText=function lastIndexOfText(t)
{
	for(var i=this.length-1;i>=0;i--)
	{
		if(safeToString(this[i]).equalText(t)) return i;
	}
	return-1;
};
Array.prototype.contains=function contains(o)
{
	return this.indexOf(o)!= -1;
};
Array.prototype.containsText=function containsText(t)
{
	return this.indexOfText(t)!= -1;
};
Array.prototype.insertAt=function insertAt(o,i)
{
	this.splice(i,0,o);
	return this.length;
};
Array.prototype.insertBefore=function insertBefore(o,o2)
{
	var i=this.indexOf(o2);
	if(-1==i)
	{
		this.push(o);
		return this.length;
	}
	else
	{
		this.splice(i,0,o);
		return i;
	}
};
Array.prototype.removeAt=function removeAt(i)
{
	this.splice(i,1);
};
Array.prototype.remove=function remove(o)
{
	var i=this.indexOf(o);
	if(-1!=i)
	{
		this.splice(i,1);
		return this.length;
	}
	else
		return-1;
};
Array.prototype.removeText=function removeText(t)
{
	var i = this.indexOfText(t);
	if(-1!=i)
	{
		this.splice(i,1);
		return this.length;
	}
	else
		return-1;
};
Array.prototype.clone=function clone()
{
	var r=[];
	r=r.concat(this);
	return r;
};
Function.prototype.name=function name()
{
	var s = safeToString(this);
	if(/^function\s+([A-Za-z_]\w+)\s*\(/g.test(s))
		return safeToString(RegExp.$1);
	else
		return "";
};
function isNull(o) { return (o==null); };	//注意undefined==null
function isUndefined(o) { return (typeof(o)=="undefined"); };
function isValid(o) { return (o!=null); };	//可以用来排除undefined和null
function safeToString(o,d) { return isValid(o)?o.safeToString(d):safeToString(d,""); };
function isObject(o) { return (isValid(o)&&typeof(o)=="object"); };
function isFunction(o) { return (isValid(o)&&typeof(o)=="function"); };
function isSelfObject(o, objClass) {	return isObject(o)&&isFunction(o.hasConstructor)&&o.hasConstructor()&&(!isValid(objClass)||eval(""+o.constructor==""+objClass)||o.instanceOf(objClass));};
function isString(s) { return (isValid(s)&&typeof(s)=="string"); };
function isNumber(n) { return (isValid(n)&&typeof(n)=="number"); };
function isBoolean(b) { return (isValid(b)&&typeof(b)=="boolean"); };
function isRegExp(r) { return isSelfObject(r,RegExp); };
function isArray(a) { return isSelfObject(a,Array); };
function isDOMNode(o,t) { return isObject(o)&&isString(o.nodeName)&&isNumber(o.nodeType)&&(!isNumber(t)||t==o.nodeType); };
//nodeType: 1 ELEMENT_NODE 2 ATTRIBUTE_NODE 3 TEXT_NODE 4 CDATA_SECTION_NODE 5 ENTITY_REFERENCE_NODE
//6 ENTITY_NODE 7 PROCESSING_INSTRUCTION_NODE 8 COMMENT_NODE 9 DOCUMENT_NODE 10 DOCUMENT_TYPE_NODE
//11 DOCUMENT_FRAGMENT_NODE 12 NOTATION_NODE
function isDOMElement(o,s) { return isDOMNode(o,1)&&isString(o.tagName)&&(safeToString(s).trim().isEmpty()||o.tagName.equalText(s)); };
function isXmlNode(x) { return isObject(x)&&isString(x.nodeTypeString); };
function isXmlDoc(d) { return isXmlNode(d)&&d.nodeTypeString.equalText("document"); };
function isXmlElm(m,s) { return isXmlNode(m)&&m.nodeTypeString.equalText("element")&&(safeToString(s).trim().isEmpty()||m.tagName==s); };
function isXmlAtt(a) { return isXmlNode(a)&&a.nodeTypeString.equalText("attribute"); };
function hasXmlAttribute(m,s)
{ 
	if(isXmlNode(m)&&isObject(m.attributes))
	{ 
		var attrs = m.attributes;
		if(isNumber(attrs.length)&&(0<attrs.length))
		{
			try
			{
				var n = attrs.getNamedItem(s);
				if(isXmlAtt(n))	return true;
			}
			catch(E) {	return false; }
		}
	}
	return false;
};
function arrayLength(a) { return (isArray(a))?a.length:0; };
function indexOfArray(a,o) { return isArray(a)?a.indexOf(o):-1; };
function indexOfArrayText(a,t) { return isArray(a)?a.indexOfText(t):-1; };
function equal(o1,o2)
{
	if(isValid(o1)&&isValid(o2)) return o1==o2;
	else if(!isValid(o1)&&!isValid(o2)) return true;
	else return false;
};
function isEmail(s)
{
	return safeToString(s).regCompare(/([\w\.]+)@(\w+)\.(\w+)((\.(\w+))*)/ig);
};
function isZipcode(s)
{
	return safeToString(s).regCompare(/\d{4,8}/ig);
};
function checkNumberBetween( o, nMin, nMax, sName, bAlert, bResume )
{
	if(!isDOMElement(o)) return false;
	var s=NaN;
	try{s=toFloat(o.value);}
	catch(E){return false;}
	if(isNaN(s))
	{
		if(toBoolean(bAlert,true)) alert("注意:"+safeToString(sName)+"的值不正确!");
		tryFocus(o);
		return false;
	}
	else
	{
		nMin = toFloat(nMin,MIN_VALUE);
		nMax = toFloat(nMax,MAX_VALUE);
		if(s>=nMax)
		{
			if(toBoolean(bAlert,true)) alert("注意:"+safeToString(sName)+"的值不能大于"+nMax+"!");
			tryFocus(o);
			return false;
		}
		if(s<=nMin)
		{
			if(toBoolean(bAlert,true)) alert("注意:"+safeToString(sName)+"的值不能小于"+nMin+"!");
			tryFocus(o);
			return false;
		}
		return true;
	}
};
function checkInputValue(o,bCanEmpty,sName,sRegPat,bTrim,bAlert,bResume)
{
	if(!isDOMElement(o)) return false;
	var s="";
	try{s=o.value;}
	catch(E){return false;}
	if(toBoolean(bTrim,true)) s=s.trim();
	if(s.isEmpty())
	{
		if(!toBoolean(bCanEmpty,true))
		{
			if(toBoolean(bAlert,true)) alert(mla(["Attention:"+safeToString(sName)+" should not be empty!","注意:"+safeToString(sName)+"不能为空!"]));
			if(toBoolean(bResume,true)) o.value=s;
			tryFocus(o);
			return false;
		}else{
			if(toBoolean(bResume,true)) o.value=s;
			return true;
		}
	}
	if(isRegExp(sRegPat)&&!s.regCompare(sRegPat))
	{
		if(toBoolean(bAlert,true)) alert(mla(["Attention: Please specified a valid "+safeToString(sName)+"!","注意:请输入正确的"+safeToString(sName)+"!"]));
		if(toBoolean(bResume,true)) o.value=s;
		tryFocus(o);
		return false;
	}
	if(toBoolean(bResume,true)) o.value=s;
	return true;	
};
function toInt(i, d)
{
	if(!isValid(d)) d=-1;
	var newi = NaN;
	if(isValid(i)&&(isNumber(i)||isString(i)||isBoolean(i)))
		newi = parseInt(safeToString(i));
	return isNaN(newi)? d: newi;
};
function toFloat(i, d)
{
	if(!isValid(d)) d=-1;
	var newf = NaN;
	if(isValid(f)&&(isNumber(f)||isString(f)||isBoolean(f)))
		newf = parseFloat(safeToString(f));
	return isNaN(newf)? d: newf;
};
function toBoolean(b,d)
{
	if(!isValid(d)) d=false;
	if(!isValid(b))
		return d;
	else if(isBoolean(b))
		return b;
	else if(isString(b))
	{
		if(b.equalText("TRUE"))
			return true;
		else if(b.equalText("FALSE"))
			return false;
		else
			return d;
	}
	else if(isNumber(b))	//NaN 负数 0均为 false
		return b>0;
	else	
		return d;
};
function getElm( elmName, parent ) 
{
	if ( !isValid(parent) )
  	parent = document;
  var coll = parent.getElementsByName(elmName);
  if ( coll.length > 0 )
    return coll.item(0);
  else
   	return null;
};
function getElmValueByElm( elm, defvalue )
{
	if ( isValid(elm) )
		return elm.value;
	else
		return defvalue;
};
function getElmValue( elmName, defvalue, parent )
{
	return getElmValueByElm( getElm( elmName, parent ), defvalue );
};
function getElmAttributeByElm( elm, attName, defvalue )
{
	if ( !isValid(elm) )
		return defvalue;
	else
	{
		var attobj = elm.getAttributeNode( attName );
		if ( !isValid(attobj) ) 
			return defvalue;
		else
			return attobj.value;
	}
};
function getElmAttributeByElmName( elmName, attName, defvalue, parent )
{
	return getElmAttributeByElm( getElm( elmName, parent ), attName, defvalue );
};
function setElmValue( elmName, value, parent )
{
	if ( !isValid(parent) )
		parent = document;
	var coll = parent.getElementsByName(elmName);
	if ( coll.length <= 0 ) return;
	for (var i = 0; i < coll.length; i++)
	{
		try
		{
			coll.item(i).value = value;
		}
		catch(E)
		{
			continue;
		}
	}
};
function jumpMenu(targ,selObj,restore)
{
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
};
function tryFocus(o) {
	try {	o.focus(); }
	catch(e) {}
};
function ifThen( bCondition, sTrue, sFalse )
{
	if ( toBoolean(bCondition) ) return sTrue;
	else	return sFalse;
};
function isEmpty(s, bTrim)
{
	return safeToString(s).isEmpty(bTrim);
};
function notEmptyString(s, bTrim)
{
	return safeToString(s).notEmpty(bTrim);
};
//检查并返回通过检查的整数
//iSign表示要检查i的正负
//0或不写:表示不检查，负数表示要检查i为负数，正数表示要检查i为正数，检查不通过则返回NaN
function parseInteger(i,iSign)
{
	i = toInt(i,NaN);
	if(isNaN(i)) return NaN;
	iSign = toInt(iSign,0);
	if(0==iSign||iSign.sign()==i.sign()) return i;
	else return NaN;
};
//年份是否是闰年
function isLeapYear(y)
{
	y = parseInteger(y,1);
	if (isNaN(y))
		return false;
	else
		return ( 0==y%4 && (0!=y%100||0==y%400) ); 
};
//检查年月日是否是确有那么一天，如果没有返回null，有则返回Date
function parseDateEx(y,m,d)
{
	y = parseInteger(y,1);
	m = parseInteger(m,1);
	d = parseInteger(d,1);
	if ( isNaN(y) || isNaN(m) || isNaN(d) )
		return null;
	m--;
	var dt = new Date(y,m,d);
	if ( dt.getFullYear()!=y  || dt.getMonth()!=m || dt.getDate()!=d )
		return null;
	return dt;
};
function parseDate(s)
{
	s=safeToString(s).trim();
	if (s.isEmpty()) {	return null; }
	var a = s.split("-");
	if ( 3!=a.length )
		return null;
	else 
		return parseDateEx( a[0], a[1], a[2] );
};
function isValidDate(s)
{
	return (parseDate(s)!=null);
};
function isValidDateEx(y,m,d)
{
	return (parseDateEx(y,m,d)!=null);
};
function dateToString(dt)
{
	try
	{
		var m=dt.getMonth()+1;
		var d=dt.getDate();
		m = ( (m<10)?"0":"" ) + m;
		d = ( (d<10)?"0":"" ) + d;
		return dt.getFullYear() + "-" + m + "-" + d;
	}
	catch(e) { return ""; }
};
//取得一个DOM对象的绝对坐标 Rect 对象
function getDOMObjRect(obj)
{
	var r = new Rect(0,0,0,0);
	if(isDOMNode(obj)&&isNumber(obj.offsetLeft)&&isNumber(obj.offsetTop)&&isNumber(obj.offsetWidth)&&isNumber(obj.offsetHeight))
	{
		r.reset( obj.offsetLeft, obj.offsetTop, obj.offsetWidth, obj.offsetHeight );
	 	while (obj = obj.offsetParent) {	r.offsetRect( obj.offsetLeft + obj.clientLeft, obj.offsetTop + obj.clientTop ); 	}
 	}
 	if(isValid(document.body))r.offsetRect(-(document.body.offsetLeft+document.body.clientLeft),-(document.body.offsetTop+document.body.clientTop));
 	return r;
};
function getDOMObjClientRect(obj)
{
	var r = new Rect(0,0,0,0);
	if(isDOMNode(obj)&&isNumber(obj.offsetLeft)&&isNumber(obj.offsetTop)&&isNumber(obj.clientWidth)&&isNumber(obj.clientHeight))
	{
		r.reset( obj.offsetLeft + obj.clientLeft, obj.offsetTop + obj.clientTop, obj.clientWidth, obj.clientHeight );
		while (obj = obj.offsetParent) { r.offsetRect( obj.offsetLeft + obj.clientLeft, obj.offsetTop + obj.clientTop ); }
	}
 	if(isValid(document.body))r.offsetRect(-(document.body.offsetLeft+document.body.clientLeft),-(document.body.offsetTop+document.body.clientTop));
	return r;
};
//************************************************************************************************/
//取鼠标当前或能取的最后坐标
var __LAST_EVENT_MOUSE_POINT = new Point(0,0);
function getEventMousePoint()
{
	if(window&&window.event)
		__LAST_EVENT_MOUSE_POINT = new Point( window.event.clientX + document.body.scrollLeft, window.event.clientY+document.body.scrollTop );
	return __LAST_EVENT_MOUSE_POINT;
};
function getMousePoint() {
	if(isObject(document)&&isObject(document.body)) {
		document.body.attachEvent("onmousemove", getEventMousePoint);
		document.body.fireEvent("onmousemove");
		document.body.detachEvent("onmousemove", getEventMousePoint);
		return __LAST_EVENT_MOUSE_POINT;
	} else return getEventMousePoint();
};
//------------------------------------------------------------------------------------------------/
//检查鼠标是否停留在DOM对象上
function checkMouseOnObj(obj)
{
	var r = getDOMObjRect(obj);
	var p = getMousePoint();
	return (r.getWidth()>=0)&&(r.containsPoint(p));
};
//检查鼠标是否停留在DOM对象上
function checkEventMouseOnObj(obj)
{
	var r = getDOMObjRect(obj);
	var p = getEventMousePoint();
	return (r.getWidth()>=0)&&(r.containsPoint(p));
};
//************************************************************************************************/
//多语种支持部份
function isen() { return (CurrentLanguage=="en"); };
function iscn() { return (CurrentLanguage=="cn"); };
function istw() { return (CurrentLanguage=="tw"); };
function _getMLIndex(sLang)
{
	if(isArray(SiteLanguageSupport))
		return Math.max(-1,SiteLanguageSupport.indexOfText(sLang));
	else if(isString(SiteLanguageSupport)&&SiteLanguageSupport.equalText(sLang))
		return 0;
	else
		return -1;
};
function getMLIndex()
{
	return Math.max(_getMLIndex(CurrentLanguage),0);
};
function ml(str, sSplit)
{
	if(isString(str)&&isString(sSplit))
	{
		var a = str.split(sSplit);
		if(isArray(a)) return mla(a);
	}
	return str;
};
function mla(strorarray)
{
	if(isArray(strorarray))
	{
		var i = getMLIndex();
		if(i>=0&&i<strorarray.length) return strorarray[i];
		else return strorarray[0];
	}
	else return ml(strorarray, " ");
};
function getMLMapping()
{
	return mla(SiteLanguageSupport);
};
//------------------------------------------------------------------------------------------------/
function uniqueID20()
{
	return Math.round( Math.random() * 0xFFFFFFFFFFFFFFFF ).toString();
};
function uniqueID40()
{
	return uniqueID20() + uniqueID20();
};
//************************************************************************************************/
/*类 XdObject */
	function XdObject()
	{
		this._uniqueID = XdObject._uniquePrefix + uniqueID40() + XdObject._uniquePrefix + XdObject._objectCount;
		XdObject.setGlobalObject(this._uniqueID,this);
		window.attachEvent("onunload", Function( "XdObject.getGlobalObject(\"" + this._uniqueID + "\").dispose();" ) );
	};
	XdObject._uniquePrefix="xduc";
	XdObject._objectCount=0;
	XdObject.toUniqueID=function toUniqueID(o)
	{
		if(isValid(o._uniqueID))
			return o._uniqueID;
		else
			return o._uniqueID = XdObject._uniquePrefix + uniqueID40() + XdObject._uniquePrefix + XdObject._objectCount;
	};
	XdObject._globalList= {};
	XdObject.getGlobalObject=function getGlobalObject(uID)
	{
		return isValid(XdObject._globalList[uID])?XdObject._globalList[uID]:undefined;
	};
	XdObject.setGlobalObject=function setGlobalObject(uID,o)
	{
		XdObject._globalList[uID]=o;
		XdObject._objectCount+=1;
	};
	XdObject.prototype._className="XdObject";
	XdObject.prototype._disposed=false;
	XdObject.prototype.getGetSelfString=function getGetSelfString()
	{
		return "XdObject.getGlobalObject(\"" + this._uniqueID + "\")"
	};
	XdObject.prototype.dispose=function dispose()
	{
		window.detachEvent("onunload", Function( this.getGetSelfString()+".dispose();" ) );
		this._disposed=true;
		/*
			合理情况下如果如下语句应该执行，这样才能真正将对象dispose,
			否则对象永远存在于_globalList中，没有真正释放内存
			但是对象是否还被引用是我在js里根本无法控制的
			如果下句执行，并且某人在某个对象dispose后仍使用它，就有可能发生错误
			发生错误的原因是XdEventObject类下的绑定事件调用需要根据uniqueID从全局_globalList里取得绑定对象
			简单用somedomnodeorwindow.attachEvent( someEventString, this.someFunction );来绑定对象事件
			会导致this指向window而非该XdEventObject对象
			而现在的XdEventObject对象的事件绑定均为
			somedomnodeorwindow.attachEvent( someEventString, new Function( "XdObject.getGlobalObject(\"" + this._uniqueID + "\")." + someFunctionString ) );
			这里的uniqueID是在对象构造时就生成的，而在事件产生后才去全局_globalList取对象当做this
			保证对象可取。
			如果代码正确(dispose后不再使用对象)，建议下句执行，省内存
			如果对象使用数量不多，建议下句不执行，确保安全。
			XdObject._globalList[this._uniqueID] = undefined;
		*/
	};
	XdObject.prototype.getDisposed=function getDisposed()
	{
		return this._disposed;
	};
	XdObject.prototype.toString=function toString()
	{
		if(isValid(this)&&isValid(this._className))
			return "[object " + this._className + "]";
		else
			return"[object Object]";
	};
	XdObject.prototype.getProperty=function getProperty(sPropertyName)
	{
		var getterName="get"+sPropertyName.charAt(0).toUpperCase()+sPropertyName.substr(1);
		if(isFunction(this[getterName]))
			return this[getterName]();
		return undefined;
	};
	XdObject.prototype.setProperty=function setProperty(sPropertyName,oValue)
	{
		var setterName="set"+sPropertyName.charAt(0).toUpperCase()+sPropertyName.substr(1);
		if(isFunction(this[setterName]))
			this[setterName](oValue);
		else
			this["_"+sPropertyName]=oValue;
	};
	XdObject.prototype.getUniqueID=function getUniqueID()
	{
		return this._uniqueID;
	};
//------------------------------------------------------------------------------------------------/
//************************************************************************************************/
/*类 XdObjectList */
	function XdObjectList()
	{
		this.base = XdObject;
		this.base();
		this._keysdic = new ActiveXObject("Scripting.Dictionary");
		this._itemsdic = new ActiveXObject("Scripting.Dictionary");
	};
	XdObjectList.prototype=new XdObject;
	XdObjectList.prototype._className="XdObjectList";
	XdObjectList.prototype.dispose=function dispose()
	{
		if(isValid(XdObjectList.prototype)&&XdObjectList.prototype!=this)
		{
			this.removeAll();
			this._keysdic = null;
			this._itemsdic = null;
		}
		XdObject.prototype.dispose.call(this);
	};
	XdObjectList.prototype.existsKey = function existsKey(k)
	{
		return this._keysdic.Exists(k);
	};
	XdObjectList.prototype.item = function item(k)
	{
		if(this.existsKey(k)) return this._keysdic.Item(k);
		else return undefined;
	};
	XdObjectList.prototype.existsItem = function existsItem(o)
	{
		return this._itemsdic.Exists(o);
	};
	XdObjectList.prototype.itemKey = function itemKey(o)
	{
		if(this.existsItem(o)) return this._itemsdic.Item(o);
		else return undefined;
	};
	XdObjectList.prototype.count = function count()
	{
		return this._keysdic.Count;
	};
	XdObjectList.prototype.set = function set(k,o)
	{
		if(!this.existsKey(k)&&!this.existsItem(o))
		{
			this._keysdic.Add(k,o);
			this._itemsdic.Add(o,k);
		}
		else if(!this.existsKey(k))
		{
			var oldK = this._itemsdic.Item(o);
			this._itemsdic.Item(o)=k;
			this._keysdic.Key(oldK)=k;
		}
		else if(!this.existsItem(o))
		{
			var oldO = this._keysdic.Item(k);
			this._keysdic.Item(k)=o;
			this._itemsdic.Key(oldO)=o;
		}
	};
	XdObjectList.prototype.add = function add(k,o)
	{
		if(!this.existsKey(k)&&!this.existsItem(o))
		{
			this._keysdic.Add(k,o);
			this._itemsdic.Add(o,k);
			return true;
		}
		else
			return false;
	};
	XdObjectList.prototype.remove = function remove(k)
	{
		if(!this.existsKey(k)) return false;
		else
		{
			var o=this._keysdic.Item(k);
			this._keysdic.Remove(k);
			this._itemsdic.Remove(o);
			return true;
		}
	};
	XdObjectList.prototype.removeAll = function removeAll()
	{
		this._keysdic.RemoveAll();
		this._itemsdic.RemoveAll();
	};
//------------------------------------------------------------------------------------------------/
//************************************************************************************************/
/*类 XdEventObject */
	function XdEventObject()
	{
		this.base = XdObject;
		this.base();
		this._events=[];
	};
	XdEventObject.prototype=new XdObject;
	XdEventObject.prototype._className="XdEventObject";
	XdEventObject.prototype.dispose=function dispose()
	{
		if(isValid(XdEventObject.prototype)&&XdEventObject.prototype!=this)
		{
			if(arrayLength(this._events)>0)
			{
				for(var i=0; i<this._events.length; i++)
				{
					if(arrayLength(this._events[i])==3)
						this.setEvent(this._events[i][0], this._events[i][1], null);
				}
				this._events = null;
			}
		}
		XdObject.prototype.dispose.call(this);
	};
	XdEventObject.prototype.indexOfDomEvent = function indexOfDomEvent(oDom, sEvent)
	{
		if(arrayLength(this._events)>0)
		{
			for(var i=0; i<this._events.length; i++)
			{
				if(arrayLength(this._events[i])==3&&equal(this._events[i][0],oDom)&&equal(this._events[i][1],sEvent)&&isFunction(this._events[i][2]))
					return i;
			}
		}
		return -1;
	};
	XdEventObject.prototype.setEvent=function setEvent(oDom, sEvent, sFuncString)
	{
		//用下句来判断是否是window、document或其它可以attachEvent和detachEvent的dom对象
		//请注意继承类的属性名要慎用attachEvent和detachEvent
		if(!isArray(this._events)) this._events=[];
		if(isObject(oDom)&&!(oDom instanceof XdObject)&&isObject(oDom.attachEvent)&&isObject(oDom.detachEvent))
		{
			var iOldIndex = this.indexOfDomEvent(oDom,sEvent);
			if(iOldIndex>=0&&(!isValid(sFuncString)||safeToString(sFuncString).trim().isEmpty()))
			{
				var oldF = this._events[iOldIndex][2];
				try
				{
					oDom.detachEvent( sEvent, oldF );
					return true;
				}
				catch(E) {}
				finally	{	this._events.removeAt(iOldIndex);	}
			}
			else if(isValid(sFuncString)&&iOldIndex<0)
			{
				try
				{
					if(isFunction(sFuncString))
						sFuncString = sFuncString.name() + "();";
					else
					{
						sFuncString = safeToString(sFuncString).trim();
						if(";"!=sFuncString.charAt(sFuncString.length-1))
							sFuncString+=";";
					}
					sFuncString = new Function( "XdObject.getGlobalObject(\"" + this._uniqueID + "\")." + sFuncString );
					oDom.attachEvent( sEvent, sFuncString );
					return true;
				}
				catch(E) { }
				finally
				{
					this._events.push( [oDom, sEvent, sFuncString] );
				}
			}
		}
		return false;
	};
//------------------------------------------------------------------------------------------------/
//************************************************************************************************/
/*类 Point 和 Size */
	function Point(x,y)
	{
		this._x= Math.max(toInt(x),0);
		this._y= Math.max(toInt(y),0);
	};
	Point.prototype.reset = function reset(x,y) { this.setx(x); this.sety(y); };
	Point.prototype.getx = function getx() {	return this._x;	};
	Point.prototype.setx = function setx(x) {	this._x= Math.max(toInt(x),0);	};
	Point.prototype.gety = function gety() {	return this._y;	};
	Point.prototype.sety = function sety(y) {	this._y= Math.max(toInt(y),0);	};
	Point.prototype.toString = function toString()
	{
		return "[object Point: x:"+this.getx()+", y:"+this.gety()+"]";
	};
	function Size(w,h)
	{
		this.base = Point;
		this.base(w,h);
	};
	Size.prototype=new Point;
	Size.prototype.getWidth = function getWidth() { return this.getx(); };
	Size.prototype.getHeight = function getHeight() { return this.gety(); };
	Size.prototype.setWidth = function setWidth(w) { this.setx(w); };
	Size.prototype.setHeight = function setHeight(h) { this.sety(h); };
	Size.prototype.getSize= function getSize() { return this.getWidth()*this.getHeight(); };	
	Size.prototype.toString = function toString()
	{
		return "[object Size: width:"+this.getWidth()+", height:"+this.getHeight()+"]";
	};
//------------------------------------------------------------------------------------------------/
function standardRect(l,t,w,h)
{
	l=toInt(l);
	t=toInt(t);
	w=toInt(w);
	h=toInt(h);
	if(w<0)
	{
		l=l+w;
		w=-w;
	}
	if(h<0)
	{
		t=t+h;
		h=-h;
	}
	return [l,t,w,h];
};
//************************************************************************************************/
/*类 Rect */
	function Rect(l,t,w,h)
	{
		this._l=toInt(l,0);
		this._t=toInt(t,0);
		this._w= Math.max(toInt(w),0);
		this._h= Math.max(toInt(h),0);
	};
	Rect.prototype.reset = function reset(l,t,w,h) { this.setLeft(l);	this.setTop(t);	this.setWidth(w);	this.setHeight(h); };
	Rect.prototype.getLeft = function getLeft() {	return this._l;	};
	Rect.prototype.getTop = function getTop() {	return this._t;	};
	Rect.prototype.getWidth = function getWidth() {	return this._w;	};
	Rect.prototype.getHeight = function getHeight() {	return this._h;	};
	Rect.prototype.getRight = function getRight() {	return this._l + this._w;	};
	Rect.prototype.getBottom = function getBottom() {	return this._t + this._h;	};
	Rect.prototype.setLeft = function setLeft(l) {	this._l=toInt(l,0);	};
	Rect.prototype.setTop = function setTop(t) { this._t=toInt(t,0); };
	Rect.prototype.setWidth = function setWidth(w) { this._w= Math.max(toInt(w),0); };
	Rect.prototype.setHeight = function setHeight(h) { this._h= Math.max(toInt(h),0); };
	Rect.prototype.setRight = function setRight(r) { this._w= toInt(r,0)-this._l; this._standardRect(); }
	Rect.prototype.setBottom = function setBottom(b) { this._h= toInt(b,0)=this._t; this._standardRect(); }
	Rect.prototype._standardRect = function _standardRect()
	{ 		
		var r = standardRect(this._l,this._t,this._w,this._h);
		this._l=r[0];
		this._t=r[1];
		this._w=r[2];
		this._h=r[3];
	};
	Rect.prototype.clone = function clone()	{	return new Rect( this._l, this._t, this._w, this._h ); };
	Rect.prototype.centerX = function centerX() {	return Math.round( this._l + this._w/2 );	}
	Rect.prototype.centerY = function centerY() {	return Math.round( this._t + this._h/2 );	}
	Rect.prototype.getLeftTop = function getLeftTop() {	return new Point( this._l, this._t );	}
	Rect.prototype.getRightBottom = function getRightBottom() {	return new Point( this.getRight(), this.getBottom() );	}
	Rect.prototype.getSize = function getSize() {	return this._w*this._h;	}
	Rect.prototype.getCenter = function getCenter() {	return new Point( this.centerX(), this.centerY() );	}
	Rect.prototype.containsPoint = function containsPoint(p)
	{
		if ( !isSelfObject(p, Point) ) return false;
		return ( p.getx() >= this.getLeft() && p.getx() <= this.getRight() && p.gety() >= this.getTop() && p.gety() <= this.getBottom() );
	};
	Rect.prototype.offsetRect = function offsetRect(x,y)
	{
		x=toInt(x,0);
		y=toInt(y,0);
		this.setLeft( this.getLeft() + x );
		this.setTop( this.getTop() + y );
		return this;
	};
	Rect.prototype.expandRect = function expandRect(i)
	{
		i=toInt(i,0);
		this.setLeft( this.getLeft() - i );
		this.setTop( this.getTop() - i );
		this.setWidth( this.getWidth() + i * 2 );
		this.setHeight( this.getHeight() + i * 2 );
		return this;
	};
	Rect.prototype.toString = function toString()
	{
		return "[object Rect: left:"+this.getLeft()+", top:"+this.getTop()+", width:"+this.getWidth()+", height:"+this.getHeight()+"]";
	};
//------------------------------------------------------------------------------------------------/
function raiseError( UseLanguage, ErrNumber, ErrSource, ErrDescription, dialogwidth, dialogheight, dialogtitle, btncaption)
{
	var Param = new Object();
	Param.ErrNumber = ErrNumber;
	Param.ErrSource = ErrSource;
	Param.ErrDescription = ErrDescription;
	Param.Btns = btncaption;
	window.showModalDialog("msg.asp?title=" + dialogtitle + "&language=" + UseLanguage,Param,"dialogWidth:" + dialogwidth + "px; dialogHeight:" + dialogheight + "px; edge: Raised; center:Yes;help:No;resizable:No;status:No;");
};
//预装图像并取最后一副图的宽和高
function preloadImages()
{
	if(arguments.length<=0) return null;
	if (!isObject(document.preloadImages))
		document.preloadImages = {};
	var r=null;
	for(var i=0;i<arguments.length;i++)
	{
		var s = safeToString(arguments[i]);
		if(s.trim().isEmpty())
			r=new Size(0,0);
		else if(isValid(document.preloadImages[s]))
			r=new Size(document.preloadImages[s].width, document.preloadImages[s].height);
		else
		{
			var oImg = new Image();
			oImg.src = s;
			document.preloadImages[s]=oImg;
			r= new Size(oImg.width,oImg.height);
		}
  }
  return r;
};
function fnSwapImage(oImg,sSrc)
{
	if(isDOMElement(oImg,"IMG"))
		oImg.src=safeToString(sSrc);
};
function removeDomChild(n)
{
	try
	{
		if(!isDOMNode(n)) return;
		var p;
		try { p=n.parentNode; }
		catch(E) { p=null; }
		if(isDOMElement(n,"TR")&&isDOMElement(p))
		{
			var npTag = safeToString(p.tagName);
			if(npTag.equalText("TBODY")||npTag.equalText("TFOOT")||npTag.equalText("THEAD"))
			{
				p.deleteRow(n.sectionRowIndex);
				return;
			}
			else if(npTag.equalText("TABLE"))
			{
				p.deleteRow(n.rowIndex);
				return;
			}
		}
		if(isDOMNode(p))
			p.removeChild(n);
		else
			n.removeNode(true);		//该方法在MSDN中有，并未指明什么IE版本才开始支持，
														//但该方法未公开支持http://www.w3.org/TR/2000/WD-DOM-Level-1-20000929/ecma-script-language-binding.html
														//其它浏览器未知
	}
	catch(E){}
};
function EnumValue( enumArray, v, d )
{
	if(arrayLength(enumArray)>0)
	{
		var i=enumArray.indexOf(v);
		if(i>=0) return enumArray[i];
		else if(isNumber(v)&&v>=0&&v<arrayLength(enumArray))
			return enumArray[v];
	}
	else if(safeToString(enumArray).equalText(safeToString(v))||toInt(v,-1)==0)
		return enumArray;
	return d;
};
function joinString() //param: s1[, s2[, . . . [, sN]]], sSep
{
	if(arguments.length<1)
		return "";
	else if(1==arguments.length)
		return safeToString(arguments[0]);
	else if(2==arguments.length)
		return safeToString(arguments[0])+safeToString(arguments[1]);
	else
	{
		var s=safeToString(arguments[0]);
		var sSep = safeToString(arguments[arguments.length-1]);
		var bSepEmpty = sSep.isEmpty();
		for(var i=1; i<arguments.length-1; i++)
		{
			var si = safeToString(arguments[i]);
			if(bSepEmpty||s.isEmpty()||si.isEmpty())
				s+=si;
			else
				s+=sSep+si;
		}
		return s;
	}
};
//*************************************************************************************************/
function isValidXdDom(o)
{
	return isSelfObject(o,XdDom)&&arrayLength(o._oDoms)>0&&isDOMElement(o._oDoms[0])&&isDOMElement(o._oDomChild);
};
//************************************************************************************************/
/*类 XdDom */
	function XdDom()
	{
		this.base = XdEventObject;
		this.base();
		this.setEvent( document, "onreadystatechange", this._onDocumentReadyStateChange );
		this._oParent = null;	//必须也是XdDom对象
		this._oChilds = [];		//里面存放子XdDom对象
		this._oDoms = [];					//要被加入_oParent._oDomChild的dom对象的数组
		this._oDomChild = null;		//子XdDom对象的_oDoms中的dom对象的容器
		/*关于_oDoms和_oDomChild
			合法的XdDom对象两者皆不能为空，即_oDoms里至少要有一个合法的dom元素，而_oDomChild也是合法的dom元素
			而_oDoms[0]==_oDomChild是允许的
			如果XdDom对象只绑定一个dom元素，就是上述这种情况
			如果某对象绑定<HR><TABLE><TBODY></TBODY></TABLE><HR>，而子对象将置入TBODY中
			那么该对象的_oDoms应该为 [HR, TABLE, HR]三个元素的数组
			而_oDomChils则为TBODY,那么可知子对象的_Doms中的任何元素均为TR才对
		*/
	};
	XdDom.prototype=new XdEventObject;
	XdDom.prototype._className="XdDom";
	XdDom.prototype.dispose=function dispose()
	{
		
		if(isValid(XdDom.prototype)&&XdDom.prototype!=this)
		{
			if(isArray(this._oChilds))
			{
				for(var i=this._oChilds.length-1; i>=0; i--)
				{
					var o = this._oChilds[i]
					try{ if(isSelfObject(o,XdObject)) o.dispose();}
					catch(E){}
					finally{o=null;}
				}
			}
			this._oChilds = null;
			removeDomChild(this._oDomChild);
			this._oDomChild=null;
			if(isArray(this._oDoms))
			{
				for(var i=this._oDoms.length-1; i>=0; i--)
				{
					removeDomChild(this._oDoms[i]);
					this._oDoms[i]=null;
				}
			}
			this._oDoms = null;
			this._oParent = null;
			this.setEvent( document, "onreadystatechange", null );
		}
		XdEventObject.prototype.dispose.call(this);
	};
	XdDom.prototype._onDocumentReadyStateChange = function _onDocumentReadyStateChange()
	{
		if(document.readyState=="complete")
		{
			if(isDOMElement(document.body,"BODY")&&document.body.readyState=="complete")
			{
				if(isFunction(this._onBodyReady)) this._onBodyReady();
			}
			else
				this.setEvent(document.body,"onload",this._onBodyLoaded);
		}
	};
	XdDom.prototype._onBodyLoaded = function _onBodyLoaded()
	{
		if(isFunction(this._onBodyReady)) this._onBodyReady();
	};
	XdDom.prototype._onBodyReady = function _onBodyReady(){};
	XdDom.prototype._addDoms = function _addDoms(o)
	{
		if(!isArray(this._oDoms)) this._oDoms=[];
		if(!isDOMElement(o)) return-1;
		return this._oDoms.push(o)-1;
	};
	XdDom.prototype.getDoms = function getDoms(i)
	{
		i=toInt(i,-1);
		return (i>=0&&i<arrayLength(this._oDoms))?this._oDoms[i]:null;
	};
	XdDom.prototype._setDomChild = function _setDomChild(o)
	{
		if(!isDOMElement(o)) return false;
		this._oDomChild=o;
		return true;
	};
	XdDom.prototype.getDomChild = function getDomChild() { return this._oDomChild; };
	XdDom.prototype.getParent = function getParent(){ return this._oParent; };
	XdDom.prototype.hasParent = function hasParent(){ return isValidXdDom(this._oParent); };
	XdDom.prototype.getLevelIndex = function getLevelIndex()
	{
		//return this.hasParent()?this._oParent.getLevelIndex()+1:0;
		if(isValidXdDom(this._oParent))
			return this._oParent.getLevelIndex()+1;
		else
			return 0;
	};
	XdDom.prototype.indexOfParent = function indexOfParent()
	{
		//return this.hasParent()?this._oParent.getChildIndex(this):0;
		if(isValidXdDom(this._oParent))
			return this._oParent.getChildIndex(this);
		else
			return 0;
	};
	XdDom.prototype.childCount = function childCount(){return arrayLength(this._oChilds);};
	XdDom.prototype.hasChild = function hasChild(){ return this.childCount()>0; };
	XdDom.prototype.getChilds = function getChilds(i) { i=toInt(i,-1);	return (i>=0&&i<this.childCount())?this._oChilds[i]:null; };
	XdDom.prototype.getFirstChild = function getFirstChild()
	{
		//return this.getChilds(0);
		var cc = this.childCount();
		if(0<cc) return this._oChilds[0];
		else return null;
	};
	XdDom.prototype.getLastChild = function getLastChild()
	{
		//return this.getChilds(this.childCount()-1);
		var cc = this.childCount();
		if(0<cc) return this._oChilds[cc-1];
		else return null;
	};
	XdDom.prototype.getChildIndex = function getChildIndex(o) { return indexOfArray(this._oChilds,o); };
	XdDom.prototype.hasBrother = function hasBrother()
	{
		//return this.hasParent()&&this._oParent.childCount()>1;
		return isValidXdDom(this._oParent)&&this._oParent.childCount()>1;
	};
	XdDom.prototype.hasYoungBrother = function hasYoungBrother()
	{
		//return this.hasBrother()&&this.indexOfParent()<this._oParent.childCount()-1;
		if(!isValidXdDom(this._oParent)) return false;
		var li = this._oParent.childCount() - 1;
		if(0>=li) return false;
		return this._oParent._oChilds[li] != this;
	};
	XdDom.prototype.hasOldBrother = function hasOldBrother()
	{
		//return this.hasBrother()&&this.indexOfParent()>0;
		if(!isValidXdDom(this._oParent)) return false;
		if(this._oParent.childCount()<=1) return false;
		return this._oParent._oChilds[0] != this;
	};
	XdDom.prototype.getFirstBrother = function getFirstBrother()
	{
		//return (this.hasBrother())?( (this.indexOfParent()==0)?this._oParent.getChilds(1):this._oParent.getFirstChild() ):null;
		if(!isValidXdDom(this._oParent)) return null;
		if(this._oParent.childCount()<=1) return null;
		if(this._oParent._oChilds[0]==this)
			return this._oParent._oChilds[1];
		else
			return this._oParent._oChilds[0];
	};
	XdDom.prototype.getPreviousBrother = function getPreviousBrother()
	{
		//return (this.hasOldBrother())?this._oParent.getChilds(this.indexOfParent()-1):null;
		if(!isValidXdDom(this._oParent)||this._oParent.childCount()<=1) return null;
		var si = this._oParent.getChildIndex(this);
		if(0>=si) return null;
		return this._oParent._oChilds[si-1];
	};
	XdDom.prototype.getNextBrother = function getNextBrother()
	{
		//return (this.hasYoungBrother())?this._oParent.getChilds(this.indexOfParent()+1):null;
		if(!isValidXdDom(this._oParent)) return null;
		var li = this._oParent.childCount() - 1;
		if(0>=li) return null;
		var si = this._oParent.getChildIndex(this);
		if( si >= li ) return null;
		return this._oParent._oChilds[si+1];
	};
	XdDom.prototype.getNextRollBrother = function getNextRollBrother()
	{
		if(!isValidXdDom(this._oParent)) return null;
		var li = this._oParent.childCount() - 1;
		var si = this._oParent.getChildIndex(this);
		if(si==li) return this._oParent._oChilds[0];
		else return this._oParent._oChilds[si+1];
	};
	XdDom.prototype.getPreviousRollBrother = function getPreviousRollBrother()
	{
		if(!isValidXdDom(this._oParent)) return null;
		var si = this._oParent.getChildIndex(this);
		if(0>=si) return this._oParent._oChilds[this._oParent.childCount()-1];
		else return this._oParent._oChilds[si-1];
	};
	XdDom.prototype.getLastBrother = function getLastBrother()
	{
		//return (this.hasBrother())?( (this.indexOfParent()==this._oParent.childCount()-1)?this._oParent.getChilds(this.indexOfParent()-1):this._oParent.getLastChild() ):null;
		if(!isValidXdDom(this._oParent)) return null;
		var li = this._oParent.childCount() - 1;
		if(0>=li) return null;
		if(this._oParent._oChilds[li]==this)
			return this._oParent._oChilds[li-1];
		else
			return this._oParent._oChilds[li];
	};
	//得到家庭同辈成员数(自家兄弟数+1，包括自己，不包括表的堂的兄弟)
	XdDom.prototype.familyCount = function familyCount() { return isValidXdDom(this._oParent)?this._oParent.childCount():1; };
	//得到家庭第几辈祖先
	XdDom.prototype.getAncestor = function getAncestor(iLevel)
	{
		var r = this;
		var nl = Math.max(r.getLevelIndex(),0);
		var ii = Math.max(Math.min(toInt(iLevel,nl-1),nl),0);
		while ( isValidXdDom(r) && r.getLevelIndex() > ii ) r = r.getParent();
		return r;
	};
	//得到开山祖师爷
	XdDom.prototype.getRoot = function getRoot()
	{
		//return this.getAncestor(0);
		var r = this;
		while( isValidXdDom(r._oParent) ) r = r._oParent;
		return r;
	};
	//得到自家小辈总数，包括子孙后代，但不包括侄系
	XdDom.prototype.progenyCount = function progenyCount()
	{
		var ii = this.childCount();
		if(0>=ii) return 0;
		var ic = ii;
		for(var i=0; i<ic; i++)
		{
			var o=this._oChilds[i];
			if(isValidXdDom(o)) ii+=o.progenyCount();
		}
		return ii;
	};
	//得到家谱排序编号，注意：哥哥的子孙后代哪怕叫你伯伯也排在你前面
	XdDom.prototype.getAbsoluteIndex = function getAbsoluteIndex()
	{
		if(this.hasOldBrother())
		{
			var pb = this.getPreviousBrother();
			return pb.getAbsoluteIndex()+pb.progenyCount()+1;
		}
		else if(this.hasParent())
			return this._oParent.getAbsoluteIndex()+1;
		else return 0;
	};
	XdDom.prototype.getFirstDom = function getFirstDom()
	{
		if(arrayLength(this._oDoms)<=0)
			return null;
		else
		{
			for(var i=0; i<arrayLength(this._oDoms); i++)
				if(isDOMElement(this._oDoms[i])) return this._oDoms[i]
		}
	};
	//以__开头的函数均为private函数，_开头的为protect or friend函数，请慎用
	XdDom.prototype.__removeChild = function __removeChild(o)//删成功返回原索引否则-1
	{
		if(!isArray(this._oChilds))
			this._oChilds=[];
		var i=this._oChilds.indexOf(o);
		if(0<=i)
		{
			this._oChilds.removeAt(i);
			return i;
		}
		else
			return -1;
	};
	XdDom.prototype.__addChild = function __addChild(o)//返回插入后o的索引
	{
		if(!isArray(this._oChilds))
			this._oChilds = [];
		return this._oChilds.push(o)-1;
	};
	XdDom.prototype.__insertChild = function __insertChild(o,i)//返回插入后o的索引
	{
		if(!isArray(this._oChilds))
			this._oChilds = [];
		i = Math.max(toInt(i,0),0);
		if(i>=this._oChilds.length)
			return this._oChilds.push(o)-1;
		else
		{
			this._oChilds.splice(i,0,o);
			return i;
		}
	};
	XdDom.prototype.addChild = function addChild(o)
	{
		if(!isValidXdDom(o)||!this._canContain(o)||!o._canBeContained(this)) return -1;
		var i = this.__addChild(o);
		if(i<0) return i;
		if(0==i) this._scHasChild();
		o._oParent = this;
		o._scParent();
		if(0<i)
		{
			this._oChilds[i-1]._scHasYoungBrother();
			o._scHasOldBrother();
		}
		if(!isDOMElement(this._oDomChild)) return i;
		for(var j=0; j<arrayLength(o._oDoms); j++)
		{
			try	{	if(isDOMElement(o._oDoms[j])) this._oDomChild.appendChild(o._oDoms[j]); }
			catch(E) {}
			finally {continue;}
		}
		if(isFunction(this._onChildAdded))this._onChildAdded(o);
		return i;
	};
	XdDom.prototype.insertChild = function insertChild(o,i)
	{
		if(!isValidXdDom(o)||!this._canContain(o)||!o._canBeContained(this)) return-1;
		var i = this.__insertChild(o,i);
		var c = this.childCount();
		if(1==c) this._scHasChild();
		o._oParent = this;
		o._scParent();
		if(0<i)
		{
			if(i>=c-1) this._oChilds[i-1]._scHasYoungBrother();
			o._scHasOldBrother();
		}
		if(i<c-1)
		{
			o._scHasYoungBrother();
			if(0==i) this._oChilds[i+1]._scHasOldBrother();
		}
		if(isDOMElement(this._oDomChild))
		{
			//寻找插入后后面的XdDom对象的第一个Dom对象
			var beforeDom = null;
			if(i<c-1)
			{
				for(var j=i+1; j<c; j++)
				{
					var tmpDom = this._oChilds[j].getFirstDom();
					if(isValid(tmpDom))
					{
						beforeDom = tmpDom;
						break;
					}
				}
			}
			//寻找结束，该Dom对象用来当前的对的Dom对象的插入
			for(var j=0; j<arrayLength(o._oDoms); j++)
			{
				try	{	if(isDOMElement(o._oDoms[j])) this._oDomChild.insertBefore(o._oDoms[j], beforeDom); }
				catch(E) {}
				finally {continue;}
			}
		}
		if(isFunction(this._onChildInserted)) this._onChildInserted(o,i);
		return i;
	};
	XdDom.prototype.removeChild = function removeChild(o)
	{
		if(!isValidXdDom(o)) return false;
		var i = this.__removeChild(o);
		var c = this.childCount();
		if(0==c)this._scHasChild();
		o._oParent=null;
		o._scParent();
		if(0<i)
		{
			if(i==c) this._oChilds[i-1]._scHasYoungBrother();
			o._scHasOldBrother();
		}
		if(i<c)
		{
			if(0==i) this._oChilds[i]._scHasOldBrother();
			o._scHasYoungBrother();
		}
		if(isDOMElement(this._oDomChild))
		{
			for(var i=0; i<arrayLength(o._oDoms); i++)
				removeDomChild(o._oDoms[i]);
		}
		if(isFunction(this._onChildRemoved))this._onChildRemoved(o);
		return true;
	};
	XdDom.prototype.setParent = function setParent(o)
	{
		if(!isValidXdDom(o)||!this._canBeContained(o)||!o._canContain(this)) return false;
		var oSp = this._oParent;	//source parent
		var bSHasParent=bSHasOldBrother=bSHasYoungBrother=false;	//source hasParent, hasOldBrother, bSHasYoungBrother
		var bDHasOldBrother=false; //destination hasOldBrother
		//如果对象原来有父对象，改变原父对象及兄弟对象的状态并记下自己的原状态
		if(isValidXdDom(oSp))
		{
			bSHasParent = true;
			var i = oSp.__removeChild(this);
			var c = oSp.childCount();
			if(0==c)oSp._scHasChild();
			if(0<i)
			{
				bSHasOldBrother=true;
				if(i==c) oSp._oChilds[i-1]._scHasYoungBrother();
			}
			if(i<c)
			{
				bSHasYoungBrother=true;
				if(0==i) oSp._oChilds[i]._scHasOldBrother();
			}
		}
		
		//加入新父对象
		var i = o.__addChild(this);
		if(0==i) o._scHasChild();
		if(0<i)
		{
			bDHasOldBrother=true;
			o._oChilds[i-1]._scHasYoungBrother();
		}
		//如果自己有Dom对象则需同时改变Dom对象的所处位置
		if(arrayLength(this._oDoms)>0)
		{
			var bSParentHasDomChild = bSHasParent||isDOMNode(this.getFirstDom().parentNode);	//以前的父对象有否dom容器
			for(var i=0; i<arrayLength(this._oDoms); i++)
			{
				var bAppendSuccess = false;
				try
				{
					if(isDOMElement(this._oDoms[i]))
					{	//把自己的Dom对象加入它
						o._oDomChild.appendChild(this._oDoms[i]);
						bAppendSuccess=true;
					}
				}
				catch(E) {bAppendSuccess=false;}
				//如果没有加入新容器并且自己的Dom对象还在原父对象的Dom容器中，则移除
				if(!bAppendSuccess&&bSParentHasDomChild)
					removeDomChild(this._oDoms[i]);
			}
		}
		//根据前后状态的改变做出相应的改变
		this._oParent=o;
		if(!bSHasParent) this._scParent();
		if(bSHasOldBrother!=bDHasOldBrother) this._scHasOldBrother();
		if(bSHasYoungBrother)	this._scHasYoungBrother();
		if(bSHadParent&&isFunction(oSp._onChildRemoved)) oSp._onChildRemoved(this);
		if(isFunction(o._onChildAdded))o._onChildAdded(this);
	};
	
	//将本对象移到某对象之前, n为参照的XdDom对象
	//使用该方法与父对象insertChild本对象有本质的不同，
	//本方法可以使自己移到没有父对象的对象(n参数)前面，虽然因为没有父对象所以自身没有索引问题
	//但自身的DOM对象却可以移到参照对象的前面
	//如果参照对象有父对象，使用本方法与moveToPosition效果相同
	//n对象也可以直接是一个dom对象,那么本对象的parent将为空，但dom对象会插入到n的前面
	XdDom.prototype.moveToBefore = function moveToBefore(n)
	{
		if(isValidXdDom(n)&&isValidXdDom(n.getParent())&&this._canBeContained(n.getParent())&&n.getParent()._canContain(this))
			this.moveToPosition(n.getParent(),n.indexOfParent());
		else if(!isValidXdDom(n)&&!isDOMElement(n)||isValidXdDom(n.getParent()))
			return;
		var oSp = this._oParent;	//source parent
		var bSHasParent=bSHasOldBrother=bSHasYoungBrother=false;	//source hasParent, hasOldBrother, bSHasYoungBrother
		//如果对象原来有父对象，改变原父对象及兄弟对象的状态并记下自己的原状态
		if(isValidXdDom(oSp))
		{
			bSHasParent = true;
			var i = oSp.__removeChild(this);
			var c = oSp.childCount();
			if(0==c)oSp._scHasChild();
			if(0<i)
			{
				bSHasOldBrother=true;
				if(i==c) oSp._oChilds[i-1]._scHasYoungBrother();
			}
			if(i<c)
			{
				bSHasYoungBrother=true;
				if(0==i) oSp._oChilds[i]._scHasOldBrother();
			}
		}
		//如果自己有Dom对象则需同时改变Dom对象的所处位置
		if(arrayLength(this._oDoms)>0)
		{
			var beforeDom = null;
			if(isValidXdDom(n)&&!isValidXdDom(n.getParent()))
				beforeDom=n.getFirstDom();
			else if(isDOMElement(n))
				beforeDom=n;
			var bDParentHasDomChild = isDOMNode(beforeDom.parentNode);	//现在的父对象有否dom容器
			var bSParentHasDomChild = bSHasParent||isDOMNode(this.getFirstDom().parentNode);	//以前的父对象有否dom容器
			for(var i=0; i<arrayLength(this._oDoms); i++)
			{
				var bInsertSuccess = false;
				try
				{
					if(bDParentHasDomChild&&isDOMElement(this._oDoms[i]))
					{	//如果现在有父对象的Dom容器就把自己的Dom对象加入它
						beforeDom.parentNode.insertBefore(this._oDoms[i], beforeDom);
						bInsertSuccess=true;
					}
				}
				catch(E) {bInsertSuccess=false;}
				//如果没有加入新容器并且自己的Dom对象还在原父对象的Dom容器中，则移除
				if(!bInsertSuccess&&bSParentHasDomChild)
					removeDomChild(this._oDoms[i]);
			}
		}
		//根据前后状态的改变做出相应的改变
		this._oParent=null;
		if(bSHasParent) this._scParent();
		if(bSHasOldBrother) this._scHasOldBrother();
		if(bSHasYoungBrother)	this._scHasYoungBrother();
		if(bSHasParent&&isFunction(oSp._onChildRemoved)) oSp._onChildRemoved(this);
	};
	
	//将本对象移到指定父对象的指定位置
	XdDom.prototype.moveToPosition = function moveToPosition(o, i)
	{
		if(!isValidXdDom(o)||!this._canBeContained(o)||!o._canContain(this)) return false;
		var oSp = this._oParent;	//source parent
		var bSHasParent=bSHasOldBrother=bSHasYoungBrother=false;	//source hasParent, hasOldBrother, bSHasYoungBrother
		var bDHasOldBrother=bDHasYoungBrother=false; //destination hasOldBrother, bSHasYoungBrother
		//如果对象原来有父对象，改变原父对象及兄弟对象的状态并记下自己的原状态
		if(isValidXdDom(oSp))
		{
			bSHasParent = true;
			var i = oSp.__removeChild(this);
			var c = oSp.childCount();
			if(0==c)oSp._scHasChild();
			if(0<i)
			{
				bSHasOldBrother=true;
				if(i==c) oSp._oChilds[i-1]._scHasYoungBrother();
			}
			if(i<c)
			{
				bSHasYoungBrother=true;
				if(0==i) oSp._oChilds[i]._scHasOldBrother();
			}
		}
		//插入新父对象
		var i = o.__insertChild(this,i);
		var c = o.childCount();
		if(1==c) o._scHasChild();
		if(0<i)
		{
			bDHasOldBrother=true;
			if(i>=c-1) o._oChilds[i-1]._scHasYoungBrother();
		}
		if(i<c-1)
		{
			bDHasYoungBrother=true;
			if(0==i) o._oChilds[i+1]._scHasOldBrother();
		}
		//如果自己有Dom对象则需同时改变Dom对象的所处位置
		if(arrayLength(this._oDoms)>0)
		{
			var bSParentHasDomChild = bSHasParent||isDOMNode(this.getFirstDom().parentNode);	//以前的父对象有否dom容器
			//寻找插入后后面的XdDom对象的第一个Dom对象
			var beforeDom = null;
			if(i<c-1)
			{
				for(var j=i+1; j<c; j++)
				{
					var tmpDom = o._oChilds[j].getFirstDom();
					if(isValid(tmpDom))
					{
						beforeDom = tmpDom;
						break;
					}
				}
			}
			//寻找结束，该Dom对象用来当前的对的Dom对象的插入
			for(var j=0; j<arrayLength(this._oDoms); j++)
			{
				var bInsertSuccess = false;
				try
				{
					if(isDOMElement(this._oDoms[j]))
					{	//如果现在有父对象的Dom容器就把自己的Dom对象加入它
						o._oDomChild.insertBefore(this._oDoms[j], beforeDom);
						bInsertSuccess=true;
					}
				}
				catch(E) {bInsertSuccess=false;}
				//如果没有加入新容器并且自己的Dom对象还在原父对象的Dom容器中，则移除
				if(!bInsertSuccess&&bSParentHasDomChild)
					removeDomChild(this._oDoms[j]);
			}
		}
		//根据前后状态的改变做出相应的改变
		this._oParent=o;
		if(!bSHasParent) this._scParent();
		if(bSHasOldBrother!=bDHasOldBrother) this._scHasOldBrother();
		if(bSHasYoungBrother!=bDHasYoungBrother)	this._scHasYoungBrother();
		if(bSHasParent&&isFunction(oSp._onChildRemoved)) oSp._onChildRemoved(this);
		if(isFunction(o._onChildInserted))o._onChildInserted(this,i);
	};
	XdDom.prototype._canContain = function _canContain(o) { return true; };
	XdDom.prototype._canBeContained = function _canBeContained(o) { return true; };
	XdDom.prototype._scHasChild = function _scHasChild() { return; };
	XdDom.prototype._scParent = function _scParent() { return; };
	XdDom.prototype._scHasYoungBrother = function _scHasYoungBrother() { return; };
	XdDom.prototype._scHasOldBrother = function _scHasOldBrother() { return; };
	XdDom.prototype._onChildAdded = function _onChildAdded(o) { return; };
	XdDom.prototype._onChildInserted = function _onChildInserted(o,i) { return; };
	XdDom.prototype._onChildRemoved = function _onChildRemoved(o) { return; };
	XdDom.prototype.getLastTabIndex = function getLastTabIndex()
	{
		var cc=arrayLength(this._oChilds);
		if(cc<=0) return 0;
		for(var i=cc-1; i>=0; i--)
		{
			var o=this._oChilds[i];
			if(isFunction(o.getLastTabIndex))
			{
				var j=o.getLastTabIndex();
				if(isNumber(j) && j!=0 ) return j;
			}
		}
		if(isDOMElement(this._oDomChild)&&isNumber(this._oDomChild.tabIndex)&&this._oDomChild.tabIndex!=0)
			return this._oDomChild.tabIndex;
		else
		{
			var cc = arrayLength(this._oDoms);
			if(cc<=0) return 0;
			for(var i=cc-1; i>=0; i--)
			{
				var o=this._oDoms[i];
				if(isDOMElement(o)&&isNumber(o.tabIndex)&&o.tabIndex!=0)
					return o.tabIndex;
			}
		}
		return 0;
	};
	XdDom.prototype.getFirstTabIndex = function getFirstTabIndex()
	{
		var cc = arrayLength(this._oDoms);
		if(cc<=0) return 0;
		for(var i=0; i<cc; i++)
		{
			var o=this._oDoms[i];
			if(isDOMElement(o)&&isNumber(o.tabIndex)&&o.tabIndex!=0)
				return o.tabIndex;
		}
		if(isDOMElement(this._oDomChild)&&isNumber(this._oDomChild.tabIndex)&&this._oDomChild.tabIndex!=0)
			return this._oDomChild.tabIndex;
		var cc=arrayLength(this._oChilds);
		if(cc<=0) return 0;
		for(var i=0; i<cc; i++)
		{
			var o=this._oChilds[i];
			if(isFunction(o.getLastTabIndex))
			{
				var j=o.getLastTabIndex();
				if(isNumber(j) && j!=0 ) return j;
			}
		}
		return 0;
	};
	XdDom.prototype.setFirstTabIndex = function setFirstTabIndex(i)
	{
		i=Math.min(Math.max(toInt(i,0),-32767),32767);
		if(isValid(this._oDoms[0]))	this._oDoms[0].tabIndex = i;
	};
//------------------------------------------------------------------------------------------------/
function createDom(p,sTag)
{
	var oDom=document.createElement(sTag);
	oDom.unselectable=true;
	try{p.appendChild(oDom);}catch(E){}
	return oDom;
};
function createElementTable(p)
{
	var oTb = createDom(p,"TABLE");
	oTb.border=0;
	oTb.cellPadding=0;
	oTb.cellSpacing=0;
	return oTb;
};
function getTBodyFromTable(t)
{
	if(!isDOMElement(t, "TABLE")) return;
	if(isObject(t.tBodies))
	{
		for(var i=0; i<t.tBodies.length; i++) {
			var oTBody = t.tBodies.item(i);
			if(isDOMElement(oTBody, "TBODY"))
			{
				oTBody.unselectable = true;
				return oTBody;
			}
		}
	}
	var oTBody = createDom(t,"TBODY");
	return oTBody;
};
function createElementTr(p){return createDom(p,"TR");};
function createElementTd(p){return createDom(p,"TD");};
function createElementImg(p)
{
	var oImg = createDom(p,"IMG");
	oImg.alt = ""
	return oImg;
};
function createElementDiv(p){return createDom(p,"DIV");};
function createElementSelect(p){return createDom(p,"SELECT");};
function createElementSpan(p){return createDom(p,"SPAN");};
function createElementButton(p){return createDom(p,"BUTTON");};
function checkBodyReady()
{
	if(isDOMNode(document,9)&&isDOMElement(document.body,"BODY"))
		return document.body.readyState=="complete";
	else
		return false;
};
function getTextWidth(s,i)
{
	if(isValid(document)&&isValid(document.body))
	{
		var o;
		if(!isValid(document.all.oTmpDivForJScriptFunctiongetTextWidth))
		{
			o=createElementDiv(document.body);
			o.id="oTmpDivForJScriptFunctiongetTextWidth";
		}
		else
			o=document.all.oTmpDivForJScriptFunctiongetTextWidth;
		o.runtimeStyle.position="absolute";
		//o.runtimeStyle.display="none";
		o.runtimeStyle.visibility="hidden";
		o.runtimeStyle.fontSize=safeToString(i)+"px";
		o.innerHTML = s;
		return o.offsetWidth;
	}
	return 0;
};
function getActiveXObject(sType)
{
	var o=null;
	for(var i=0;i<4;i++)
	{
		var sServer="";
		switch(i)
		{
			case 0: sServer="Msxml3";break;
			case 1: sServer="Msxml2";break;
			case 2: sServer="Msxml";break;
			default: sServer="Microsoft";break;
		}
		for(var j=0;j<6;j++)
		{
			var sVersion="";
			switch(j)
			{
				case 0: sVersion=".4.0";break;
				case 1: sVersion=".3.0";break;
				case 2: sVersion=".2.6";break;
				case 3: sVersion=".1.0";break;
				case 4: sVersion=".1";break;
				default: sVersion="";break;
			}
			try{o=new ActiveXObject(sServer+"."+safeToString(sType).trim()+sVersion);return o;}
			catch(e){}
		}	
	}
	return o;
};
function getXmlDoc()
{
	return getActiveXObject("DOMDocument");
};
function getXmlHttp()
{
	return getActiveXObject("XMLHTTP");
};
//************************************************************************************************/
/*类 XdXMLHttp */
/*
XMLHTTP.readyState Value & Mean
(0) UNINITIALIZED The object has been created but has not been initialized because the open method has not been called. 
(1) LOADING The object has been created but the send method has not been called. 
(2) LOADED The send method has been called and the status and headers are available, but the response is not yet available. 
(3) INTERACTIVE Some data has been received. You can call responseBody and responseText to get the current partial results. 
(4) COMPLETED All the data has been received, and the complete data is available in responseBody and responseText. 
*/
	function XdXMLHttp()
	{
		var o =getXmlHttp();
		if(!isValid(o)) return null;
		this.base = XdObject;
		this.base();
		this._xmlhttp = o;
		this._sText = "";
	};
	XdXMLHttp.prototype=new XdObject;
	XdXMLHttp.prototype._className="XdXMLHttp";
	XdXMLHttp.prototype.dispose=function dispose()
	{
		if(isValid(XdXMLHttp.prototype)&&XdXMLHttp.prototype!=this)
		{
			try{this._xmlhttp.onreadystatechange=null;}catch(E){}
			try{this._xmlhttp = null;}catch(E){}
		}
		XdObject.prototype.dispose.call(this);
	};
	XdXMLHttp.prototype.OnReadyStateChange = function OnReadyStateChange(iReadyState){};
	XdXMLHttp.prototype._ReadyStateChange = function _ReadyStateChange()
	{
		var iReadyState=this._xmlhttp.readyState;
		if(isFunction(this.OnReadyStateChange))
			this.OnReadyStateChange(iReadyState);
		if(iReadyState == 4)
			this._ResponseComplete();
	};
	XdXMLHttp.prototype.OnResponseComplete = function OnResponseComplete(){};
	XdXMLHttp.prototype._OnResponseComplete = function _OnResponseComplete()
	{
		this._sText=this._xmlhttp.responseText;
	};
	XdXMLHttp.prototype._ResponseComplete = function _ResponseComplete()
	{
		if(isFunction(this.OnResponseComplete))
		{
			this._OnResponseComplete();
			this.OnResponseComplete();
		}
	};
	XdXMLHttp.prototype.postText = function postText(sUrl, str)
	{
		this._xmlhttp.Open("POST", safeToString(sUrl), true);
		this._xmlhttp.onreadystatechange= new Function( "XdObject.getGlobalObject(\"" + this._uniqueID + "\")._ReadyStateChange();" );
		this._xmlhttp.Send(str);
	};
	XdXMLHttp.prototype.getResponseText = function getResponseText()
	{
		return this._sText;
	};
//------------------------------------------------------------------------------------------------/
//************************************************************************************************/
/*类 XdDialogHelper */
	function XdDialogHelper()
	{
		this.base = XdEventObject;
		this.base();
		//document.writeln( "<OBJECT ID='DialogHelper' CLASSID='clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b' WIDTH='0px' HEIGHT='0px'></OBJECT>" );
		//var oDlgHelper = document.all.DialogHelper;
		this._oDlgHelper = document.createElement("OBJECT");
		this._oDlgHelper.classid = "clsid:3050f819-98b5-11cf-bb82-00aa00bdce0b";
		this._oDlgHelper.runtimeStyle.pixelWidth = 0;
		this._oDlgHelper.runtimeStyle.pixelHeight = 0;
		this._oBinds=[];
		this.setEvent( document, "onreadystatechange", this._onDocumentReadyStateChange );
	};
	XdDialogHelper.prototype=new XdEventObject;
	XdDialogHelper.prototype._className="XdDialogHelper";
	XdDialogHelper.prototype._onDocumentReadyStateChange=function _onDocumentReadyStateChange()
	{
		if(document.readyState=="complete"||isValid(document.body))
		{
			document.body.appendChild(this._oDlgHelper);
			if(!isArray(this._oBinds)) return;
			for(var i=0;i<this._oBinds.length;i++)
			{
				if(isSelfObject(this._oBinds[i],XdDialogHelperBind)&&isFunction(this._oBinds[i].refresh))
					this._oBinds[i].refresh();
			}
		}
	};
	XdDialogHelper.prototype.addBinds=function addBinds(o)
	{
		if(!isArray(this._oBinds))this._oBinds=[];
		if(isSelfObject(o,XdDialogHelperBind)&&isFunction(o.refresh)&&this._oBinds.indexOf(o)<0)
			this._oBinds.push(o);
	};
	XdDialogHelper.prototype.removeBinds=function removeBinds(o)
	{
		if(!isArray(this._oBinds))this._oBinds=[];
		this._oBinds.remove(o);
	};
//------------------------------------------------------------------------------------------------/
//************************************************************************************************/
/*类 XdDialogHelperBind */
	function XdDialogHelperBind(oXdDialogHelper)
	{
		this.base = XdDom;
		this.base();
		this._oBindDialogHelper=oXdDialogHelper;
		this._items=[];
		this._oSelect = createElementSelect();
		this._oDoms=[this._oSelect];
		this._oDomChild=this._oSelect;
		this.setEvent(this._oSelect,"onchange",this._onChange);
		if(isSelfObject(oXdDialogHelper,XdDialogHelper))
			oXdDialogHelper.addBinds(this);
	};
	XdDialogHelperBind.prototype=new XdDom;
	XdDialogHelperBind.prototype._className="XdDialogHelperBind";
	XdDialogHelperBind.prototype.refresh=function refresh(){};
	XdDialogHelperBind.prototype._onChange=function _onChange()
	{
		if(isFunction(this.onSelect))
		{
			var i=this._oSelect.selectedIndex;
			var o=this._oSelect.options[i];
			this.onSelect(o.value,o.innerText,i);
		}
	};
	XdDialogHelperBind.prototype.onSelect=function onSelect(value,text,index){};
//------------------------------------------------------------------------------------------------/
//************************************************************************************************/
/*类 XdClientFontList */
	function XdClientFontList(oXdDialogHelper)
	{
		this.base = XdDialogHelperBind;
		this.base(oXdDialogHelper);
		this._oSelect.title = (iscn())?"字体":"Font";
	};
	XdClientFontList.prototype=new XdDialogHelperBind;
	XdClientFontList.prototype._className="XdClientFontList";
	XdClientFontList.prototype.refresh=function refresh()
	{
		var oOptions = this._oSelect.options;
		//while(oOptions.length>0)oOptions.remove(0);
		this._items=[];
		var iCount = this._oBindDialogHelper._oDlgHelper.fonts.count;
		if(iCount<=0) return;
		for(var i=1; i<iCount; i++)
		{
			var oOption = document.createElement("OPTION");
			oOptions.add(oOption);
			var s=this._oBindDialogHelper._oDlgHelper.fonts(i);
			this._items.push(s);
			oOption.innerText = s;
			oOption.value = s;
			if(i==1) oOption.selected = true;
		}
	};
	XdClientFontList.prototype.setFontName=function setFontName(s)
	{
		for(var i=0;i<this._oSelect.options.length;i++)
		{
			if(safeToString(s).equalText(this._oSelect.options.item(i).value))
				this._oSelect.options.item(i).selected=true;
		}
	};
//------------------------------------------------------------------------------------------------/
//************************************************************************************************/
/*类 XdClientFormatBlockList */
	function XdClientFormatBlockList(oXdDialogHelper)
	{
		this.base = XdDialogHelperBind;
		this.base(oXdDialogHelper);
		this._oSelect.title = (iscn())?"样式":"Font Style";
	};
	XdClientFormatBlockList.prototype=new XdDialogHelperBind;
	XdClientFormatBlockList.prototype._className="XdClientFormatBlockList";
	XdClientFormatBlockList.prototype.refresh=function refresh()
	{
		var oOptions = this._oSelect.options;
		while(oOptions.length>0)oOptions.remove(0);
		this._items=[];
		var iCount = this._oBindDialogHelper._oDlgHelper.blockFormats.count;
		if(iCount<=0) return;
		for(var i=1; i<iCount; i++)
		{
			var oOption = document.createElement("OPTION");
			oOptions.add(oOption);
			var s=this._oBindDialogHelper._oDlgHelper.blockFormats(i);
			this._items.push(s);
			oOption.innerText = s;
			oOption.value = s;
			if(i==1) oOption.selected = true;
		}
	};
	XdClientFormatBlockList.prototype.setFormatBlock=function setFormatBlock(s)
	{
		for(var i=0;i<this._oSelect.options.length;i++)
		{
			if(safeToString(s).equalText(this._oSelect.options.item(i).innerText))
				this._oSelect.options.item(i).selected=true;
		}
	};
//------------------------------------------------------------------------------------------------/
//************************************************************************************************/
/*类 XdFontSizeList */
	function XdFontSizeList()
	{
		this.base = XdDom;
		this.base();
		this._items=[1,2,3,4,5,6,7];
		this._oSelect = createElementSelect();
		this._oSelect.title = (iscn())?"字号":"Font Size";
		this._oDoms=[this._oSelect];
		this._oDomChild=this._oSelect;
		this.refresh();
		this.setEvent(this._oSelect,"onchange",this._onChange);
	};
	XdFontSizeList.prototype=new XdDom;
	XdFontSizeList.prototype._className="XdFontSizeList";
	XdFontSizeList.prototype.refresh=function refresh()
	{
		var oOptions = this._oSelect.options;
		while(oOptions.length>0)oOptions.remove(0);
		for(var i=0; i<this._items.length; i++)
		{
			var oOption = document.createElement("OPTION");
			oOptions.add(oOption);
			var s=this._items[i]
			oOption.innerText = s;
			oOption.value = i+1;
			if(i==3) oOption.selected = true;
		}
	};
	XdFontSizeList.prototype._onChange=function _onChange()
	{
		if(isFunction(this.onSelect))
		{
			var i=this._oSelect.selectedIndex;
			var o=this._oSelect.options[i];
			this.onSelect(o.value,o.innerText,i);
		}
	};
	XdFontSizeList.prototype.onSelect=function onSelect(value,text,index){};
	XdFontSizeList.prototype.setFontSize=function setFontSize(s)
	{
		for(var i=0;i<this._oSelect.options.length;i++)
		{
			if(safeToString(s).equalText(this._oSelect.options.item(i).value))
				this._oSelect.options.item(i).selected=true;
		}
	};
//------------------------------------------------------------------------------------------------/
function colorValueToString(v)
{
	v = toInt(v).toString(16);
	if (v.length < 6)
	{
	  var sTempString = "000000".substring(0,6-v.length);
	  v = sTempString.concat(v);
	}
  return v;
};
function colorStringToValue(s)
{
	s = safeToString(s).trim();
	if (s.length < 6)
	{
	  var sTempString = "000000".substring(0,6-s.length);
	  s = sTempString.concat(s);
	}
	s="0x".concat( s.substring(4,2),s.substring(2,2),s.substring(0,2));
	s = toInt(s,0);
  return s;
};
function getHtmlInnerTexts(sHtml)
{
	return safeToString(sHtml).split(/(<\/{0,1}[A-Za-z]+[^<>]*>)/ig);
};
function addHtmlInnerTextsTag(sHtml,sTagHead,sTagFoot)
{
	sHtml=safeToString(sHtml);
	sTagHead=safeToString(sTagHead);
	sTagFoot=safeToString(sTagFoot);
	var a=new Array();
	while(isValid(sHtml.match(/(<\/{0,1}[A-Za-z]+[^<>]*>)/ig)))
	{
		a.push([RegExp.rightContext,"text"]);
		a.push([RegExp.lastMatch,"html"]);
		sHtml = RegExp.leftContext;
	}
	a.push([sHtml,"text"]);
	a.reverse();
	var r="";
	for(var i=0;i<a.length;i++)
	{
		if(a[i][1]=="text")
			r=r.concat(sTagHead,a[i][0],sTagFoot);
		else
			r=r.concat(a[i][0])
	}
	return r;
};
function parseBookmark(s)
{
	s=safeToString(s).trim();
	var sClean=s.replace("#","").trim();
	if(!sClean.equalText(s))
		return ["#",sClean];
	else
		return ["",sClean];
};
function parseLinkStr(s)
{
	s=safeToString(s).trim();
	var i=0;
	var sClean=s.replace(/(file:\/\/|ftp:\/\/|gopher:\/\/|http:\/\/|https:\/\/|mailto:|news:|telnet:|wais:)/ig,"").trim();
	if(!sClean.equalText(s))
	{
		var sHead=RegExp.$1.toLowerCase();
		switch(sHead)
		{
			case "file://":		i=1;	break;
			case "ftp://":		i=2;	break;
			case "gopher://":	i=3;	break;
			case "http://":		i=4;	break;
			case "https://":	i=5;	break;
			case "mailto:":		i=6;	break;
			case "news:":		i=7;	break;
			case "telnet:":		i=8;	break;
			case "wais:":		i=9;	break;
		}
		s=sHead+sClean;
	}else if(sClean.isEmpty()){ s="http://";i=4; }
	return [i,sClean,s];
};
function createLink(sInit)
{
	var sCharset=safeToString(getMLMapping()).toLowerCase();
	if(sCharset!="en"&&sCharset!="tw")sCharset="cn";
	var sFeatures="dialogWidth:460px;dialogHeight:134px;center:yes;dialogHide:yes;edge:raised;help:no;resizable:no;scroll:no;status:no;unadorned:no;";
	var v=window.showModalDialog("createlink"+sCharset+".htm",sInit,sFeatures);
	if(isValid(v)){ return [v[2],v[1]]; }
	else return null;
};
function createBookmark(sInitHref,sInitName,aryAnchors)
{
	var sCharset=safeToString(getMLMapping()).toLowerCase();
	if(sCharset!="en"&&sCharset!="tw")sCharset="cn";
	var sFeatures="dialogWidth:460px;dialogHeight:134px;center:yes;dialogHide:yes;edge:raised;help:no;resizable:no;scroll:no;status:no;unadorned:no;";
	return window.showModalDialog("createbookmark"+sCharset+".htm",[sInitHref,sInitName,aryAnchors],sFeatures);
};