
    /*
     *	对象名称：Element（全局静态对象）
     *	职责：负责处理HTML对象公共方法
     *
     */
    var Element = {};
    /*
     *	函数说明：删除对象
     *	参数：
     *	返回值：
     *	作者：毛云
     *	日期：2006-4-14
     *
     */
    Element.removeNode = function(node){
        if(null!=node){
            if(_BROWSER==_BROWSER_IE){
                node.removeNode(true);
            }else{
                var parentNode = node.parentNode;
                if(null!=parentNode){
                    parentNode.removeChild(node);
                }
            }
        }
    }
    /*
     *	函数说明：获取对象页面绝对位置
     *	参数：	object:srcElement       HTML对象
     *	返回值：number:offsetLeft       对象页面绝对位置
     *	作者：毛云
     *	日期：2006-4-14
     *
     */
    Element.absLeft = function(srcElement){
        var absLeft = 0;
        var tempObj = srcElement;
        while(tempObj!=document.body){
            absLeft += tempObj.offsetLeft - tempObj.offsetParent.scrollLeft;
            tempObj = tempObj.offsetParent;
        }
        return absLeft;
    }
    /*
     *	函数说明：获取对象页面绝对位置
     *	参数：	object:srcElement       HTML对象
     *	返回值：number:offsetTop        对象页面绝对位置
     *	作者：毛云
     *	日期：2006-4-14
     *
     */
    Element.absTop = function(srcElement){
        var absTop = 0;
        var tempObj = srcElement;
        while(tempObj!=document.body){
            absTop += tempObj.offsetTop - tempObj.offsetParent.scrollTop;
            tempObj = tempObj.offsetParent;
        }
        return absTop;
    }
    /*
     *	函数说明：创建带命名空间的对象
     *	参数：	string:tagName		对象标签名
                string:ns			命名空间
     *	返回值：object	html对象
     *	作者：毛云
     *	日期：2006-4-10
     *
     */
    Element.createElement = function(tagName,ns){
        var obj = null;
        if(null==ns){
            obj = document.createElement(tagName);
        }else{
            var tempDiv = document.createElement("DIV");
            tempDiv.innerHTML = "<"+ns+":"+tagName+"/>";
            obj = tempDiv.firstChild.cloneNode(false);
            Element.removeNode(tempDiv);
        }
        return obj;

    }
    /*
     *	函数说明：隐藏对象覆盖范围内的高优先级的控件(select等)
     *	参数：	Object:obj			html对象
     *	返回值：
     *	作者：毛云
     *	日期：2006-4-25
     *
     */
    Element.hideConflict = function(obj){
        var x = Element.absLeft(obj);
        var y = Element.absTop(obj);
        var w = obj.offsetWidth;
        var h = obj.offsetHeight;
        var rect = {x:x,y:y,w:w,h:h};
		var conflict = [];

        function isInSide(point,rect){
            var flag = true;
            if(point.x>rect.x+rect.w || point.x<rect.x){
                flag = false;
            }
            if(true==flag){
                if(point.y>rect.y+rect.h || point.y<rect.y){
                    flag = false;
                }
            }
            return flag;
        }

        var conflictTags = ["select"];
        for(var i=0,iLen=conflictTags.length;i<iLen;i++){
            var curConflictTag = conflictTags[i];
            var curConflictObjs = document.getElementsByTagName(curConflictTag);
            for(var j=0,jLen=curConflictObjs.length;j<jLen;j++){
                var curConflictObj = curConflictObjs[j];

                var x1 = Element.absLeft(curConflictObj);
                var y1 = Element.absTop(curConflictObj);
                var w1 = curConflictObj.offsetWidth;
                var h1 = curConflictObj.offsetHeight;
                var x2 = x1 + w1;
                var y2 = y1 + h1;

                var flag = isInSide({x:x1,y:y1},rect);
                flag = flag || isInSide({x:x2,y:y1},rect);
                flag = flag || isInSide({x:x2,y:y2},rect);
                flag = flag || isInSide({x:x1,y:y2},rect);

                if(flag==true){
                        curConflictObj.style.visibility = "hidden";
						conflict[conflict.length] = curConflictObj;
                }

                
            }
        }
		obj.conflict = conflict;
        return obj;

    }
    /*
     *	函数说明：显示对象覆盖范围内的高优先级的控件(select等)
     *	参数：	Object:obj			html对象
     *	返回值：
     *	作者：毛云
     *	日期：2006-4-25
     *
     */
    Element.showConflict = function(obj){
		if(null!=obj.conflict){
			for(var i=0,iLen=obj.conflict.length;i<iLen;i++){
				obj.conflict[i].style.visibility = "visible";
			}
		}
    }
    /*
     *	函数说明：写入内容（同时解决ActiveX控件激活问题）
     *	参数：	string:content      内容HTML字符串
     *	返回值：
     *	作者：毛云
     *	日期：2006-5-12
     *
     */
    Element.write = function(obj,content){
        obj.innerHTML = content;
    }
    /*
     *
     * 函数说明：控制对象拖动改变宽度
     * 参数：	Object:obj			要拖动改变宽度的HTML对象
     * 返回值：	
     * 作者：毛云
     * 日期：2006-6-8
     *
     */
	Element.attachColResize = function(obj,offsetX){
        offsetX = 3 - (offsetX||0);

		//计算对象实际X,Y位置
		obj._absTop = this.absTop(obj);
		obj._absLeft = this.absLeft(obj);

		//添加resize条
		var ruleObj = document.createElement("DIV");
		ruleObj.id = "colRule";
		ruleObj.style.cssText = "cursor:col-resize;width:3px;height:" + obj.offsetHeight + ";top:" + obj._absTop + ";left:" + (obj._absLeft+obj.offsetWidth-offsetX) + ";position:absolute;background-color:white;overflow:hidden;filter:alpha(opacity=0)"
		document.body.appendChild(ruleObj);

        var colResizeTimeout;
        var colResizeDelay = 20;

		//检测边缘
		function checkEdge(obj){
			if(event.clientX>obj.offsetWidth-offsetX-2){
				return true;
			}else{
				return false;
			}
		
		}

		ruleObj.onmousedown = function(){
			if(checkEdge(obj)==true){
				this.style.backgroundColor = "#999999";
				this.style.filter = "alpha(opacity=50)";

				this._isMouseDown = true;
				this._ox = event.clientX;

				this.setCapture();
			}else{
				this.style.backgroundColor = "white";
				this.style.filter = "alpha(opacity=0)";

				this._isMouseDown = false;
				this.releaseCapture();
			}
		
		};
		ruleObj.onmousemove = function(){
			if(this._isMouseDown==true){
				this.style.left = Math.max(obj._absLeft,event.clientX - 3);
			}
		};
		ruleObj.onmouseup = function(){
			if(this._isMouseDown==true){
				this._isMouseDown = false;
				this.releaseCapture();

				obj.style.width = Math.max(1,obj.offsetWidth - offsetX + event.clientX - this._ox);

				this.style.backgroundColor = "white";
				this.style.filter = "alpha(opacity=0)";
			}
		
		};
		obj.onresize = function(){
            clearTimeout(colResizeTimeout);
            colResizeTimeout = setTimeout(function(){
                //计算对象实际X,Y位置
                obj._absTop = Element.absTop(obj);
                obj._absLeft = Element.absLeft(obj);

                ruleObj.style.left = obj._absLeft + obj.offsetWidth - offsetX;
                ruleObj.style.top = obj._absTop;
                ruleObj.style.height = obj.offsetHeight;
            },colResizeDelay);
		}
		
	}
    /*
     *
     * 函数说明：控制对象拖动改变高度
     * 参数：	Object:obj			要拖动改变宽度的HTML对象
     * 返回值：	
     * 作者：毛云
     * 日期：2006-6-8
     *
     */
	Element.attachRowResize = function(obj,offsetY){
        offsetY = 3 - (offsetY||0);

		//计算对象实际X,Y位置
		obj._absTop = this.absTop(obj);
		obj._absLeft = this.absLeft(obj);

		//添加resize条
		var ruleObj = document.createElement("DIV");
		ruleObj.id = "rowRule";
		ruleObj.style.cssText = "cursor:row-resize;height:3px;width:" + obj.offsetWidth + ";top:" + (obj._absTop+obj.offsetHeight-offsetY) + ";left:" + obj._absLeft + ";position:absolute;background-color:white;overflow:hidden;filter:alpha(opacity=0)"
		document.body.appendChild(ruleObj);

        var rowResizeTimeout;
        var rowResizeDelay = 20;

		//检测边缘
		function checkEdge(obj){
			if(event.clientY>obj.offsetHeight-offsetY-2){
				return true;
			}else{
				return false;
			}
		
		}

		ruleObj.onmousedown = function(){
			if(checkEdge(obj)==true){
				this.style.backgroundColor = "#999999";
				this.style.filter = "alpha(opacity=50)";

				this._isMouseDown = true;
				this._oy = event.clientY;

				this.setCapture();
			}else{
				this.style.backgroundColor = "white";
				this.style.filter = "alpha(opacity=0)";

				this._isMouseDown = false;
				this.releaseCapture();
			}
		
		};
		ruleObj.onmousemove = function(){
			if(this._isMouseDown==true){
				this.style.top = Math.max(obj._absTop,event.clientY - 3);
			}
		};
		ruleObj.onmouseup = function(){
			if(this._isMouseDown==true){
				this._isMouseDown = false;
				this.releaseCapture();

				obj.style.height = Math.max(1,obj.offsetHeight - offsetY + event.clientY - this._oy);

				this.style.backgroundColor = "white";
				this.style.filter = "alpha(opacity=0)";
			}
		
		};
		obj.onresize = function(){
            clearTimeout(rowResizeTimeout);
            rowResizeTimeout = setTimeout(function(){
                //计算对象实际X,Y位置
                obj._absTop = Element.absTop(obj);
                obj._absLeft = Element.absLeft(obj);

                ruleObj.style.top = obj._absTop + obj.offsetHeight - offsetY;
                ruleObj.style.left = obj._absLeft;
                ruleObj.style.width = obj.offsetWidth;
            },rowResizeDelay);
		}
		
	}