var IE5 = "IE" ;
var MOZ2 = "MOZILLA"
var zIndexMax = 6 ;
var timerclose = null ;
var timerdrag = null ;
var timerresize = null ;
var timerresize2 = null ;
var loadtimer = null ;
var popupWindowColl = new Array();
function _C(tag, id) {
    var v = document.createElement(tag);
    v.id = id;
    return v;
}
function getzIndexMax() {
    return zIndexMax;
}
function setzIndexMax(value) {
    zIndexMax = value;
}
function newxWin(width, height, left, top, title, content, frame_id, isParentWindow, zIndex, isShowShadow, isFlashShow, xPosition, yPosition) {
    this.isShow = 0;
    this.isParent = isParentWindow;
    // this.isFlashShow = isNaN(isFlashShow) ? true : isFlashShow ;
    // this.isShowShadow = isShowShadow ;
    if (isParentWindow == "true" && !isNaN(top)) {
        top = window.parent.document.body.scrollTop + top;
    } else if (!isNaN(top)) {
        top = document.body.scrollTop + top;
    }
    this.xBeginPosition = isNaN(xPosition) ? 0 : parseInt(xPosition);
    this.yBeginPosition = isNaN(yPosition) ? 0 : parseInt(yPosition);
    this._isFix = isNaN(xPosition) ? false : true;
    //是否固定,根据POSITION
    this.width = isNaN(width) ? 642 : parseInt(width);
    this.height = isNaN(height)? 400 : parseInt(height);
    this.left = isNaN(left)  ? 150 : parseInt(left);
    this.top = isNaN(top)   ? 100 : parseInt(top);
    this.title = title           ? title : "字 典";
    //alert(zIndex);
    this.zIndex = isNaN(zIndex)   ? 3 : parseInt(zIndex);
    this.content = "";
    this._isshow = false;
    this._flashOver = false;     //是否已经完全打开窗口
    if (frame_id) {
        this.frame_id = frame_id;
    } else {
        this.frame_id = 1;
    }
    //this.cl_win_Shadow  	= "#94999A";
    this.cl_win_Shadow = "#CACFD7";
    this.frameHtml = '<iframe src="' + this.content + '" id="innerFrame' + this.frame_id + '" style="width:100%; height:100%;" frameBorder=0></iframe>';
    return this.build();
}
newxWin.prototype = {
    _canmove: false,    // 移动标志
    _fix    : this._isFix,    //是否固定
    _state  : "default" ,
    _maxwidth: 0,
    _maxheight: 0,
    _minwidth : 180,
    _minheight :120,
    _x0: 0,                // 事件发生的 x 坐标
    _y0: 0,                // 事件发生的 y 坐标
    _x1: 0,                // 鼠标点击 x 坐标
    _y1: 0,                // 鼠标点击 y 坐标
    _titleHeight:30,    //标题高度 标题图片大小
    _bottomHeight:15,  //底图片大小
    _leftWidth : 15,   //左图片大小
    _rightWidth : 15 , //右边图片大小
    _innerBorder:1 , //内边框线大小
    _shadowDiv:null , //拖动时的阴影
    _maskDiv :null , //遮挡阴影

    global:window.document,
    parentGlobal : window.parent.document,
    title:this.title,
    checkIExWin: function() {
        if (window.navigator.userAgent.indexOf("MSIE") >= 1) {
            return IE5;
        } else if (window.navigator.userAgent.indexOf("Firefox") >= 1) {
            //如果浏览器为Firefox
            return MOZ2;
        } else {
            //如果浏览器为其他
            return MOZ2;
        }
    },
    _isIE:true ,

//构造窗体
    build:function() {
        if (this.checkIExWin() != IE5) {
            this._isIE = false;
        }
        if (this.isParent == "true") {
            documentObj = window.parent.document;
        } else {
            documentObj = window.document;
        }

        var xWin = documentObj.createElement("DIV");
        this.xWin = xWin;
        with (xWin.style) {
            width = this.width;
            height = this.height;
            top = this.top;
            left = this.left;
            position = "absolute";
            display = "none";
            zIndex = this.zIndex;
        }
        if (this.isParent == "true") {
            this.parentGlobal.body.appendChild(xWin);
        } else {
            this.global.body.appendChild(xWin);
            //xWin不能用引号,因为它是个对象 ;
        }
        var titlebar = documentObj.createElement("DIV");
        this.titlebar = titlebar;
        with (titlebar.style) {
            width = this.width;
            //减去xWin两边border的大小
            height = this._titleHeight;
            zIndex = this.zIndex;
        }
        xWin.appendChild(titlebar);

        var title_left = documentObj.createElement("DIV");
        this.title_left = title_left;
        with (title_left.style) {
            width = this._leftWidth;
            height = this._titleHeight;
            filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../smmail/sy06/images/sysimg/t1.png', sizingMethod='scale',enabled='true')";
        }
        title_left.className = "floatLeft";
        //*title_left.className = "title_left"
        titlebar.appendChild(title_left);

        var titlecontent = documentObj.createElement("DIV");
        this.titlecontent = titlecontent;
        with (titlecontent.style) {
            width = this.width - this._leftWidth - this._rightWidth;
            //15为右边的图片大小
            height = this._titleHeight;
            filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../smmail/sy06/images/sysimg/t2.png', sizingMethod='scale',enabled='true')";
        }
       titlecontent.className = "floatLeft";
       //*titlecontent.className = "titlecontent";
        titlebar.appendChild(titlecontent);

        var titletable = documentObj.createElement("TABLE");
        with (titletable) {
            cellspacing = 0;
            cellpadding = 0;
        }
        with (titletable.style) {
            width = "100%";
            height = "100%";
            border = "0px groove red";
        }

        var tbody = documentObj.createElement("TBODY");
        with (tbody) {
            width = "100%";
            height = "100%";
        }
        titletable.insertBefore(tbody, null);

        var titletr = documentObj.createElement("tr");
        this.titletr = titletr;
        var col01 = documentObj.createElement("td");
        //第一个td
        with (col01.style) {
            width = 1;
        }
        // titletr.insertBefore(col01, null);

        var col03 = documentObj.createElement("td");
        this.col03 = col03;
        with (col03.style) {
            color = "#000000";
            fontSize = "12px";
            fontFamily = "宋体";
            //fontWeight	= "bold";
            paddingTop = 11;
            cursor = "default";
        }
        col03.innerHTML = this.title;
        titletr.appendChild(col03);

        var col04 = documentObj.createElement("td");
        with (col04.style) {
            width = 16;
        }

        var tdimgmin = documentObj.createElement("img");
        tdimgmin.src = "../../smmail/sy06/images/sysimg/min.gif";
        with (tdimgmin.style) {
            width = 15;
            height = 15;
            position = "relative";
            top = -3;
            border = 0;
            display = "none";
        }
        col04.appendChild(tdimgmin);
        //**titletr.appendChild(col04);

        var col05 = documentObj.createElement("td");
        with (col05.style) {
            width = 16;
        }
        var tdimgmax = documentObj.createElement("img");
        this.tdimgmax = tdimgmax;
        tdimgmax.src = "../../smmail/sy06/images/sysimg/max.gif";
        with (tdimgmax.style) {
            width = 15;
            height = 15;
            position = "relative";
            top = -3;
            border = 0;
            display = "none";
        }
        col05.appendChild(tdimgmax);
        //**titletr.appendChild(col05);

        var col06 = documentObj.createElement("td");
        with (col06.style) {
            width = 16;
        }
        var tdimgclose = documentObj.createElement("img");
        this.tdimgclose = tdimgclose;
        tdimgclose.src = "../../smmail/sy06/images/sysimg/close.gif";
        with (tdimgclose.style) {
            width = 43;
            height = 18;
            position = "relative";
            //top = -3;
            top = 3;
            border = 0;
        }
        col06.appendChild(tdimgclose);
        titletr.appendChild(col06);

        tbody.appendChild(titletr);

        titlecontent.appendChild(titletable);

        titlebar.appendChild(titlecontent);


        var tilte_right = documentObj.createElement("DIV");
        this.tilte_right = tilte_right;
        with (tilte_right.style) {
            width = this._rightWidth;
            height = this._titleHeight;
            filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../smmail/sy06/images/sysimg/t3.png', sizingMethod='scale',enabled='true')";
        }
        tilte_right.className = "floatLeft";
         //*tilte_right.className = "tilte_right";
        titlebar.appendChild(tilte_right);


        //***************内容区
        var clientMain = documentObj.createElement("DIV");
        this.clientMain = clientMain;
        with (clientMain.style) {
            width = this.width;
            height = this.height - this._titleHeight - this._bottomHeight;
            overflow = "hidden";
        }
        xWin.appendChild(clientMain);

        var client_left = documentObj.createElement("DIV");
        this.client_left = client_left;
        with (client_left.style) {
            width = this._leftWidth;
            height = this.height - this._titleHeight - this._bottomHeight;
            filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../smmail/sy06/images/sysimg/l1.png', sizingMethod='scale',enabled='true')";
        }
        client_left.className = "floatLeft";
         //*client_left.className = "client_left";
        clientMain.appendChild(client_left);

        var client = documentObj.createElement("DIV");
        this.client = client;
        with (client.style) {
            width = this.width - this._leftWidth - this._rightWidth;
            //其中2表示内边框大小
            height = this.height - this._titleHeight - this._bottomHeight;
            border = this._innerBorder + "px solid #666";
            //filter = "alpha(Opacity=65,style=0)";         //*很耗资源
            background = "#f7f7f7";
            //opacity = 0.15;
            overflow = "auto";

        }
        client.className = "floatLeft";
        clientMain.appendChild(client);

        var client_right = documentObj.createElement("DIV");
        this.client_right = client_right;
        with (client_right.style) {
            width = this._rightWidth;
            height = this.height - this._titleHeight - this._bottomHeight;
            filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../smmail/sy06/images/sysimg/r1.png', sizingMethod='scale',enabled='true')";
        }
        client_right.className = "floatLeft";
         //*client_right.className = "client_right";
        clientMain.appendChild(client_right);

        if (this.isParent == "true") {
            client.innerHTML = this.content;
        } else {
            client.innerHTML = this.frameHtml;
            iframebody = documentObj.getElementById("innerFrame" + this.frame_id);
            this.iframebody = iframebody;
            with (iframebody.style) {
                width = "99%";
                height = "99%";
            }
        }

        // ********************* 底部
        var win_bottom = documentObj.createElement("DIV");
        this.win_bottom = win_bottom;
        with (win_bottom.style) {
            width = this.width;
            //减去xWin两边border的大小
            height = this._bottomHeight;
            top = this.height - this._bottomHeight;
            overflow = "hidden";
        }
        xWin.appendChild(win_bottom);

        var bottom_left = documentObj.createElement("DIV");
        this.bottom_left = bottom_left;
        with (bottom_left.style) {
            width = this._leftWidth;
            height = this._bottomHeight;
            filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../smmail/sy06/images/sysimg/l2.png', sizingMethod='scale',enabled='true')";
        }
        bottom_left.className = "floatLeft";
         //*bottom_left.className = "bottom_left";
        win_bottom.appendChild(bottom_left);

        var bottom_mid = documentObj.createElement("DIV");
        this.bottom_mid = bottom_mid;
        with (bottom_mid.style) {
            width = this.width - this._leftWidth - this._rightWidth;
            height = this._bottomHeight;
            filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../smmail/sy06/images/sysimg/b1.png', sizingMethod='scale',enabled='true')";
        }
        bottom_mid.className = "floatLeft";
         //*bottom_mid.className = "bottom_mid";
        win_bottom.appendChild(bottom_mid);

        var bottom_right = documentObj.createElement("DIV");
        this.bottom_right = bottom_right;
        with (bottom_right.style) {
            width = this._rightWidth;
            height = this._bottomHeight;
            cursor = "se-resize";
            filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../../smmail/sy06/images/sysimg/r2.png', sizingMethod='scale',enabled='true')";
        }
        bottom_right.className = "floatLeft";
         //*bottom_right.className = "bottom_right";
        win_bottom.appendChild(bottom_right);

        //各方法
        var oThis = this;
        //用来定义this
        tdimgclose.onmouseover = function() {
            tdimgclose.src = "../../smmail/sy06/images/sysimg/close_mouseover.gif";
        };
        tdimgclose.onmouseout = function() {
            tdimgclose.src = "../../smmail/sy06/images/sysimg/close.gif";
        };
        tdimgmax.onclick = function() {
            oThis.max();
        };
        tdimgmax.onmouseover = function() {
            tdimgmax.src = "../../smmail/sy06/images/sysimg/max_mouseover.gif";
        };
        tdimgmax.onmouseout = function() {
            tdimgmax.src = "../../smmail/sy06/images/sysimg/max.gif";
        };
        titlebar.onmousedown = function(event) {
            oThis.startDrag(event, titlebar);
        };
        titlebar.onmousemove = function(event) {
            oThis.drag(event);
        };
        titlebar.onmouseup = function(event) {
            oThis.stopDrag(event, titlebar);
        };

        tdimgclose.onmousedown = function() {
            event.cancelBubble = true;
            return false;
        };
        tdimgclose.onmouseup = function() {
            event.cancelBubble = true;
            return false;
        };
        tdimgclose.onclick = function() {
            event.cancelBubble = true;
            oThis.close();
        };
        titlebar.onclick = function() {
            oThis.setFocus(getzIndexMax());
        };
        titlebar.ondblclick = function() {
            //event.cancelBubble = true;
            //oThis.setFocus(getzIndexMax());
        };
        //设置焦点
        client.onclick = function() {
            oThis.setFocus(getzIndexMax());
        };

        bottom_right.onmousedown = function(event) {
            oThis.startResize(event, bottom_right);
        };
        bottom_right.onmousemove = function(event) {
            oThis.Resize(event);
        };
        bottom_right.onmouseup = function(event) {
            oThis.stopResize(event, bottom_right);
            oThis.setFocus(getzIndexMax());
        };


    },

    show:function() {
        if (this._isshow == true) {
        } else {
            try {
                if (this.isParent == "true") {
                    documentObj = window.parent.document;
                } else {
                    documentObj = window.document;
                }
                //*this.titlebar.style.filter = "alpha(opacity=" + "100" + ",style=0)";
                //***this.titlebar.className = "alpha_100";
                //*this.tdimgclose.style.filter = "alpha(opacity=" + "100" + ",style=0)";
                //***this.tdimgclose.className = "alpha_100";
                //*this.xWin.style.filter = "alpha(opacity=" + "100" + ",style=0)";
               //*** this.xWin.className = "alpha_100";
                if (G("Main_Div")) {
                    documentObj.body.style.overflow = "hidden";
                    var obj =  G("Main_Div") ;
                    var num = obj.getAttribute("MaskNum") ;
                    if(num>=0){
                        obj.setAttribute("MaskNum",parseInt(num)+1);
                    }
                    num = null ;obj =null ;
                    //*G("Main_Div").style.display = "";
                    //*G("Main_Div").style.width = parseInt(document.body.scrollWidth) + 20;
                    //*G("Main_Div").style.height = parseInt(document.body.scrollHeight);
                    this._maskDiv = documentObj.createElement("DIV");
                    this._maskDiv.style.cssText = "filter:alpha(Opacity=60,style=0);opacity:0.6;background-color:#EEEEEE;position:absolute;left:0;top:0;width:"+(parseInt(document.body.scrollWidth) )+";height:"+parseInt(document.body.scrollHeight)+";z-index:"+(zIndexMax);
                    this._maskDiv.className="Main_Mask_Div";
                    documentObj.body.appendChild(this._maskDiv);
                }
                if (G("div_obj")) {
                    G("div_obj").style.display = "none";
                    // 视频层关闭
                }
                if (G("temp_div_obj")) {
                    G("temp_div_obj").style.display = "none";
                    // 视频层关闭
                }

                this.xWin.style.left = this.left;
                this.xWin.style.top = this.top;
                this._fix = false;
                this._isshow = true;
                this._state = "default";
                //alert("tihs.top;=" + this.top+ "  " + parseInt(documentObj.body.scrollTop) + "  ClientHeight=" + documentObj.body.clientHeight);
                this.resize_window_bycenter(this._minwidth, this._minheight, this.width, this.height, parseInt(this.left) + parseInt(this.width) / 2,parseInt(documentObj.body.scrollTop)+ documentObj.body.clientHeight, this.top);

                this.tdimgclose.style.display = "";
                this.xWin.style.display = "";
                this.setFocus(getzIndexMax());  //新增的
            } catch(E) {
                alert(E);
            }
        }
    },

    showOnly:function() {
        this._flashOver = true ;
        if (this._isshow == true) {
        } else {
            try {
                if (this.isParent == "true") {
                    documentObj = window.parent.document;
                } else {
                    documentObj = window.document;
                }
                //*this.titlebar.style.filter = "alpha(opacity=" + "100" + ",style=0)";
                //***this.titlebar.className = "alpha_100";
                //*this.tdimgclose.style.filter = "alpha(opacity=" + "100" + ",style=0)";
                //***this.tdimgclose.className = "alpha_100";
                //*this.xWin.style.filter = "alpha(opacity=" + "100" + ",style=0)";
                //***this.xWin.className = "alpha_100";

                this.xWin.style.left = this.left;
                this.xWin.style.top = this.top;
                this._fix = false;
                this._isshow = true;
                this._state = "default";

                this.tdimgclose.style.display = "";
                this.xWin.style.display = "";

                if (G("Main_Div")) {
                    documentObj.body.style.overflow = "hidden";
                    var obj =  G("Main_Div") ;
                    var num = obj.getAttribute("MaskNum") ;
                    if(num>=0){
                        obj.setAttribute("MaskNum",parseInt(num)+1);
                    }
                    num = null ;obj =null ;
                    //*G("Main_Div").style.display = "";
                    //*G("Main_Div").style.width = parseInt(document.body.scrollWidth) + 20;
                    //*G("Main_Div").style.height = parseInt(document.body.scrollHeight);
                    this._maskDiv = documentObj.createElement("DIV");
                    this._maskDiv.style.cssText = "filter:alpha(Opacity=40,style=0);opacity:0.4;background-color:#EEEEEE;position:absolute;left:0;top:0;width:"+(parseInt(document.body.scrollWidth))+";height:"+parseInt(document.body.scrollHeight)+";z-index:"+(zIndexMax);
                    this._maskDiv.className="Main_Mask_Div";
                    documentObj.body.appendChild(this._maskDiv);
                }
                if (G("div_obj")) {
                    G("div_obj").style.display = "none";
                    // 视频层关闭
                }
                if (G("temp_div_obj")) {
                    G("temp_div_obj").style.display = "none";
                    // 视频层关闭
                }
            } catch(E) {
                alert(E);
            }
        }
    },

    flashClose:function() {
        this.xWin.style.left = this.left;
        this.xWin.style.top = this.top;
        this._fix = false;
        this._isshow = true;
        this._state = "default";

        this.resize_window_bycenter(this.width, this.height,this._minwidth, this._minheight,  parseInt(this.left) + parseInt(this.width) / 2, this.top,parseInt(document.body.clientHeight-this._minheight)-20 );

        //this.tdimgclose.style.display = "";
        //this.xWin.style.display = "";
    } ,
    //关闭函数
    close:function() {
        if (this.isParent == "true") {
            this._isshow = false;
            this.content = "";
            documentObj = window.parent.document;
        } else {
            this._isshow = false;
            this.content = "";
            documentObj = window.document;
        }
        this.tdimgclose.style.display = "none";
        //*this.flashClose();

        this.xWin.style.display = "none";
        try {
            if (G("Main_Div")) {
               //* G("Main_Div").style.display = "none";
                documentObj.body.removeChild(this._maskDiv);
                var obj =  G("Main_Div") ;
                var num = obj.getAttribute("MaskNum") ;
                if (num >= 0) {
                    obj.setAttribute("MaskNum", parseInt(num) - 1);
                }
                num = obj.getAttribute("MaskNum") ;
                if(num<=0) {
                   documentObj.body.style.overflow = "hidden";
                }
                num = null ;  obj = null ;
                this._maskDiv = null;
            }
            if (G("div_obj")) {
                G("div_obj").style.display = "";
                // 视频层关闭
            }
            if (G("temp_div_obj")) {
                G("temp_div_obj").style.display = "";
                // 视频层关闭
            }
        } catch(e) {
            alert(e);
        }

        this.isShow = 0;
        try {
            if (this.frame_id) {  //清空Frame 防止焦点问题
                try {
                    if (window.frames("innerFrame" + this.frame_id)) {
                        window.frames("innerFrame" + this.frame_id).document.body.innerHTML = "";
                        this.iframebody.src = "" ;
                         //window.frames("innerFrame" + this.frame_id).src = "" ;
                    }
                } catch(e) {

                }
            }
            this._flashOver = false ;
            this.client.innerHTML= null;;
            CollectGarbage();
            //alert(this.client.innerHTML) ;

        }
        catch(e) {
            alert(e);
            return;
        }
        return;
    },

//最大化窗体
    max:  function() {
        //通过resize来操作
    },
//窗体放缩开始
    startResize: function(event, obj) {
        this._fix = this._isFix;
        //alert(this._fix);
        var scrollTop = 0 ;
        var scrollLeft = 0 ;
        if (this.isParent == "true") {
            var oEvent = window.parent.event ? window.parent.event : event;
            scrollTop = window.parent.document.body.scrollTop;
            scrollLeft = window.parent.document.body.scrollLeft;
        } else {
            documentObj = window.document;
            var oEvent = window.event ? window.event : event;
            scrollTop = document.body.scrollTop;
            scrollLeft = document.body.scrollLeft;
        }
        if (this._fix == false) {
            if (this._shadowDiv == null) {
                try{
                this._shadowDiv = documentObj.createElement("DIV");
                this._shadowDiv.style.cssText = "filter:alpha(Opacity=10,style=0);opacity:0.2;width:" + this.width + "px;height:" + this.height + "px;top:" + this.xWin.style.top.replace("px","") + "px;left:" + this.xWin.style.left.replace("px","") + "px;position:absolute;background:#000";
                documentObj.body.appendChild(this._shadowDiv);
                }catch(e){

                }
            }
            obj.setCapture ? obj.setCapture() : function() {
            };
            //obj.setCapture();
            this._x0 = oEvent.clientX;
            this._y0 = oEvent.clientY;
            this._x1 = parseInt(this.xWin.style.left);
            this._y1 = parseInt(this.xWin.style.top);
            this._canmove = true;
        } else {
        }
    },
//改变大小
    Resize:function(event) {
        if (this.isParent == "true") {
            documentObj = window.parent.document;
            var oEvent = window.parent.event ? window.parent.event : event;
        } else {
            documentObj = window.document;
            var oEvent = window.event ? window.event : event;
        }
        if (this._canmove == true) {
            var x = oEvent.clientX - this._x1;
            var y = oEvent.clientY - this._y1;
            //限制窗体移动范围
            x = x < this._minwidth ? this._minwidth : x;
            y = y < this._minheight ? this._minheight : y;
            if (this.checkIExWin() == IE5) {
                x = x > documentObj.body.offsetWidth - this.left - 10   ?documentObj.body.offsetWidth - this.left - 10: x;
                y = y > documentObj.body.offsetHeight - this.top - 20 ?documentObj.body.offsetHeight - this.top - 20 : y;
            }
            try{
            this._shadowDiv.style.width = x;
            this._shadowDiv.style.height = y;
             }catch(e){

            }
        }
    },
    resize_window:function(begin_width, begin_height, end_width, end_height) {
        timerresize = null;
        var isStopX = false ;
        var isStopY = false;
        var widthnew = null ;
        var heightnew = null ;
        var lenX = Math.abs(end_width - begin_width) ;
        var lenY = Math.abs(end_height - begin_height) ;
        var pernum = 30 ;
        if (lenX > 500 || lenY > 500) {
            pernum = 80;
        } else if (lenX > 300 || lenY > 300) {
            pernum = 60;
        }

        var xGo = pernum ;
        var yGo = pernum ;
        if (lenX > 0) {
            yGo = Math.round(pernum * lenY / lenX);
        } else {
            yGo = pernum;
        }
        //if (this._canmove == true) {
        if (begin_width - end_width > 0 && Math.abs(begin_width - end_width) > xGo) {
            widthnew = parseInt(begin_width) - xGo;
        } else if (begin_width - end_width < 0 && Math.abs(begin_width - end_width) > xGo) {
            widthnew = parseInt(begin_width) + xGo;
        } else {
            widthnew = end_width;
            isStopX = true;
        }
        //alert(lenX + " " + lenY + " " + xGo + " " + yGo);
        if (begin_height - end_height > 0 && Math.abs(begin_height - end_height) > yGo) {
            heightnew = parseInt(begin_height) - yGo;
        } else if (begin_height - end_height < 0 && Math.abs(begin_height - end_height) > yGo) {
            heightnew = parseInt(begin_height) + yGo;
        } else {
            isStopY = true
            heightnew = end_height;
        }
        this.setSize(widthnew, heightnew);
        begin_width = this.xWin.style.width.replace("px", "");
        begin_height = this.xWin.style.height.replace("px", "");
        var oThis = this ;
        if (isStopX == false || isStopY == false) {
            timerresize = setTimeout(function() {
                oThis.resize_window(begin_width, begin_height, end_width, end_height)
            }, 1);
        }
    },
//根据中轴线进行放缩
    resize_window_bycenter:function(begin_width, begin_height, end_width, end_height, begin_left, begin_top, end_top, have_go_top) {
        timerresize2 = null;
        if (!have_go_top) {
            have_go_top = 0;
        }
        var isStopX = false ;
        var isStopY = false;
        var widthnew = null ;
        var heightnew = null ;
        var leftnew = null ;
        var topnew = null ;
        var lenX = Math.abs(end_width - begin_width) ;
        var lenY = Math.abs(end_height - begin_height) ;
        var lenTop = (begin_top - end_top - end_height) ;
        //top变化量
        var pernum = 50 ;
        if(this.width>500) {
           pernum = 200 ;
        }

        if (lenX > 500 || lenY > 500) {
            pernum = 150;
        } else if (lenX > 300 || lenY > 300) {
            pernum = 120;
        }

        var xGo = pernum ;
        var yGo = pernum ;
        var topGo = pernum ;
        if (lenX > 0) {
            yGo = Math.round(pernum * lenY / lenX);
        } else {
            yGo = pernum;
        }
        if (lenTop < 0) {   //向下跑
           // lenTop = 0;
        }
        //alert("lenx="+lenX+" xGo="+xGo+" leny="+lenY+" ygo=" + yGo);
        if (begin_width - end_width > 0 && Math.abs(begin_width - end_width) > xGo) {
            widthnew = parseInt(begin_width) - xGo;
        } else if (begin_width - end_width < 0 && Math.abs(begin_width - end_width) > xGo) {
            widthnew = parseInt(begin_width) + xGo;
        } else {
            widthnew = end_width;
            isStopX = true;
        }

        //alert(lenX + " " + lenY + " " + xGo + " " + yGo);
        if (begin_height - end_height > 0 && Math.abs(begin_height - end_height) > yGo) {
            heightnew = parseInt(begin_height) - yGo;
        } else if (begin_height - end_height < 0 && Math.abs(begin_height - end_height) >  Math.abs(yGo)) {
            heightnew = parseInt(begin_height) + yGo;
        } else {
            isStopY = true
            heightnew = end_height;
        }
        leftnew = begin_left - parseInt(widthnew) / 2;
        if (lenTop == 0) {
            topnew = begin_top - parseInt(heightnew);
        } else  if (!isStopX) {
            if (lenY > lenX) {
                topGo = (xGo * lenTop) / lenX;
            } else {
                topGo = (yGo * lenTop) / lenY;
            }
            if (lenY > 0) {
                topnew = begin_top - parseInt(heightnew) - have_go_top - topGo;
            } else if (lenY < 0) {
                topnew = begin_top - parseInt(heightnew) + have_go_top + topGo;
            }
            if (topnew <= end_top) {
                topnew = end_top;
            }
            //alert("topnew="+topnew+"end_top="+end_top+"begin_top=" + begin_top + "heightnew=" + heightnew + "have_go_top=" + have_go_top + "topGo=" + topGo);
            have_go_top = have_go_top + topGo;
        } else {
            //alert("end_top="+topGo);
            topnew = end_top;
        }

        this.setPosition(leftnew, topnew-parseInt(document.body.scrollTop));
        this.setSize(widthnew, heightnew);
        begin_width = this.xWin.style.width.replace("px", "");
        begin_height = this.xWin.style.height.replace("px", "");
        //if (begin_y < end_y && begin_x < end_x) {
        var oThis = this ;
        if (isStopX == false || isStopY == false) {
            this._flashOver = false ;
            timerresize2 = setTimeout(function() {
                oThis.resize_window_bycenter(begin_width, begin_height, end_width, end_height, begin_left, begin_top, end_top, have_go_top)
            },2);
        }else{
            this._flashOver = true ;
        }
    },
//改变大小结束
    stopResize:function(event, obj) {
        try{
        if (this.isParent == "true") {
            documentObj = window.parent.document;
            var oEvent = window.parent.event ? window.parent.event : event;
        } else {
            documentObj = window.document;
            var oEvent = window.event ? window.event : event;
        }
        if (this._fix == false) {
            var x = this._shadowDiv.style.width.replace("px", "");
            var y = this._shadowDiv.style.height.replace("px", "");
            documentObj.body.removeChild(this._shadowDiv);
            this._shadowDiv = null;
            this.resize_window(this.xWin.style.width.replace("px", ""), this.xWin.style.height.replace("px", ""), x, y);
            obj.releaseCapture ? obj.releaseCapture() : function() {
            };
            this._canmove = false;
        }
        } catch(e) {

        }
    },

//窗体拖动开始
    startDrag: function(event, obj) {
        this._fix = this._isFix;
        //alert(this._fix);
        var scrollTop = 0 ;
        var scrollLeft = 0 ;
        if (this.isParent == "true") {
            var oEvent = window.parent.event ? window.parent.event : event;
            scrollTop = window.parent.document.body.scrollTop;
            scrollLeft = window.parent.document.body.scrollLeft;
        } else {
            documentObj = window.document;
            var oEvent = window.event ? window.event : event;
            scrollTop = document.body.scrollTop;
            scrollLeft = document.body.scrollLeft;
        }
        if (this._fix == false) {
            if (this._shadowDiv == null) {
                this._shadowDiv = documentObj.createElement("DIV");
                this._shadowDiv.style.cssText = "filter:alpha(Opacity=10,style=0);opacity:0.2;width:" + this.width + "px;height:" + this.height + "px;top:" + this.xWin.style.top.replace("px","") + "px;left:" + this.xWin.style.left.replace("px","") + "px;position:absolute;background:#000";
                documentObj.body.appendChild(this._shadowDiv);
            }
            obj.setCapture ? obj.setCapture() : function() {
            };
            this._x0 = oEvent.clientX;
            this._y0 = oEvent.clientY;
            this._x1 = parseInt(this.xWin.style.left);
            this._y1 = parseInt(this.xWin.style.top);
            this._canmove = true;
        } else {
            // alert(this._fix) ;
        }
    },
//窗体拖动---阴影
    drag: function(event) {
        try{
        if (this.isParent == "true") {
            documentObj = window.parent.document;
            var oEvent = window.parent.event ? window.parent.event : event;
        } else {
            documentObj = window.document;
            var oEvent = window.event ? window.event : event;
        }
        if (this._canmove == true) {
            var x = this._x1 + oEvent.clientX - this._x0;
            var y = this._y1 + oEvent.clientY - this._y0;
            //限制窗体移动范围
            x = x < 5 ? 5 : x;
            y = y < 5 ? 5 : y;
            if (this.checkIExWin() == IE5) {
                x = x > documentObj.body.offsetWidth - this.width - 30   ?documentObj.body.offsetWidth - this.width - 30: x;
                // y = y > documentObj.body.offsetHeight - this.height - 20 ?documentObj.body.offsetHeight - this.height - 20 : y;
            }
            this._shadowDiv.style.left = x;
            this._shadowDiv.style.top = y;
        }
        } catch(e) {

        }
    },
//窗体拖动---窗口
    drag_window: function(begin_x, begin_y, end_x, end_y) {
        timerdrag = null;
        var isStopX = false ;
        var isStopY = false;
        var pernum = 35 ;
        var lenX = Math.abs(end_x - begin_x) ;
        var lenY = Math.abs(end_y - begin_y) ;

        var xGo = pernum ;
        var yGo = pernum ;
        if (lenX > 0) {
            yGo = Math.round(pernum * lenY / lenX);
        } else {
            yGo = pernum;
        }
        if (begin_x - end_x > 0 && Math.abs(begin_x - end_x) > xGo) {
            this.xWin.style.left = parseInt(begin_x) - xGo;
        } else if (begin_x - end_x < 0 && Math.abs(begin_x - end_x) > xGo) {
            this.xWin.style.left = parseInt(begin_x) + xGo;
        } else {
            this.xWin.style.left = end_x;
            isStopX = true;
        }
        if (begin_y - end_y > 0 && Math.abs(begin_y - end_y) > yGo) {
            this.xWin.style.top = parseInt(begin_y) - yGo;
        } else if (begin_y - end_y < 0 && Math.abs(begin_y - end_y) > yGo) {
            this.xWin.style.top = parseInt(begin_y) + yGo;
        } else {
            isStopY = true
            this.xWin.style.top = end_y;

        }
        //alert(lenX + " " + lenY + " " + xGo + " " + yGo+" "+isStopX +" "+isStopY);
        begin_x = this.xWin.style.left.replace("px", "");
        begin_y = this.xWin.style.top.replace("px", "");
        this.left = begin_x;
        //重新设置值
        this.top = begin_y;
        var oThis = this ;
        if (isStopX == false || isStopY == false) {
            timerdrag = setTimeout(function() {
                oThis.drag_window(begin_x, begin_y, end_x, end_y)
            }, 10);
        }
    },

//窗体拖动结束
    stopDrag:function(event, obj) {
        try{
        if (this.isParent == "true") {
            documentObj = window.parent.document;
            var oEvent = window.parent.event ? window.parent.event : event;
        } else {
            documentObj = window.document;
            var oEvent = window.event ? window.event : event;
        }
        if (this._fix == false) {
            var x = this._shadowDiv.style.left.replace("px", "");
            var y = this._shadowDiv.style.top.replace("px", "");
            documentObj.body.removeChild(this._shadowDiv);
            this._shadowDiv = null;
            this.drag_window(this.xWin.style.left.replace("px", ""), this.xWin.style.top.replace("px", ""), x, y);

            obj.releaseCapture ? obj.releaseCapture() : function() {
            };
            this._canmove = false;
        }
        } catch(e) {

        }
    },
//
    getisShow:function() {
        return this._isshow;
    },
    getLeftPosition:function() {
        var l = this.xWin.style.left ;
        return l.replace("px", "");
    },
    getTopPosition:function() {
        var t = this.xWin.style.top ;
        return t.replace("px", "");
    },
//设定窗体的当前位置 :
    setPosition:function(leftnew, topnew) {
        var scrollTop = 0 ;
        if (this.isParent == "true") {
            scrollTop = window.parent.document.body.scrollTop;
        } else {
            scrollTop = document.body.scrollTop;
        }
        this.xWin.style.left = parseInt(leftnew);
        this.xWin.style.top =  parseInt(scrollTop) + parseInt(topnew);
        this.left = parseInt(leftnew);
        this.top =  parseInt(scrollTop) + parseInt(topnew);
        //alert(this.top);
    },
//设定窗体的大小
    setSize:function(widthnew, heightnew) {
        this.width = widthnew;
        this.height = heightnew;
        this.xWin.style.width = this.width;
        this.xWin.style.height = this.height;
        this.titlebar.style.width = this.width;
        this.titlecontent.style.width = this.width - this._leftWidth - this._rightWidth;
        this.clientMain.style.width = this.width;
        this.clientMain.style.height = this.height - this._titleHeight - this._bottomHeight;
        this.client_left.style.height = this.height - this._titleHeight - this._bottomHeight;
        this.client.style.width = this.width - this._leftWidth - this._rightWidth;
        this.client.style.height = this.height - this._titleHeight - this._bottomHeight;
        this.client_right.style.height = this.height - this._titleHeight - this._bottomHeight;
        this.win_bottom.style.width = this.width;
        this.bottom_mid.style.width = this.width - this._leftWidth - this._rightWidth
    },

    getFrameId:function() {
        return "innerFrame" + this.frame_id;
    },
    getzIndex:function() {
        return  this.xWin.style.zIndex;
    },
//设定层的index
    setzIndex:function(zIndexNum) {
        this.xWin.style.zIndex = zIndexNum;
    },
    setFocus:function(zIndexNum) {
        //alert(zIndexNum);
        this.setzIndex(zIndexNum + 2);
        setzIndexMax(zIndexNum + 2);
    },
//窗体的标题
    setTitle: function (sTitle, bText) {
        //var iWidth = _getWidth(sTitle, "10pt");
        this.title = sTitle;
        this.col03.innerHTML = sTitle;
    },
    setClientByObject: function (obj) {
        //this.iframebody = null ;
        this.client.innerHTML = "";
        this.client.appendChild(obj);
    },
    setContentStr:function(str, leftPadding, topPadding, rightPadding, bottomPadding) {
        if (!leftPadding) {
            leftPadding = "5px";
        }
        if (!topPadding) {
            topPadding = "5px";
        }
        if (!rightPadding) {
            rightPadding = "5px";
        }
        if (!bottomPadding) {
            bottomPadding = "5px";
        }
        this.client.style.paddingTop = topPadding;
        this.client.style.paddingLeft = leftPadding;
        this.client.style.paddingRight = rightPadding;
        this.client.style.paddingBottom = bottomPadding;
        this.client.innerHTML = str;
    },
//设置内容区的内容
    setcontent: function(obj) {
        loadtimer = null ;
        //this.iframebody.src = "";
        if (this._flashOver == true) {
            if (this.isParent == "true") {
                documentObj = window.parent.document;
                this.client.innerHTML = obj;
            } else {
                documentObj = window.document;
            }
            try {
                this.client.innerHTML = this.frameHtml;
                iframebody = documentObj.getElementById("innerFrame" + this.frame_id);
                this.iframebody = iframebody;
                try {
                    iframebody.src = obj;
                } catch(e) {
                }
                with (iframebody.style) {
                    width = "99%";
                    height = "99%";
                }
                if (this._isshow == false) {
                    // this.show();
                }
            } catch(E) {
            }
        } else {
            try {
                this.client.innerHTML = "<div style='padding:10px'>页面加载中.....</div>";
            } catch(E) {
            }
            var oThis = this ;
            loadtimer = setTimeout(function() {
                oThis.setcontent(obj)
            }, 100);
        }
    },
//释放函数  不能直接在调用中使用 对象=null
    free: function() {
        with (this) {
            tdimgclose.onmouseup = null;
            tdimgclose.onmousedown = null;
            tdimgclose.onmouseover = null;
            tdimgclose.onmouseout = null;
            tdimgmax.onclick = null;
            tdimgmax.onmouseover = null;
            tdimgmax.onmouseout = null;
            titlebar.onmousedown = null;
            titlebar.onmousemove = null;
            titlebar.onmouseup = null;
            titlebar.ondblclick = null;
            titlebar.onclick = null;
            client.onclick = null;
            tdimgclose.onclick = null;
            bottom_right.onmouseup = null;
            bottom_right.onmousedown = null;
            bottom_right.onmousemove = null;

            //关闭按钮
            titletr = null;
            width = null;
            height = null;
            left = null;
            top = null;
            xWin = null;
            col03 = null;
            bottom_right = null;
        }
    }
}


//关闭自定义窗口
function do_close_xwin(obj) {
    if (obj) {
        obj.close();
    } else {
        mywin_main.close();
    }
}

