//==============================
//====== 定义通用函数开始 ======
//==============================
//格式化字符串
function fs(runCode,c)
	{
		switch (runCode) {
			case 0:		//调用方式：fs(0,c)，将含数字的字符串用parseInt函数格式化为≥0的整数，如果字符串不能解析为数字或者解析为负数，则格式化为0
				var b=0;
					b=parseInt(c);
					if(isNaN(b)){b=0;}
					if(b<0){b=0;}
					return b;
			break;

			case 1:		//调用方式：fs(1,c)，将在线编辑器里的字符串进行优化
				//去除<br></p>中的<br>
				var str=arguments[1];
				var re=/<br><\/p>/ig;
				str=str.replace(re,'</p>');
				re=/(<[^>]+?)( _[a-z]+="[0-9]+")/ig;
				str=str.replace(re,'$1');
				return str;
			break;

			case 2:		//调用方式：fs(2,c)，将c格式化为数字，如果不能解析为数字，则格式化为0
				var numNumber=parseFloat(arguments[1]);
				if(isNaN(numNumber)){return 0;}else{return numNumber;}
			break;

			case 3:		//调用方式：fs(3,c)，返回c右边点后的内容
				var re=/\.([^.]*)$/i;
				var arr=c.match(re);
				return arr ? arr[1].toLowerCase() : '';
			break;

			default:
		}
		return null;
	}

//===============================
//====== 定义Prototype开始 ======
//===============================

String.prototype.trim = function()
	{
		return this.replace(/(^\s*)|(\s*$)/g,"");
	}

String.prototype.is=function(n)
	{
		switch (n) {
			case 0:		//是否大于等于0的正整数
				var re=/^[0-9.]+$/ig,c=0;
				if(this.match(re)==null){return false;}
				c=parseInt(this);
				if(c!=this || c<0){return false;}else{return true;}
			break;

			case 1:		//是否是WEB图像文件（扩展名为：jpeg、jpg、gif、png、bmp）
				var re=/\.(jpeg|jpg|gif|png|bmp)$/ig;
				return this.match(re)==null ? false : true;
			break;

			case 2:		//是否是大于0的数字
				var re=/^\+?([0-9]+\.)?[0-9]+$/ig;
				if(this.match(re)==null){return false;}
				var a=parseFloat(this);
				if(isNaN(a)){return false;}
				if(a<=0){return false;}
				return true;
			break;

			case 3:		//是否是大于等于0的数字
				var re=/^\+?([0-9]+\.)?[0-9]+$/ig;
				if(this.match(re)==null){return false;}
				var a=parseFloat(this);
				if(isNaN(a)){return false;}
				if(a<0){return false;}
				return true;
			break;
			case 5:		//是否是电子邮件地址
				var re=/^[^\s@]+@[^\s@]{4,}$/ig;
				if(this.match(re)==null){return false;}
				return true;
			break;
		}
		return null;
	}

String.prototype.test=function(dataArray,runCode)		//判断某格式化字符串中是否包含c
	{
		switch (runCode) {
		case 0:				//String为由某个字符隔开的字符串，比如“a'b'c”，判断某字符串是否在String中，调用方式：a.test(Array(c,'"'),0)，此时返回true或false
			var c=dataArray[0],g=encodeURIComponent(dataArray[1]),d=encodeURIComponent(this);

			c=encodeURIComponent(c);

			var objReg=new RegExp('(^|'+g+')'+c+'('+g+'|$)','i');

			return objReg.test(d);
			break;
		}
		return null;
	}

String.prototype.fm=function(runCode,dataArray)	//按某种方式格式化字符串
	{
		switch (runCode) {
			case 0:			//runCode=0，调用方法：itClientName.value.fm(Array('b',3),0)，比如：将“a”格式化为“bba”
				var c=dataArray[0],n=dataArray[1],a=this;
				if(c.length==0){return a;}
				while(a.length<n){
					a=c+a;
				}
				return a;
				break;
			case 1:			//返回以K计的文件尺寸；
				if(this.is(0)==false){return this;}
				return Math.round(parseInt(this)/1000);
			break;
			case 2:			//如果String是文件名，则返回扩展名，如果没有，则返回''；
				var re=/\.([\s\S]*?)$/i;
				var cArray=this.match(re);
				if(cArray){return cArray[1];}else{return '';}
			break;
			case 3:			//将类似１２的字符更换为12；
				var c=this;
				var arr=new Array('１','２','３','４','５','６','７','８','９','０');
				var arr1=new Array('1','2','3','4','5','6','7','8','9','0');
				for (var i=0; i<arr.length; i++) {
					c=c.replace(arr[i],arr1[i]);
				}
				return c;
			break;
		}
		return null;
	}

if(window.Node)		//设置Node
	{
		Node.prototype.innerText=function()
			{
				if(Node.hasChildNodes()==false){return null;}
				var a=Node.childNodes,c='';
				for (var i=0; i<a.length; i++) {
					if(a.nodeType==3){c+=a.nodeValue;alert(a.nodeValue);}
				}
				return c;
			}
		Node.prototype.swapNode=function(Node){	// 交换节点
			var nextSibling=this.nextSibling;
			var parentNode=this.parentNode;
			Node.parentNode.replaceChild(this,Node);
			parentNode.insertBefore(Node,nextSibling);
		}
		//点击
		Node.prototype.click=function ()
			{
				var evt = document.createEvent("MouseEvents");
				evt.initMouseEvent("click", true, true, window,0, 0, 0, 0, 0, false, false, false, false, 0, null);
				this.dispatchEvent(evt);
			}
	}

//=========================
//====== 定义Dom开始 ======
//=========================

//====== 定义Dom扩展属性 ======
function aLeft(d)
	{
		var a=d,b=0;
		while (a) {
			if(a.offsetLeft){
				b=b+a.offsetLeft;
			}
			a=a.offsetParent;
		}
		return b;
	}
function aLeftToBody(d)
	{
		var a=d,b=0;
		while (a && a.tagName!='BODY' && a.tagName!='body') {
			if(a.offsetLeft){
				b=b+a.offsetLeft;
			}
			a=a.offsetParent;
		}
		return b;
	}
function aRight(a)
	{
		return aLeft(a)+a.offsetWidth;
	}
function aTop(d)
	{
		var a=d,b=0;
		while (a) {
			if(a.offsetTop){
				b=b+a.offsetTop;
			}
			a=a.offsetParent;
		}
		return b;
	}
function aBottom(a)
	{
		return aTop(a)+a.offsetHeight;
	}
function getStyle(a,styleName)	//获得currentStyle的内容
	{
		if(document.all){
			return a.currentStyle.getAttribute(styleName,0);
		}
		else {
			var re=/([A-Z]+)/g;
			var c=styleName;
			if(c.match(re)!=null){
				c=c.replace(re,'-$1');
				c=c.toLowerCase();
			}
			return window.getComputedStyle(a,'').getPropertyValue(c);
		}
	}
function htEditorGetZIndex(b)	//获得b对象的子对象中最大的z-index
	{
		var zIndex=0,curIndex=0,cnNode=null;
		for (var i=0; i<b.childNodes.length; i++) {
			cnNode=b.childNodes[i];
			if(cnNode.nodeType==1){
				curIndex=fs(0,$(cnNode).getStyle('zIndex'));
				zIndex=curIndex>zIndex ? curIndex : zIndex;
			}
		}
		return zIndex;
	}
function childrenByTagName(a,tagName)	//返回a对象第一级子对象中tagName的数组
	{
		var arr=new Array(),b;
		if(a.hasChildNodes()==false){return arr;}
		for (var i=0; i<a.childNodes.length; i++) {
			b=a.childNodes[i];
			if(b.nodeType==1){
				if(b.tagName.toLowerCase()==tagName){arr.push($(b));}
			}
		}
		return arr;
	}
//返回某对象所包含的文本内容
function inText(a)
	{
		if(document.all){return a.innerText;}
		else{
			var c=a.innerHTML;
			var re=/<[0-9a-z]+[\s\S]*?>/ig;
			c=c.replace(re,'');
			var re=/<\/[0-9a-z]+>/ig;
			c=c.replace(re,'');
			return c;
		}
	}
//向某对象插入新的文本，这会替换该对象所有子对象，包括原有文本
function setText(a,c)
	{
		while(a.hasChildNodes()){
			a.removeChild(a.firstChild);
		}
		var oText=document.createTextNode(c);
		a.appendChild(oText);
	}
//返回某对象的左右边框宽度＋左右padding宽度＋左右margin宽度
function propertyWidth(a)
	{
		var n=fs(0,a.getStyle('borderLeftWidth'));
		n=n+fs(0,a.getStyle('borderRightWidth'));
		n=n+fs(0,a.getStyle('paddingLeft'));
		n=n+fs(0,a.getStyle('paddingRight'));
		n=n+fs(0,a.getStyle('marginLeft'));
		n=n+fs(0,a.getStyle('marginRight'));
		return n;
	}
//返回某对象的上下边框宽度＋上下padding宽度＋上下margin宽度
function propertyHeight(a)
	{
		var n=fs(0,a.getStyle('borderTopWidth'));
		n=n+fs(0,a.getStyle('borderBottomWidth'));
		n=n+fs(0,a.getStyle('paddingTop'));
		n=n+fs(0,a.getStyle('paddingBottom'));
		n=n+fs(0,a.getStyle('marginTop'));
		n=n+fs(0,a.getStyle('marginBottom'));
		return n;
	}
//返回某对象的父对象的className为特定值的对象
function parentClassName(d,cName)
	{
		var a=d,strName;
		while (a) {
			a=a.parentNode;
			if(a){
				strName=document.all ? a.className :a.getAttribute('class',0);
				if(strName==cName){return a;}
			}
		}
		return null;
	}
//返回某对象的父对象中，tagName为特定值的最近的父对象，没有则返回null
function parentByTagName(a,tagName)
	{
		var c=tagName.toLowerCase();
		var d=a;
		while (d) {
			d=d.parentNode;
			if(d.tagName.toLowerCase()==c){
				return d;
			}
		}
		return null;
	}

//返回某对象的tagName为特定值，className为特定值的对象数组
function childClassName(a,tagName,cName)
	{
		var arr=new Array();
		var oElements=a.getElementsByTagName(tagName);
		if(oElements){
			for (var i=0; i<oElements.length; i++) {
				var strName=document.all ? oElements[i].className : oElements[i].getAttribute('class',0);
				if(strName==cName){arr.push(oElements[i]);}
			}
		}
		return arr;
	}
//返回某对象的tagName为特定值，className为特定值的对象数组中的第一个对象
function childClassNameFirst(a,tagName,cName)
	{
		var arr=childClassName(a,tagName,cName);
		if(arr.length>0){return arr[0]}else{return null;}
	}

//调用方式：a.childBy(tagName,type,name)，返回某对象的子对象中，tagName、type、name（区分大小写）为指定值的第一个子对象，如果没有，则返回null
function childBy(a)
	{
		var tagName=arguments.length>=2 ? arguments[1].toLowerCase() : null;
		var type=arguments.length>=3 ? arguments[2].toLowerCase() : null;
		var name=arguments.length>=4 ? arguments[3] : null;
		var b=null;
		var bln=false;
		if(a.hasChildNodes()){
			for (var i=0; i<a.childNodes.length; i++) {
				b=a.childNodes[i];
				if(b.nodeType==1){
					bln=true;
					//测试tagName
					if(tagName!=null){
						if(b.tagName){
							if(b.tagName.toLowerCase()!=tagName){
								bln=false
							}
						}
						else{
							bln=false;
						}
					}
					//测试type
					if(bln && type!=null){
						var c=b.getAttribute('type',0);
						if(c!=null){
							if(c.toLowerCase()!=type){bln=false;}
						}
						else {
							bln=false;
						}
					}
					//测试name
					if(bln && name!=null){
						var c=b.getAttribute('name',0);
						if(c!=null){
							if(c!=name){bln=false;}
						}
						else {
							bln=false;
						}
					}
					//根据以上测试结果决定是否返回对象
					if(bln){return $(b);}
				}
			}
		}
		return null;
	}
//调用方式：a.childNodeBy(nodeName)，返回某对象的子对象中，nodeName为指定值的第一个子对象，如果没有，则返回null
function childNodeBy(a)
	{
		var nodeName=arguments.length>=2 ? arguments[1].toLowerCase() : null;
		//var type=arguments.length>=3 ? arguments[2].toLowerCase() : null;
		//var name=arguments.length>=4 ? arguments[3] : null;
		var b=null;
		var bln=false;
		if(a.hasChildNodes()){
			for (var i=0; i<a.childNodes.length; i++) {
				b=a.childNodes[i];
				if(b.nodeType==1){
					bln=true;
					//测试tagName
					if(tagName!=null){
						if(b.tagName){
							if(b.tagName.toLowerCase()!=tagName){
								bln=false
							}
						}
						else{
							bln=false;
						}
					}
					//测试type
					if(bln && type!=null){
						var c=b.getAttribute('type',0);
						if(c!=null){
							if(c.toLowerCase()!=type){bln=false;}
						}
						else {
							bln=false;
						}
					}
					//测试name
					if(bln && name!=null){
						var c=b.getAttribute('name',0);
						if(c!=null){
							if(c!=name){bln=false;}
						}
						else {
							bln=false;
						}
					}
					//根据以上测试结果决定是否返回对象
					if(bln){return b;}
				}
			}
		}
		return null;
	}

//调用方式：a.childrenBy(id(区分大小写),tagName,type,name(区分大小写),className)，返回某对象的子对象（包含子对象的子对象）中，符合要求的子对象，未定义的参数赋值为null
//返回值类型为数组，数组的项为找到的子对象；如果没有，则返回空长度为0的空数组
function childrenBy(a,id,tagName,type,name,className)
	{
		//定义需要返回的对象数组
		var arrNodes=new Array();

		//开始查找
		__childrenBySub(a,id,tagName,type,name,className,arrNodes);

		return arrNodes;
	}
	//查找对象
	function __childrenBySub(a,id,tagName,type,name,className,arrNodes)
		{
			var oNode=null,blnID=null,blnTagName=null,blnType=null,blnName=null,blnClassName=null,c=null;

			if(a.hasChildNodes()==false){return;}

			for (var i=0, len=a.childNodes.length; i<len; i++) {
				oNode=a.childNodes[i];
				//如果该对象不是Element，则进行下一个循环
				if(oNode.nodeType!=1){continue;}

				//确定id是否符合要求
				blnID=false;
				if(id==null){
					blnID=true;
				}
				else if(id==oNode.getAttribute('id',0)){
					blnID=true;
				}

				//确定tagName是否符合要求
				blnTagName=false;
				if(tagName==null){
					blnTagName=true;
				}
				else if(tagName.toLowerCase()==oNode.tagName.toLowerCase()){
					blnTagName=true;
				}

				//确定type是否符合要求
				blnType=false;
				if(type==null){
					blnType=true;
				}
				else{
					c=oNode.getAttribute('type',0);
					if(c!=null){
						if(type.toLowerCase()==c.toLowerCase()){
							blnType=true;
						}
					}
				}

				//确定name是否符合要求
				blnName=false;
				if(name==null){
					blnName=true;
				}
				else{
					c=oNode.getAttribute('name',0);
					if(c!=null){
						if(name==c){
							blnName=true;
						}
					}
				}

				//确定claaName是否符合要求
				blnClassName=false;
				if(className==null){
					blnClassName=true;
				}
				else{
					c=oNode.getAttribute('className',0)==null ? oNode.getAttribute('class',0) : oNode.getAttribute('className',0);
					if(c!=null){
						if(className==c){
							blnClassName=true;
						}
					}
				}

				//如果符合要求，则加入到返回的数组中
				if(blnID && blnTagName && blnType && blnName && blnClassName){
					arrNodes.push($(oNode));
				}

				//如果该对象有子对象，则在子对象中查找
				if(oNode.hasChildNodes()){
					__childrenBySub(oNode,id,tagName,type,name,className,arrNodes);
				}

			}
		}

//====== 定义Dom扩展方法 ======
function setStyle(a,styleName,styleValue)
	{
		if(document.all){a.runtimeStyle.setAttribute(styleName,styleValue,0);}
		else{
			var re=/^([a-z]+)([A-Z]+)([a-z]+)$/;
			var c=styleName;
			if(c.match(re)!=null){
				c=c.replace(re,'$1-$2$3');
				c=c.toLowerCase();
			}
			a.style.setProperty(c,styleValue,null);
		}
	}
function hide(a)
	{
		setStyle(a,'display','none');
	}
//移除某对象所有子对象
function removeAllChildren(a)
	{
		while (a.hasChildNodes()) {
			a.removeChild(a.firstChild);
		}
	}
//移除某对象指定tagName的子对象，包括子对象中的子对象
function removeChildrenByTagName(a,tagName)
	{
		if(a.hasChildNodes()){
			var arr=new Array();
			for (var i=0; i<a.childNodes.length; i++) {
				arr.push(a.childNodes[i]);
			}
			for (var i=0; i<arr.length; i++) {
				var oElement=arr[i];
				if(oElement.nodeType==1){
					if(oElement.tagName.toLowerCase()==tagName){
						a.removeChild(oElement);
					}
					else{
						removeChildrenByTagName(oElement,tagName);
					}
				}
			}
		}
	}
//等比例缩放图像，宽度缩放到targetWidth，其中rate=图片原始的height/width
function resize(a,targetWidth,rate)
	{
		a.setAttribute('width',targetWidth);
		a.setAttribute('height',rate*fs(0,a.width));
	}
//激发click事件
function performClick(a)
	{
		if(document.all){
			a.fireEvent('onclick');
		}
		else{
			var evt=document.createEvent('MouseEvents');
			evt.initMouseEvent('click', true, true, window,0, 0, 0, 0, 0, false, false, false, false, 0, null);
			a.dispatchEvent(evt);
		}
	}

//去除对象的前后空格
function trim(a)
	{
		//如果对象是input type=text
		if(a.tagName.toLowerCase()=='input'){
			if(a.type.toLowerCase()=='text' || a.type.toLowerCase()=='hidden'){
				a.value=a.value.trim();
			}
		}
		//如果对象是textarea
		if(a.tagName.toLowerCase()=='textarea'){
			a.value=a.value.trim();
		}
		//如果对象是form
		if(a.tagName.toLowerCase()=='form'){
			for (var i=0; i<a.elements.length; i++) {
				var b=a.elements[i];
				if(b.tagName.toLowerCase()=='input'){
					if(b.type.toLowerCase()=='text' || b.type.toLowerCase()=='hidden'){
						b.value=b.value.trim();
					}
				}
				if(b.tagName.toLowerCase()=='textarea'){
					b.value=b.value.trim();
				}
			}
		}
	}

//移动对象，调用方式类似：a.move('left',3);，向左移动对象3像素，无论对象是否可以移动
function move(a,strDirection,numSpace)
	{
		a=$(a);
		var num=0;
		var numPosition=0;
		switch (strDirection) {
			case 'left':
				//numPosition=parseInt(a.currentStyle ? a.currentStyle.left : a.style.left);
				numPosition=parseInt(a.getStyle('left'));
				num=numPosition-numSpace;
				a.setStyle('left',num+'px');
			break;
			case 'right':
				//numPosition=parseInt(a.currentStyle ? a.currentStyle.left : a.style.left);
				numPosition=parseInt(a.getStyle('left'));
				num=numPosition+numSpace;
				a.setStyle('left',num+'px');
			break;
			case 'top':
				//numPosition=parseInt(a.currentStyle ? a.currentStyle.top : a.style.left);
				numPosition=parseInt(a.getStyle('top'));
				num=numPosition-numSpace;
				a.setStyle('top',num+'px');
			break;
			case 'bottom':
				//numPosition=parseInt(a.currentStyle ? a.currentStyle.top : a.style.left);
				numPosition=parseInt(a.getStyle('top'));
				num=numPosition+numSpace;
				a.setStyle('top',num+'px');
			break;
		}
	}

//====== 定义Dom扩展属性对象组 ======
var __G=
	{
		'aLeft':aLeft,
		'aLeftToBody':aLeftToBody,
		'aRight':aRight,
		'aTop':aTop,
		'aBottom':aBottom,
		'propertyWidth':propertyWidth,
		'propertyHeight':propertyHeight,
		'setStyle':setStyle,
		'getStyle':getStyle,
		'hide':hide,
		'childMaxZIndex':htEditorGetZIndex,
		'childrenByTagName':childrenByTagName,
		'inText':inText,
		'setText':setText,
		'removeAllChildren':removeAllChildren,
		'resize':resize,
		'performClick':performClick,
		'parentClassName':parentClassName,
		'parentByTagName':parentByTagName,
		'childClassName':childClassName,
		'childClassNameFirst':childClassNameFirst,
		'trim':trim,
		'removeChildrenByTagName':removeChildrenByTagName,
		'childBy':childBy,
		'childNodeBy':childNodeBy,
		'childrenBy':childrenBy,
		'move':move
	}
var $=function() {
	if(arguments.length==1){
		var a=arguments[0];
		var el=typeof(a)=='string' ? document.getElementById(a) : a;
		if(el && !el._extendedByMyScriptName){
			for(var i in __G){
				var _tmpFn=function(_fn,_o){//delegate function
					return function(){
						if(typeof(_fn)=="function"){return _fn.apply(null,[_o].concat(Array.prototype.slice.call(arguments)))}else{return null;}
					}
				};
				el[i]=_tmpFn(__G[i],el);
			}
			//this statement is use to stop from too much recursion
			el._extendedByMyScriptName=true;
		}
		return el;
	}
	if(arguments.length==2){
		var dataArray=arguments[0],runCode=arguments[1];
		switch (runCode) {

			case 2:		//调用方式：$(Array(a,'left'),2)返回对象a相对原点的绝对距离；
				var a=dataArray[0],direction=dataArray[1],b=0;
				while (a) {
					if(a.nodeType==1){
						b=b+(direction=='left' ? a.offsetLeft : a.offsetTop);
					}
					a=a.offsetParent;
				}
				return b;
			break;

			case 3:		//调用方式：$('checkBoxName',3)，返回当前文档中，name为checkBoxName的对象集合数组；
				var cArray=new Array();
				var a=document.getElementsByTagName('input'),c=arguments[0];
				if(a==null){return cArray;}
				for (var i=0; i<a.length; i++) {
					if(a[i].type.toLowerCase()=='checkbox'){
						if(a[i].name==c){
							cArray.push(a[i]);
						}
					}
				}
				return cArray;
			break;

			case 5:		//调用方式：$(Array(a,'tr'),5)，返回某对象父对象tagName为tr的对象
				var a=dataArray[0],strTg=dataArray[1];
				var b=a.parentNode;
				while (b) {
					if(b.tagName){
						if(b.tagName.toLowerCase()==strTg){return b;}
					}
					b=b.parentNode;
				}
			break;

			case 6:		//调用方式：$(a,6)，返回某对象的privousSibling（其nodeType为1）
				var a=arguments[0];
				var b=a.previousSibling;
				while (b) {
					if(b.nodeType==1){return b;}
					b=b.previousSibling;
				}
			break;

			case 7:		//调用方式：$(a,7)，返回某对象的nextSibling（其nodeType为1）
				var a=arguments[0];
				var b=a.nextSibling;
				while (b) {
					if(b.nodeType==1){return b;}
					b=b.nextSibling;
				}
			break;

			case 8:		//调用方式：$(a,8)，返回对象a的innerText，但不包括对象a的子对象的innerText
				var a=arguments[0],b,c='';
				if(a.hasChildNodes()){
					for (var i=0; i<a.childNodes.length; i++) {
						b=a.childNodes[i];
						if(b.nodeType==3){c=c+b.nodeValue;}
					}
				}
				return c;
			break;

			case 9:		//调用方式：$(c,9)，返回c的文件后缀，如果c是个文件名的话，否则返回空字符串
				var re=/\.([^.\/]+)(\?|$)/ig;
				var arr=re.exec(arguments[0]);
				if(arr){return arr[1];}
			break;

			case 10:	//调用方式：$('',10)，返回当前文件绝对路径，返回类似：/client/default.asp
				return self.location.pathname.toLowerCase();
			break;

			case 11:	//调用方式：$(a,11)，返回a对象的第一个nodeType＝1的子对象
				var a=arguments[0];
				if(a.hasChildNodes()){
					a=a.childNodes;
					for (var i=0; i<a.length; i++) {
						if(a[i].nodeType==1){return a[i];}
					}
				}
			break;

			case 12:	//调用方式：$('',12)，在某文档中的radio中返回checked对象；
				var a=b.getElementsByTagName('input');
				if(a){
					for (var i=0; i<a.length; i++) {
						if(a[i].type.toLowerCase()=='radio'){
							if(a[i].checked){return a[i];}
						}
					}
				}
			break;

			case 13:	//调用方式：$('',13)，在某文档中的checkbox中返回checked了并且命名了的checkbox对象；
				var a=b.getElementsByTagName('input');
				var cArray=new Array();
				if(a){
					for (var i=0; i<a.length; i++) {
						if(a[i].type.toLowerCase()=='checkbox'){
							if(a[i].checked && a[i].name==arguments[2]){cArray.length++;cArray[cArray.length-1]=a[i];}
						}
					}
					return cArray;
				}
			break;

			case 14:	//调用方式：$(Array(a,b),14)，在同一级对象中，将a、和b之间的对象remove；
				var a=arguments[0][0],b=arguments[0][1],d;
				a=a.nextSibling;
				while (a!=b) {
					d=a.nextSibling;
					a.parentNode.removeChild(a);
					if(d){a=d}else{break;}
				}
			break;

			case 15:	//调用示例：$(a,15)，返回a对象的nodeType为1的子对象集合
				var a=arguments[0],aArray=new Array(),b;
				if(a.hasChildNodes()){
					b=a.childNodes;
					for (var i=0; i<b.length; i++) {
						if(b[i].nodeType==1){aArray.push(b[i]);}
					}
				}
				return aArray;
			break;

			case 16:	//调用示例：$(Array('span','spanItem'),16)，返回当前页面tagName为span，className为spanItem的对象数组
				var tagName=arguments[0][0],className=arguments[0][1],aArray=new Array(),re;
				var cl=document.getElementsByTagName(tagName);
				for (var i=0; i<cl.length; i++) {
					c=cl[i].className;
					if(c==className){aArray.push(cl[i]);}
				}
				return aArray;
			break;

			case 17:	//调用示例：$(Array(a,'dlContent'),17)，返回a对象第一级子对象中className＝dlContent的第一个对象
				var a=arguments[0][0],cName=arguments[0][1];
				if(a.hasChildNodes()==false){return null;}
				a=a.childNodes;
				for (var i=0; i<a.length; i++) {
					if(a[i].nodeType==1){if(a[i].className.toLowerCase()==cName){return a[i];}}
				}
			break;

			case 18:	//调用方式：$(a,18)，返回a对象最深的frame子对象；
				var a=arguments[0];
				while(a.frames.length>0){
					a=a.frames[0];
				}
				return a;
			break;


		}
	}
	return null;
}

//=========================
//====== 定义Dom结束 ======
//=========================

//==========================
//====== 定义常用对象 ======
//==========================
function oReturnBody()
	{
		var oBody=$(document.documentElement).childrenByTagName('body')[0];
		return oBody;
	}
var g=
	{
		'body':oReturnBody,
		'blnDealMenu':false,
		'sTop':function(){return document.body ? (document.documentElement.scrollTop || document.body.scrollTop) : document.documentElement.scrollTop;},
		'sLeft':function(){return document.body ? (document.documentElement.scrollLeft || document.body.scrollLeft) : document.documentElement.scrollLeft;},
		'oh':function(){return document.documentElement.offsetHeight;},//返回浏览器窗口的高度
		'ch':function(){return document.documentElement.clientHeight;},//返回浏览器窗口的高度
		'wareID':0
	}

	var $f=function ()		//各种功能
		{
			switch (arguments[0]) {
				case 0:		//持续连接远程服务器，防止Session过期
					try {
						tao.getHtpText('get','/manage/');
					}
					catch (e) {
					}
					setTimeout('$f(0)',300000);
				break;

				case 1:		//调用方式：$f(1,a)把a对象在当前文档中居中
					var a=arguments[1];
					a.style.left=((document.documentElement.clientWidth-a.clientWidth)/2+document.documentElement.scrollLeft)+'px';
					a.style.top=((document.documentElement.clientHeight-a.clientHeight)/2+document.documentElement.scrollTop)+'px';
				break;

				case 2:		//调用方式：$f(2)，如果当前页面有id为ulMenu的对象，则设置该对象的事件
					var a=$('ulMenu'),liArray=new Array();
					if(a==null){return;}
					$(Array(a,'li',liArray),0);
					for (var i=0; i<liArray.length; i++) {
						liArray[i].onmouseover=function() {$f(3,this);}
						liArray[i].onmouseout=function() {$f(4,this);}
					}
				break;

				case 3:		//调用方式：$f(3,a)，接上面，如果有onmouseover事件，那么则显示a对象中tagName为“ul”的子对象；
					var a=arguments[1];
					var oLi=$(a);
					a=$(Array(a,'ul'),1);
					if(a==null){return;}
					//a.style.left=(a.parentNode.clientWidth+1)+'px';
					a.style.left=(a.parentNode.clientWidth-1)+'px';
					var oElement=$(a);
					a.style.top=oElement.propertyHeight()+oElement.clientHeight+oLi.aTop()>document.documentElement.scrollTop+document.documentElement.clientHeight ? document.documentElement.scrollTop+document.documentElement.clientHeight-(oElement.propertyHeight()+oElement.clientHeight+oLi.aTop())+'px' : '0px';//+'|'+document.documentElement.clientHeight;
					a.style.visibility='visible';
				break;
				case 4:		//调用方式：$f(4,a)，接上面，如果有onmouseout事件，那么则隐藏a对象中tagName为“ul”的子对象；
					var a=arguments[1];
					a=$(Array(a,'ul'),1);
					if(a==null){return;}
					a.style.visibility='hidden';
				break;

				case 5:		//调用方式：$f(5,f)，将form表单中的input、textarea前后的空格去掉；
					var a,f=arguments[1];
					for (var i=0; i<f.length; i++) {
						a=f.elements[i];
						if(a.type.toLowerCase()=='text'){a.value=a.value.trim();}
						if(a.type.toLowerCase()=='textarea'){a.value=a.value.trim();}
					}
				break;

				case 6:		//调用方式：$f(6)，如果当前页面有form表单中的项目存在spanText，则当focus时，变化spanText的表现形式
					var of=document.forms,f,a,aType;
					for (var i=0; i<of.length; i++) {
						f=of[i];
						for (var j=0; j<f.length; j++) {
							a=f.elements[j];
							aType=a.type.toLowerCase();
							if(aType=='text' || aType=='textarea' || aType=='password' || aType=='file' || aType=='select-one' || aType=='radio' || aType=='checkbox'){
								a.onfocus=function(){
									this.select ? this.select() : this.focus();
									var b=$(this,7);
									if(b){
										if(b.className=='spanText'){b.className='spanTextFocus';this.onblur=function(){var d=$(this,7);d.className='spanText';}}
									}
									b=$(this.parentNode,7);
									if(b){
										if(b.className=='spanText'){b.className='spanTextFocus';this.onblur=function(){var d=$(this.parentNode,7);d.className='spanText';}}
									}

								}
							}
						}
					}
				break;

				case 7:		//调用方式：$f(7)，focus某些页面的input
					var c=$('',10);
					switch (c) {
						case '/client/login.asp':
							$('itUserName').focus();
						break;
						case '/client/getpassword.asp':
							$('itUserName').focus();
						break;
						case '/client/setpassword.asp':
							$('ipPassword').focus();
						break;
						default:

					}
				break;

				case 8:		//修正img对象中className包含visual的大小
					var clImg=document.getElementsByTagName('img'),cName,re;
					if(clImg.length==0){return;}
					for (var i=0; i<clImg.length; i++) {
						cName=clImg[i].className;
						if(cName){
							re=/(^| )imgVisual( |$)/ig;
							if(cName.match(re)!=null){
								$f(9,clImg[i]);
							}
						}
					}
				break;

				case 9:		//续上
					var a=arguments[1];
					var src=a.getAttribute('src',0);
					var oImg=document.createElement('img');
					window.attachEvent ? oImg.attachEvent('onload',function(){$f(10,oImg,a);}) : oImg.addEventListener('load',function(){$f(10,this,a);},true);
					oImg.setAttribute('src',src,0);
				break;

				case 10:	//续上
					var oImg=arguments[1];
					var a=arguments[2];
					var widthCur=a.clientWidth;
					var heightCur=a.clientHeight;
					var left=(a.offsetWidth-a.clientWidth)/2-a.clientLeft;
					var top=(a.offsetHeight-a.clientHeight)/2-a.clientTop;
					var width=window.Node ? oImg.width : oImg.getAttribute('width',0);
					var height=window.Node ? oImg.height : oImg.getAttribute('height',0);
					width=parseInt(width);
					height=parseInt(height);
					if(width>widthCur){
						height=Math.floor(widthCur*height/width);
						width=widthCur;
					}
					if(height>heightCur){
						width=Math.floor(heightCur*width/height);
						height=heightCur;
					}
					a.style.width=width+'px';
					a.style.height=height+'px';
					a.style.padding=((heightCur-height)/2+top)+'px '+((widthCur-width)/2+left)+'px';
				break;

				default:

				case 11:		//产品详细介绍页面中，当鼠标放到图片上后，变换产品中图片
					var a=arguments[1];
					var mImg,b,d,curWidth,curHeight;
					if (a==null) {return;}
					b=a.getElementsByTagName('a');
					if(b.length==null){return;}
					if(b.length<2){return;}
					mImg=b[0].firstChild;
					curWidth=mImg.clientWidth;
					curHeight=mImg.clientHeight;
					for (var i=1; i<b.length; i++) {
						d=b[i];
						d.onmouseover=function() {
							var a,b,f,oldWidth,oldHeight;
							b=this.firstChild;
							//如果是文本，则退出
							if(b.nodeType!=1){return;}
							mImg.setAttribute('src',b.getAttribute('src'),0);
							a=b.cloneNode(true);
							oldWidth=parseInt(a.getAttribute('width'));
							oldHeight=parseInt(a.getAttribute('height'));
							if(isNaN(oldWidth) || isNaN(oldHeight)){oldWidth=268;oldHeight=179;}
							if(oldWidth==0 || oldHeight==0){	//如果出现尺寸错误，比如等于0的情况，则到原始图片中去查找尺寸
								f=$(Array($('divWareInfo'),a.getAttribute('src')),1);
								if(f){oldWidth=f.getAttribute('width');oldHeight=f.getAttribute('height');}
							}
							if(oldWidth>curWidth || oldHeight>curHeight){
								if(oldWidth/oldHeight>curWidth/curHeight){
									mImg.style.width='100%';
									mImg.style.height=(curWidth/curHeight)/(oldWidth/oldHeight)*100+'%';
								}
								else{
									mImg.style.height='100%';
									mImg.style.width=(oldWidth/oldHeight)/(curWidth/curHeight)*100+'%';
								}
							}
							else{
								mImg.style.width=oldWidth+'px';
								mImg.style.height=oldHeight+'px';
							}
							a=null;
						}
					}
				break;
			}
		}

	//添加事件，通用于主流浏览器
	function addEvent(el, type, handler, capture) {
		//举例：addEvent(this.parentElement,'mouseenter',function(event){self.blnCanScroll=false;},false);
		//如果是firefox
		if (typeof el.addEventListener != 'undefined') {
			if (type === 'mouseenter') {
				el.addEventListener('mouseover', _addEvent(handler), capture);
			}
			else if (type === 'mouseleave') {
				el.addEventListener('mouseout', _addEvent(handler), capture);
			} else {
				el.addEventListener(type, handler, capture);
			}
		} else if (typeof el.attachEvent != 'undefined') {
			//如果是IE
			el.attachEvent('on' + type, handler);
		} else {
			el['on' + type] = handler;
		}
	}
	function _addEvent(handler) {
		return function (e) {
			var parent = e.relatedTarget;
			while ( parent && parent != this ) {
				try { parent = parent.parentNode; }
				catch(e) { break; }
			}
			if ( parent != this )handler.call(this, e);
		}
	}
