if(typeof(_sysDom)=="undefined")alert("Can not find the _sysDom object!");
_sysDom.importFile("/ETSOO/Eajax/Window/Themes/Default.css");
function ETSOOWindow(sConfig)
{
    this.path="/ETSOO/Eajax/Window/";
    this.name=_sysDom.getID("window");
    this.maximumSize=[];
    this.screenSize=[_sysDom.getClientWidth(self),_sysDom.getClientHeight(self)];
	if(_sysDom.browser.name=="msie"&&document.documentElement.clientWidth==0)this.screenSize[0]+=16;
    this.minimumSize=[150,120];
    this.lockedPoints=[];
    this.readyState=0;
    this.container=null;
    this.controlDiv=null;
    this.objects=[];
    this.basePoints=[];
    this.content=null;
    this.url=null;
    this.isUrl=false;
    this.isTitleBarAction=true;
    this.sizeMode="normal";
    this.styleObject=null;
    this.coverFrame=null;
    this.coverFrameBgColor="#dddddd";
    this.coverFrameOpacity=80;
    this.focusResult=1;
	this.adjustHeight=2;
    this._interval=null;
    this._bodyScroll=true;
    
    this.configs={
        bgcolor:null,
        bottomdraggable:"no",
        boxalign:"right",
        center:"yes",
        closable:"yes",
        controlbox:"yes",
        draggable:"yes",
        height:null,
        hide:"no",
        layoutpadding:4,
        left:null,
        maximizable:"yes",
        minimizable:"yes",
        modal:"no",
        opacity:60,
        padding:4,
        resizable:"yes",
        status:"no",
        statustext:"",
        theme:"winxp",
        title:"ETSOO Window",
        titlebar:"yes",
        top:null,
        topmost:"yes",
        width:null
    }
    this.loadConfigs(sConfig);
    
    this.parent=null;
    this.children=[];

    this.onShow=null;
    this.onFocus=null;
    this.onClose=null;
    this.onInit=null;
    this.onReload=null;
    this.onMinimize=null;
    this.onMaximize=null;
    this.onMove=null;
    this.onResize=null;
    this.onRestore=null;
    this.onChildEvent=null;
    this.onParentEvent=null;
    
    this.id=ETSOOWindow.Global.add(this);
}
ETSOOWindow.Global={
    id:-1,
    all:[],
    add:function(oWin){this.id++;this.all[this.id]=oWin;return this.id;},
    getWindowById:function(iId){return this.all[iId];},
    getWindowByName:function(sName){var iLen=this.all.length;for(var i=0;i<iLen;i++){var oW=this.all[i];if(oW.name==sName)return oW;}}
}
ETSOOWindow.CurrentZIndex=10;
ETSOOWindow.ActiveWindow=null;
ETSOOWindow.TitleBarAction=function(oEvent)
{
    if(oEvent==null)oEvent=window.event;
    var oWin=ETSOOWindow.ActiveWindow;
    if(oWin)oWin.minimize();
    _sysDom.cancelEvent(oEvent);
}
ETSOOWindow.DoInterval=function(iId)
{
    var oWin=ETSOOWindow.Global.getWindowById(iId);
    if(oWin)
    {
        var oStyle=oWin.styleObject;
        var aRules=[];
        try
        {
            aRules=oStyle.cssRules||oStyle.rules;
        }
        catch(e)
        {
            aRules=[];
        }
        if(aRules.length>0)
        {
            window.clearInterval(oWin._interval);
            oWin.testSize();
            oWin.readyState=4;
            oWin.setTitle();
            if(oWin.url)oWin.setUrl();
            else if(oWin.content)oWin.setContent();
            oWin.setStatus();
            
            if(!oWin.testKey("hide"))oWin.hide(false);
        }
    }
}
ETSOOWindow.GetWindow=function(oT)
{
    while(oT&&(oT.nodeName!="DIV"||oT.className!=_sysDom.browser.name))oT=oT.parentNode;
    if(oT)
    {
        var sId=oT.id;
        if(sId)
        {
            var iPos=sId.lastIndexOf("_");
            if(sId.substr(0,iPos)=="ETSOOWindowContainer")
            {
                return ETSOOWindow.Global.getWindowById(sId.substr(iPos+1));
            }
        }
    }
}
ETSOOWindow.InitDrag=function(oEvent)
{
    var oT=_sysDom.getEventTarget(oEvent);
    var oTD=oT;
    while(oTD&&(oTD.nodeName!="TD"||oTD.className==null||oTD.className==""))oTD=oTD.parentNode;
    var oWin=ETSOOWindow.GetWindow(oT);
    if(oWin)ETSOOWindow.ActiveWindow=oWin;
    if(oWin==null)return;
    if(oTD)
    {
        var sAction=null;
        var sPara=null;
        var sClassName=oTD.className;
        var iPos=sClassName.lastIndexOf("_");
        if(iPos!=-1&&sClassName.substr(0,iPos)==oWin.configs.theme)
        {
            sClassName=sClassName.substr(iPos+1);
            switch(sClassName)
            {
                case "title":
                    sAction="move";
                    if(oWin.testKey("draggable")&&oWin.sizeMode!="max")sPara="";
                    break;
                case "status":
                    sAction="move";
                    if(oWin.testKey("bottomdraggable")&&oWin.sizeMode!="max")sPara="";
                    break;
                case "min":
                case "max":
                case "close":
                    sAction="button";
                    sPara=sClassName;
                    break;
                default:
                    if(sClassName=="w0"||sClassName=="nw1"||sClassName=="sw0")sPara="w";
                    else if(sClassName=="e0"||sClassName=="ne1"||sClassName=="se0")sPara="e";
                    else if(sClassName=="n0")sPara="n";
                    else if(sClassName=="s1")sPara="s";
                    else if(sClassName=="nw0")sPara="nw";
                    else if(sClassName=="se1"||sClassName=="resize")sPara="se";
                    else if(sClassName=="ne0")sPara="ne";
                    else if(sClassName=="sw1")sPara="sw";
                    
                    if(sPara!=null)sAction="resize";
                    if(sAction=="resize"&&(!oWin.testKey("resizable")||oWin.sizeMode!="normal"))sPara=null;
                    break;
            }
            oWin._currentAction=sAction;
            oWin._currentPara=sPara;
            if(sAction!=null&&sPara!=null)
            {
                oWin._currentPoints=_sysDom.eventPoints(oEvent,document);
            }
            else
            {
                oWin._currentPoints=[];
            }
        }
        var iResult=oWin.focusResult;
        if(iResult>0)
        {
            if(iResult==1)
            {
                if(sAction!="move")iResult=0;
            }
            if(iResult>0)oWin.toTopMost();
        }
    }
    if(oWin._currentAction!=null)
    {
        _sysDom.cancelEvent(oEvent);
    }
}
ETSOOWindow.UpdateDrag=function(oEvent)
{
    var oWin=ETSOOWindow.ActiveWindow;
    if(oWin==null)return;
    if(oWin._currentPoints.length==2&&oWin._currentAction!=null)
    {
        if(_sysDom.browser.name=="msie"&&oEvent.button!=1)
        {
            ETSOOWindow.EndDrag(oEvent);
        }
        else
        {
            var sAction=oWin._currentAction;
            var sPara=oWin._currentPara;
            var aBase=oWin._currentPoints;
            var aNew=_sysDom.eventPoints(oEvent);
            var iX=aNew[0]-aBase[0];
            var iY=aNew[1]-aBase[1];
            if(sAction=="button")
            {
                if(iX>5||iY>5)oWin._currentAction=null;
                return false;
            }

            var iLeft=oWin.configs.left;
            var iTop=oWin.configs.top; 
            var iWidth=null;
            var iHeight=null;
            if(sAction=="move")
            {
                if(oWin.onMove!=null)
                {
                    if(oWin.onMove()==false)return false;
                }
                if(oWin.deliverEvent("move",[oEvent])==false)return false;
                var aLocks=oWin.lockedPoints;
                if(aLocks[0]==null)aLocks[0]=[];
                if(aLocks[1]==null)aLocks[1]=[];
                var iMinL=aLocks[0][0];
                var iMinT=aLocks[0][1];
                var iMaxL=aLocks[1][0];
                var iMaxT=aLocks[1][1];
                iLeft+=iX;
                if(iLeft<0)iLeft=0;
                else
                {
                    if(iMinL!=null)
                    {
                        if(iLeft<iMinL)iLeft=iMinL;
                    }
                    if(iMaxL!=null)
                    {
                        if(iLeft+oWin.configs.width>iMaxL)iLeft=null;
                    }
                }
                iTop+=iY;
                if(iTop<0)iTop=0;
                else
                {
                    if(iMinT!=null)
                    {
                        if(iTop<iMinT)iTop=iMinT;
                    }
                    if(iMaxT!=null)
                    {
                        if(iTop+oWin.configs.height>iMaxT)iTop=null;
                    }
                }
            }
            else if(sAction=="resize")
            {
                if(oWin.onResize!=null)
                {
                    if(oWin.onResize()==false)return false;
                }
                if(oWin.deliverEvent("resize",[oEvent])==false)return false;
                iWidth=oWin.configs.width;
                iHeight=oWin.configs.height;
            
                switch(sPara)
                {
                    case "n":
                        iHeight-=iY;
                        iTop+=iY;
                        break;
                    case "s":
                        iHeight+=iY;
                        break;
                    case "w":
                        iWidth-=iX;
                        iLeft+=iX;
                        break;
                    case "e":
                        iWidth+=iX;
                        break;
                    case "nw":
                        iWidth-=iX;
                        iHeight-=iY;
                        iLeft+=iX;
                        iTop+=iY;
                        break;
                    case "ne":
                        iWidth+=iX;
                        iHeight-=iY;
                        iTop+=iY;
                        break;
                    case "sw":
                        iWidth-=iX;
                        iHeight+=iY;
                        iLeft+=iX;
                        break;
                    case "se":
                        iWidth+=iX;
                        iHeight+=iY;
                        break;
                }
                var aMin=oWin.minimumSize;
                var iMinW=aMin[0];
                var iMinH=aMin[1];
                var aMax=oWin.maximumSize;
                var iMaxW=aMax[0];
                var iMaxH=aMax[1];
                if(iWidth<iMinW||iWidth>iMaxW)
                {
                    iWidth=null;
                    iLeft=null;
                }
                if(iHeight<iMinH||iHeight>iMaxH)
                {
                    iHeight=null;
                    iTop=null;
                }
                if(iLeft<0)
                {
                    iLeft=null;
                    iWidth=null;
                }
                if(iTop<0)
                {
                    iTop=null;
                    iHeight=null;
                }
            }
            oWin._setSameSize(iWidth,iHeight,iLeft,iTop,(sAction=="move"?1:0));
            oWin._currentPoints=aNew;
            if(sAction=="resize")
            {
                oWin.sizeMode="normal";
                oWin.testSize();
            }
        }
    }
    if(oWin._currentAction!=null)
    {
        _sysDom.cancelEvent(oEvent);
    }
}
ETSOOWindow.EndDrag=function(oEvent)
{
    var oWin=ETSOOWindow.ActiveWindow;
    if(oWin==null)return;

    var sAction=oWin._currentAction;
    var sPara=oWin._currentPara;
    if(sAction=="button")
    {
        if(sPara=="max")oWin.maximize();
        if(sPara=="min")oWin.minimize();
        if(sPara=="close")oWin.close();
    }
    else
    {
        var sSizeMode=oWin.sizeMode;
        if(sSizeMode!="max")
        {
            if(sSizeMode=="normal")
            {
                oWin.basePoints[0]=oWin.configs.width;
                oWin.basePoints[1]=oWin.configs.height;
            }
            oWin.basePoints[2]=oWin.configs.left;
            oWin.basePoints[3]=oWin.configs.top;
        }
    }
    if(oWin._currentAction!=null)
    {
        _sysDom.cancelEvent(oEvent);
    }
    oWin._currentAction=null;
    oWin._currentPoints=[];
}
_sysDom.attachEvent(document,"onmousedown",ETSOOWindow.InitDrag);
_sysDom.attachEvent(document,"onmousemove",ETSOOWindow.UpdateDrag);
_sysDom.attachEvent(document,"onmouseup",ETSOOWindow.EndDrag);

ETSOOWindow.prototype.loadConfigs=function(sConfig)
{
    if(sConfig)
    {
        var aConfigs=sConfig.split(new RegExp("[,;]","gi"));
        var iLen=aConfigs.length;
        for(var i=0;i<iLen;i++)
        {
            var aOnes=aConfigs[i].split(new RegExp("[:=]","gi"));
            if(aOnes.length==2)
            {
                var sKey=aOnes[0].toLowerCase();
                sKey=sKey.replace(new RegExp("^\\s","gi"),"");
                sKey=sKey.replace(new RegExp("\\s$","gi"),"");
                var sValue=aOnes[1];
                sValue=sValue.replace(new RegExp("^\\s","gi"),"");
                sValue=sValue.replace(new RegExp("\\s$","gi"),"");
                var iValue=parseInt(sValue,10);
                if(isNaN(iValue))iValue=null;
                switch(sKey)
                {
                    case "dialogwidth":
                    case "width":
                        sKey="width";
                        if(iValue)sValue=iValue;
                        break;
                    case "dialogheight":
                    case "height":
                        sKey="height";
                        if(iValue)sValue=iValue;
                        break;
                    case "dialogtop":
                    case "top":
                        sKey="top";
                        if(iValue!=null)sValue=iValue;
                        break;
                    case "dialogleft":
                    case "left":
                        sKey="left"
                        if(iValue!=null)sValue=iValue;
                        break;
                    case "padding":
                    case "layoutpadding":
                    case "opacity":
                        if(iValue!=null)sValue=iValue;
                        break;
                }
                if(sValue!="")this.configs[sKey]=sValue;
            }
        }
    }
    if(this.configs.width==null)
    {
        this.configs.width=this.screenSize[0];
    }
    else
    {
        if(this.configs.width<this.minimumSize[0])this.configs.width=this.minimumSize[0];
        else if(this.maximumSize[0]&&this.configs.width>this.maximumSize[0])this.configs.width=this.maximumSize[0];
    }
    if(this.configs.height==null)
    {
        this.configs.height=this.screenSize[1];
    }
    else
    {
        if(this.configs.height<this.minimumSize[0])this.configs.height=this.minimumSize[0];
        else if(this.maximumSize[1]&&this.configs.height>this.maximumSize[1])this.configs.height=this.maximumSize[1];
    }
    if(this.testKey("center")||this.configs.left==null||this.configs.top==null)
    {
        if(this.configs.left==null)this.configs.left=Math.round((this.screenSize[0]-this.configs.width)/2);
        if(this.configs.top==null)this.configs.top=Math.round((this.screenSize[1]-this.configs.height)/2);
    }
    if(!this.testKey("controlbox"))
    {
        this.configs.maximizable="no";
        this.configs.minimizable="no";
        this.configs.closable="no";
    }
    else if(!this.testKey("maximizable")&&!this.testKey("minimizable")&&!this.testKey("closable"))
    {
        this.configs.controlbox="no";
    }
    if(this.readyState==4)this.reload();
}
ETSOOWindow.prototype.setCenter=function()
{
    var scrollSize=_sysDom.getScrollSize();
    this.moveTo(Math.round((this.screenSize[0]-this.configs.width)/2)+scrollSize[0],Math.round((this.screenSize[1]-this.configs.height)/2)+scrollSize[1]);
}
ETSOOWindow.prototype.add=function(oWin)
{
    this.children.push(oWin);
    oWin.parent=this;
}
ETSOOWindow.prototype.testKey=function(sKey)
{
    var sValue=this.configs[sKey];
    if(sValue=="1"||sValue=="yes")return true;
    else return false;
}
ETSOOWindow.prototype.deliverEvent=function(sEvent,aArgs,oF,iType)
{
    if(sEvent!=null)sEvent=sEvent.toLowerCase();
    if(oF==null)iType=null;
    else if(iType==null)oF=null;
    var oParent=this.parent;
    var bR=true;
    if(iType!=1&&oParent!=null&&oParent.readyState==4&&oParent.onChildEvent!=null)
    {
        var aR=oParent.onChildEvent(sEvent,aArgs);
        var bT=aR;
        if(typeof(aR)=="object")
        {
            bT=aR[0];
            bR=aR[1];
        }
        if(bR&&bT!=false)oParent.deliverEvent(sEvent,aArgs,this,0);
    }
    if(bR)
    {
        var iLen=this.children.length;
        for(var i=0;i<iLen;i++)
        {
            var oOne=this.children[i];
            if(oOne!=null&&oOne.readyState==4&&oOne.onParentEvent!=null&&(iType!=0||(iType==0&&oOne.name!=oF.name))){
                var aR=oOne.onParentEvent(sEvent,aArgs);
                var bT=aR;
                if(typeof(aR)=="object")
                {
                    bT=aR[0];
                    bR=aR[1];
                }
                if(bT!=false)oOne.deliverEvent(sEvent,aArgs,this,1);
            }
        }
    }
    return bR;
}
ETSOOWindow.prototype.show=function(iLeft,iTop)
{
    var oBody=document.getElementsByTagName("body")[0];
    if(oBody==null)return;    
    
    if(this.readyState==0)
    {
        this.readyState=1;
        if(this.onInit)this.onInit();
        if(this.deliverEvent("init")==false)return false;
        
        if(iLeft!=null)this.configs.left=iLeft;
        if(iTop!=null)this.configs.top=iTop;
        
        this.styleObject=_sysDom.importStylesheet(this.path+"Themes/"+this.configs.theme.toLowerCase()+".css",self.document);
        this._getStructure(oBody);
    }
    else
    {
        if(iLeft!=null||iTop!=null)this.moveTo(iLeft,iTop);
        this.hide(false);
    }
    if(this.onShow!=null)
    {
        if(this.onShow()==false)return false;
    }
    if(this.deliverEvent("show")==false)return false;
}
ETSOOWindow.prototype.setAlert=function(sTheme)
{
    if(sTheme==null)sTheme=this.configs.theme;
    else this.configs.theme=sTheme;
    this.configs.draggable="no";
    this.configs.resizable="no";
    this.configs.status="no";
    this.configs.maximizable="no";
    this.configs.minimizable="no";
    this.configs.modal="yes";
    if(this.readyState>=2)
    {
        this.reload();
    }
}
ETSOOWindow.prototype._getCoverFrame=function()
{
    var oFrame=document.createElement(_sysDom.browser.isCover?"div":"iframe");
    oFrame.id=_sysDom.getID("coverFrame");
    var sBgColor=this.coverFrameBgColor;
    with(oFrame.style)
    {
        position="absolute";
		if(_sysDom.browser.subName=="safari")visibility="hidden";
		else display="none";
        zIndex=this.zIndex-1;
        left=this.configs.left+"px";
        top=this.configs.top+"px";
        width=this.configs.width+"px";
        height=this.configs.height+"px";
        border="0px none";
    }  
	_sysDom.setOpacity(oFrame,0);
    this.container.parentNode.insertBefore(oFrame,this.container);
    this.coverFrame=oFrame;
    
    if(oFrame.nodeName=="IFRAME")
    {
        var oD=_sysDom.setIFrameBg(window.frames[oFrame.id],sBgColor);
        if(oD)
        {
            _sysDom.attachEvent(oD,"onmousemove",parent.ETSOOWindow.UpdateDrag);
            _sysDom.attachEvent(oD,"onmouseup",parent.ETSOOWindow.EndDrag);
        }
    }
    else oFrame.style.backgroundColor=sBgColor;
}
ETSOOWindow.prototype._getStructure=function(oBody)
{
    var sLeft=this.configs.left+'px';
    var sTop=this.configs.top+'px';
    var sWidth=this.configs.width+'px';
    var sHeight=this.configs.height+'px';
    
    var sId="ETSOOWindowContainer_"+this.id;
    var sTheme=this.configs.theme;

    var sLeftPart='<td class="'+sTheme+'_title" nowrap><div>&nbsp;</div></td>';
    var sRightPart='<td class="'+sTheme+'_box" align="right">';
    sRightPart+='<table cellspacing="0" cellpadding="0" border="0"><tr>';
    sRightPart+='<td class="'+sTheme+'_min"></td>';
    sRightPart+='<td class="'+sTheme+'_max"></td>';
    sRightPart+='<td class="'+sTheme+'_close"></td>';
    sRightPart+='</tr></table>';
    sRightPart+='</td>';
    if(this.configs.boxalign=="left")
    {
        var sTempPart=sRightPart;
        sRightPart=sLeftPart;
        sRightPart=sRightPart.replace(' nowrap',' nowrap align="center"');
        
        sTempPart=sTempPart.replace("_min","_lose_temp");
        sTempPart=sTempPart.replace("_max","_min");
        sTempPart=sTempPart.replace("_close","_max");
        sTempPart=sTempPart.replace("_lose_temp","_close");
        
        sLeftPart=sTempPart;
    }

    var sTitlePart=sLeftPart+sRightPart;
    var sLayout='<div style="position:absolute; visibility:inherit; left:0; top:0;">';
    sLayout+='<table cellspacing="0" cellpadding="0" border="0" width="100%">';
    sLayout+='<tr><td class="'+sTheme+'_nw0"></td><td class="'+sTheme+'_n0"></td><td class="'+sTheme+'_ne0"></td></tr>';
    sLayout+='<tr><td class="'+sTheme+'_nw1"></td><td class="'+sTheme+'_n1">';
    sLayout+='<table cellspacing="0" cellpadding="0" border="0"><tr>';
    sLayout+=sTitlePart;
    sLayout+='</tr></table>';
    sLayout+='</td><td class="'+sTheme+'_ne1"></td></tr>';
    sLayout+='<tr><td class="'+sTheme+'_w0"></td><td class="'+sTheme+'_m0"><div';
    sLayout+='>&nbsp;</div></td><td class="'+sTheme+'_e0"></td></tr>';
    sLayout+='<tr><td class="'+sTheme+'_sw0"></td><td class="'+sTheme+'_s0">';
    sLayout+='<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>';
    sLayout+='<td class="'+sTheme+'_status" nowrap><div>&nbsp;</div></td><td align="right" valign="bottom">';
    sLayout+='<table cellspacing="0" cellpadding="0" border="0"><tr><td class="'+sTheme+'_resize"></td></tr></table></td>';
    sLayout+='</tr></table>';
    sLayout+='</td><td class="'+sTheme+'_se0"></td></tr>';
    sLayout+='<tr><td class="'+sTheme+'_sw1"></td><td class="'+sTheme+'_s1"></td><td class="'+sTheme+'_se1"></td></tr>';
    sLayout+='</table>';
    sLayout+='</div>';

    var sTL=sLayout+'<div class="'+sTheme+'_topdiv"><table cellspacing="0" cellpadding="0" width="100%" border="0">';
    sTL+='<tr>';
    sTL+='    <td><table cellspacing="0" cellpadding="0" width="100%" border="0"><tr>';
    sTL+='        <td class="'+sTheme+'_nw"></td>';
    sTL+='        <td class="'+sTheme+'_n">&nbsp;</td>';
    sTL+='        <td class="'+sTheme+'_ne"></td>';
    sTL+='    </tr></table></td>';
    sTL+='</tr><tr>';
    sTL+='    <td><table cellspacing="0" cellpadding="0" width="100%" style="table-layout:fixed" border="0"><tr>';
    sTL+='        <td class="'+sTheme+'_w" align="right"></td>';
    sTL+='        <td class="'+sTheme+'_m">&nbsp;</td>';
    sTL+='        <td class="'+sTheme+'_e" align="left"></td>';
    sTL+='    </tr></table></td>';
    sTL+='</tr><tr>';
    sTL+='    <td><table cellspacing="0" cellpadding="0" width="100%" border="0"><tr>';
    sTL+='        <td class="'+sTheme+'_sw"></td>';
    sTL+='        <td class="'+sTheme+'_s">&nbsp;</td>';
    sTL+='        <td class="'+sTheme+'_se"></td>';
    sTL+='    </tr></table></td>';
    sTL+='</tr></table></div>';
    
    this.zIndex=ETSOOWindow.CurrentZIndex;
    ETSOOWindow.CurrentZIndex+=4;
    
    var oDiv=document.createElement("div");
    oDiv.id=sId;
    oDiv.className=_sysDom.browser.name;
    with(oDiv.style)
    {
        margin="0px";
        visibility="hidden";
        position="absolute";
        zIndex=this.zIndex;
        left=sLeft;
        top=sTop;
        width=sWidth;
        height=sHeight;
    }
    oDiv.setAttribute("baseTheme",sTheme);
    oDiv=oBody.appendChild(oDiv);
    
    var oDivN=document.createElement("div");
    oDivN.id="ETSOOWindowContainer";
    oDivN=oDiv.appendChild(oDivN);
    oDivN.innerHTML=sTL;
    
    this.container=oDiv;
    this.controlDiv=oDiv.firstChild;
    
    this._getCoverFrame();
    
    var oFilters=function(sName)
    {
        var iPos=sName.lastIndexOf("_");
        if(iPos==-1)
        {
            sName=null;
        }
        else
        {
            sName=sName.substr(iPos+1);
        }
        return sName;
    }
    this.objects=_sysDom.getCollection(oDiv,"td","className",oFilters);
    var aDivs=_sysDom.getCollection(oDiv,"div","className",oFilters);
    for(var sName in aDivs)
    {
        this.objects[sName]=aDivs[sName];
    }
    
    _sysDom.setNoSelect(this.objects.title);
    this.objects.title.oncontextmenu=new Function("return false");
    _sysDom.setNoSelect(this.objects.status);
    this.objects.status.oncontextmenu=new Function("return false");
    
    if(oBody.getAttribute("scroll")=="no"||_sysDom.getCurrentStyle(oBody,"overflow")=="hidden")this._bodyScroll=false;
    
    this.readyState=2;
    this.reload();
}
ETSOOWindow.prototype.reload=function()
{
    var sBaseTheme=this.container.getAttribute("baseTheme");
    var sTheme=this.configs.theme.toLowerCase();
    if(sBaseTheme!=sTheme)
    {
        if(this.onReload!=null)
        {
            if(this.onReload()==false)return false;
        }
        if(this.deliverEvent("reload")==false)return false;
        
        this.close();
        this.styleObject=_sysDom.importStylesheet(this.path+"Themes/"+sTheme+".css",self.document);
        for(var sName in this.objects)
        {
            var oT=this.objects[sName];
            oT.className=sTheme+"_"+sName;
        }
    }
    var oM0=this.objects.m0;
    this.contentBar=oM0.firstChild;
    this.setPadding();
    
    if(this.testKey("titlebar"))
    {
        this.titleBar=this.objects.title.firstChild;
        this.titleBar.style.overflow="hidden";
    }
    if(this.testKey("status"))
    {
        this.statusBar=this.objects.status.firstChild;
        this.statusBar.style.overflow="hidden";
    }
    this.boxBar=this.objects.box;
    if(this.testKey("modal"))this.setModal(true);
    
    this.setResizable(this.testKey("resizable"));
    this.setDraggable(this.testKey("draggable"));
    this.setBottomDraggable(this.testKey("bottomdraggable"));
    this.setCursor(this.objects.min,"pointer");
    this.setCursor(this.objects.max,"pointer");
    this.setCursor(this.objects.close,"pointer");
    if(!this.configs.controlbox||!this.testKey("minimizable"))this.setMinimizable(false);
    if(!this.configs.controlbox||!this.testKey("maximizable"))this.setMaximizable(false);
    if(!this.configs.controlbox||!this.testKey("closable"))this.setClosable(false);
    
    var sBgColor=this.configs.bgcolor;
    if(sBgColor)this.objects.m.style.backgroundColor=sBgColor;
    
    this.basePoints=[this.configs.width,this.configs.height,this.configs.left,this.configs.top];
    
    if(this.isTitleBarAction)this.objects.title.ondblclick=ETSOOWindow.TitleBarAction;
    else this.objects.title.ondblclick=null;
    
    this.readyState=3;
	if(this._interval)window.clearInterval(this._interval);
    this._interval=window.setInterval("ETSOOWindow.DoInterval('"+this.id+"')",50);
}
ETSOOWindow.prototype.setTitle=function(sTitle)
{
    if(sTitle==null)sTitle=this.configs.title;
    else this.configs.title=sTitle;
    if(this.titleBar)this.titleBar.innerHTML=sTitle;
}
ETSOOWindow.prototype.setContent=function(sContent)
{
    if(sContent==null)sContent=this.content;
    else this.content=sContent;
    if(this.readyState==4)
    {
        var oDiv=this.contentBar;
        oDiv.innerHTML="";
        if(typeof(sContent)=="object"&&sContent.nodeName!=null)sContent=sContent.innerHTML;
        oDiv.innerHTML=sContent;
        this.isUrl=false;
    }
}
ETSOOWindow.prototype.setUrl=function(sUrl)
{
    if(sUrl==null)sUrl=this.url;
    else this.url=sUrl;
    if(this.readyState==4)
    {
        var oContentBar=this.contentBar;
        oContentBar.style.overflow="hidden";
        this.setPadding(0,1);
        var oFrame=oContentBar.firstChild;
        if(oFrame==null||oFrame.nodeName!="IFRAME")
        {
            var sWidth=this.layoutSize.baseCW+"px";
            var sHeight=this.layoutSize.baseCH+"px";
            oContentBar.style.height=sHeight;
            oContentBar.innerHTML="";
            
            oFrame=_sysDom.createIFrame(document,false);
            oFrame.setAttribute("src",sUrl);
            oFrame.setAttribute("width",sWidth);
            oFrame.setAttribute("height",sHeight);
            oFrame.setAttribute("frameBorder",0);
            oContentBar.appendChild(oFrame);
            oFrame.style.display="block";
        }
        this.isUrl=true;
    }
}
ETSOOWindow.prototype.setStatus=function(sStatus)
{
    if(sStatus==null)sStatus=this.configs.statustext;
    else this.configs.statustext=sStatus;
    if(this.statusBar)this.statusBar.innerHTML=sStatus;
}
ETSOOWindow.prototype.setPadding=function(iPadding,iType)
{
    if(iPadding==null)iPadding=this.configs.padding;
    if(iType==null)this.configs.padding=iPadding;
    if(this.contentBar)this.contentBar.style.padding=iPadding+"px";
}
ETSOOWindow.prototype.setResizable=function(bY)
{
    if(this.objects.length==0)return;
    if(bY)
    {
        this.configs.resizable="yes";
        this.setCursor(this.objects.n0,"n-resize");
        this.setCursor(this.objects.e0,"w-resize");
        this.setCursor(this.objects.s1,"n-resize");
        this.setCursor(this.objects.w0,"w-resize");
        this.setCursor(this.objects.nw0,"nw-resize");
        this.setCursor(this.objects.nw1,"w-resize");
        this.setCursor(this.objects.ne0,"ne-resize");
        this.setCursor(this.objects.ne1,"w-resize");
        this.setCursor(this.objects.sw0,"w-resize");
        this.setCursor(this.objects.sw1,"ne-resize");
        this.setCursor(this.objects.se0,"w-resize");
        this.setCursor(this.objects.se1,"nw-resize");
        this.setCursor(this.objects.resize,"nw-resize");
    }
    else
    {
        this.configs.resizable="no";
        this.setCursor(this.objects.n0,"default");
        this.setCursor(this.objects.e0,"default");
        this.setCursor(this.objects.s1,"default");
        this.setCursor(this.objects.w0,"default");
        this.setCursor(this.objects.nw0,"default");
        this.setCursor(this.objects.nw1,"default");
        this.setCursor(this.objects.ne0,"default");
        this.setCursor(this.objects.ne1,"default");
        this.setCursor(this.objects.sw0,"default");
        this.setCursor(this.objects.sw1,"default");
        this.setCursor(this.objects.se0,"default");
        this.setCursor(this.objects.se1,"default");
        this.setCursor(this.objects.resize,"default");
    }
}
ETSOOWindow.prototype.setCursor=function(oT,sCursor)
{
    oT.style.cursor=sCursor;
}
ETSOOWindow.prototype.setDraggable=function(bY)
{
    var sY=bY?"yes":"no";
    this.configs.draggable=sY;
    if(this.readyState>=2)
    {
        var sCursor=bY?"move":"default";
        this.setCursor(this.objects.title,sCursor);
    }
}
ETSOOWindow.prototype.setBottomDraggable=function(bY)
{
    var sY=bY?"yes":"no";
    this.configs.bottomdraggable=sY;
    if(this.readyState>=2)
    {
        var sCursor=bY?"move":"default";
        this.setCursor(this.objects.status,sCursor);
    }
}
ETSOOWindow.prototype.setMinimizable=function(bY)
{
    this.configs.minimizable=bY?"yes":"no";
    if(this.readyState>=2)this._setButtonClass("min",bY);
}
ETSOOWindow.prototype.setMaximizable=function(bY)
{
    this.configs.maximizable=bY?"yes":"no";
    if(this.readyState>=2)this._setButtonClass("max",bY);
}
ETSOOWindow.prototype.setClosable=function(bY)
{
    this.configs.closable=bY?"yes":"no";
    if(this.readyState>=2)this._setButtonClass("close",bY);
}
ETSOOWindow.prototype._setButtonClass=function(sC,bY)
{
    if(this.boxBar)
    {
        var iIndex=null;
        if(this.configs.boxalign=="left")
        {
            switch(sC)
            {
                case "min":
                    iIndex=1;
                    break;
                case "max":
                    iIndex=2;
                    break;
                case "close":
                    iIndex=0;
                    break;
            }
        }
        else
        {
            switch(sC)
            {
                case "min":
                    iIndex=0;
                    break;
                case "max":
                    iIndex=1;
                    break;
                case "close":
                    iIndex=2;
                    break;
            }
        }
        if(iIndex!=null)
        {
            var oTD=this.boxBar.getElementsByTagName("td")[iIndex];
            if(oTD)
            {
                oTD.className=(bY?this.configs.theme+"_"+sC:"");
                if(this.layoutSize)
                {
                    var iLen=this.layoutSize.boxWidth[sC];
                    if(iLen)
                    {
                        if(!bY)iLen=-iLen;
                        this.layoutSize.box+=iLen;
                        this._setTitleWidth();
                    }
                }
            }
        }
    }
}
ETSOOWindow.prototype._setTitleWidth=function()
{
    this.boxBar.style.width=this.layoutSize.box+"px";
    this._setWidth(this.titleBar,"title",this.configs.width-this.layoutSize.leftPad-this.layoutSize.rightPad-this.layoutSize.box);
}
ETSOOWindow.prototype._setWidth=function(oT,sName,iLen)
{
    if(oT==null)oT=this.objects[sName];
    else iLen-=this.configs.padding;
    oT.style.width=iLen+"px";
}
ETSOOWindow.prototype._setSameSize=function(iWidth,iHeight,iLeft,iTop,iType)
{
    var oFrame=this.coverFrame;
    var sSizeMode=this.sizeMode;
    var bModal=this.testKey("modal");
    with(this.container.style)
    {
        if(iType!=1&&iWidth!=null)
        {
            width=iWidth+"px";
            if(oFrame&&!bModal)oFrame.style.width=iWidth+"px";
            if(sSizeMode=="normal")this.basePoints[0]=this.configs.width;
            this.configs.width=iWidth;
        }
        if(iType!=1&&iHeight!=null)
        {
            height=iHeight+"px";
            if(oFrame&&!bModal)oFrame.style.height=iHeight+"px";
            if(sSizeMode=="normal")this.basePoints[1]=this.configs.height;
            this.configs.height=iHeight;
        }
        if(iLeft!=null)
        {
            left=iLeft+"px";
            if(oFrame&&!bModal)oFrame.style.left=iLeft+"px";
            if(sSizeMode!="max")this.basePoints[2]=this.configs.left;
            this.configs.left=iLeft;
        }
        if(iTop!=null)
        {
            top=iTop+"px";
            if(oFrame&&!bModal)oFrame.style.top=iTop+"px";
            if(sSizeMode!="max")this.basePoints[3]=this.configs.top;
            this.configs.top=iTop;
        }
    }
}
ETSOOWindow.prototype.minimize=function()
{
    if(this.readyState<3)return;
	if(this._bodyScroll&&this.sizeMode=="max")this._setScroll(true);
    if(this.sizeMode!="min")
    {
        if(this.onMinimize!=null)
        {
            if(this.onMinimize()==false)return false;
        }
        if(this.deliverEvent("minimize")==false)return false;
        this._setSameSize(this.basePoints[0],this.layoutSize.header+this.layoutSize.footer,this.basePoints[2],this.basePoints[3]);
        this.sizeMode="min";
    }
    else
    {
        if(this.onRestore!=null)
        {
            if(this.onRestore()==false)return false;
        }
        if(this.deliverEvent("restore")==false)return false;
        this._setSameSize(this.basePoints[0],this.basePoints[1],this.basePoints[2],this.basePoints[3]);
        this.sizeMode="normal";
    }
    this.testSize();
}
ETSOOWindow.prototype._setScroll=function(bY)
{
	var bIE=(_sysDom.browser.name=="msie");
	if(bY)
	{
		document.documentElement.style.overflow="auto";
		if(bIE)document.body.style.overflow="auto";
		if(_sysDom.browser.name!="msie")
		{
			var aS=this._scrollSize;
			if(aS)
			{
				window.scroll(aS[0],aS[1]);
			}
		}
	}
	else
	{
		this._scrollSize=_sysDom.getScrollSize();
		document.documentElement.style.overflow="hidden";
		if(bIE)document.body.style.overflow="hidden";
	}
}
ETSOOWindow.prototype.maximize=function()
{
    if(this.readyState<3)return;
    if(this.sizeMode!="max")
    {
        if(this.onMaximize!=null)
        {
            if(this.onMaximize()==false)return false;
        }
        if(this.deliverEvent("maximize")==false)return false;
        this._setScroll(false);
		var aS=_sysDom.getScrollSize();
        this._setSameSize(this.maximumSize[0]||this.screenSize[0],this.maximumSize[1]||this.screenSize[1],aS[0],aS[1]);
        this.sizeMode="max";
    }
    else
    {
        if(this.onRestore!=null)
        {
            if(this.onRestore()==false)return false;
        }
        if(this.deliverEvent("restore")==false)return false;
        if(this._bodyScroll&&this.sizeMode=="max")this._setScroll(true);
        this._setSameSize(this.basePoints[0],this.basePoints[1],this.basePoints[2],this.basePoints[3]);
        this.sizeMode="normal";
    }
    this.testSize();
}
ETSOOWindow.prototype.close=function()
{
    if(this.readyState<3)return;
    if(this.onClose!=null)
    {
        if(this.onClose()==false)return false;
    }
    if(this.deliverEvent("close")==false)return false;
    var oC=this.container;
    if(this._bodyScroll&&this.sizeMode=="max")this._setScroll(true);
    if(!this.closed)
    {
        this.hide(true);
    }
}
ETSOOWindow.prototype.hide=function(bH)
{
    if(this.readyState<3)return;
    if(bH==null)bH=true;
    this.closed=bH;
    this.container.style.visibility="visible";
    this.container.style.display=(bH?"none":"block");
    if(!bH&&this.testKey("center"))
    {
        this.setCenter();
    }
    if(this.coverFrame)
	{
		if(_sysDom.browser.subName=="safari")this.coverFrame.style.visibility=bH?"hidden":"visible";
		else this.coverFrame.style.display=bH?"none":"block";
	}
}
ETSOOWindow.prototype.testSize=function()
{
    var oContent=this.contentBar;
    if(oContent==null)return;
    var iPadBox=this.configs.layoutpadding;
    var iPadContent=this.configs.padding;
    var iHeader,iFooter,iLeft,iRight,iHeaderPad,iFooterPad,iLeftPad,iRightPad,iBox,iResize;
    if(this.layoutSize==null)
    {
        iHeader=this.getNumberValue("n","height");
        iFooter=this.getNumberValue("s","height");
        iLeft=this.getNumberValue("w","width");
        iRight=this.getNumberValue("e","width");
        iHeaderPad=iHeader;
        iFooterPad=iFooter;
        iLeftPad=this.getNumberValue("nw0","width");
        iRightPad=this.getNumberValue("ne0","width");
        var sPadding=iPadBox+"px";
        var iMinBox=this.testKey("minimizable")?this.getNumberValue("min","width"):0;
        var iMaxBox=this.testKey("maximizable")?this.getNumberValue("max","width"):0;
        var iCloseBox=this.testKey("closable")?this.getNumberValue("close","width"):0;
        iBox=iMinBox+iMaxBox+iCloseBox+iPadBox;
        this.boxBar.style.width=iBox+"px";
        var iResize=this.getNumberValue("resize","width");
        if(this.configs.boxalign=="left")this.boxBar.style.paddingLeft=sPadding;
        else this.boxBar.style.paddingRight=sPadding;
        oContent.style.overflow="auto";
        if(this.titleBar)this.titleBar.parentNode.style.paddingLeft=sPadding;
        if(this.statusBar)this.statusBar.parentNode.style.paddingLeft=sPadding;
        this.layoutSize={};
        this.layoutSize.header=iHeader;
        this.layoutSize.footer=iFooter;
        this.layoutSize.left=iLeft;
        this.layoutSize.right=iRight;
        this.layoutSize.headerPad=iHeaderPad;
        this.layoutSize.footerPad=iFooterPad;
        this.layoutSize.leftPad=iLeftPad;
        this.layoutSize.rightPad=iRightPad;
        this.layoutSize.box=iBox;
        this.layoutSize.boxWidth={};
        this.layoutSize.boxWidth.min=iMinBox;
        this.layoutSize.boxWidth.max=iMaxBox;
        this.layoutSize.boxWidth.close=iCloseBox;
        this.layoutSize.resize=iResize;
    }
    else
    {
        iHeader=this.layoutSize.header;
        iFooter=this.layoutSize.footer;
        iLeft=this.layoutSize.left;
        iRight=this.layoutSize.right;
        iHeaderPad=this.layoutSize.headerPad;
        iFooterPad=this.layoutSize.footerPad;
        iLeftPad=this.layoutSize.leftPad;
        iRightPad=this.layoutSize.rightPad;
        iBox=this.layoutSize.box;
        iResize=this.layoutSize.resize;
    }
    var iWidth=this.configs.width;
    var iHeight=this.configs.height;
    var iCW=iWidth-iLeftPad-iRightPad;
    var iCH=iHeight-iHeaderPad-iFooterPad;
    var iTitleLen=iCW-iBox-iPadBox;
    this._setWidth(this.titleBar,"title",iTitleLen);
    var iBaseCW=iCW;
    var iBaseCH=iCH;

    iCW-=2*iPadContent;
    iCH-=2*iPadContent;
	if(iCH>0&&_sysDom.browser.name=="msie")iCH+=2*iPadContent+this.adjustHeight;
	
    if(iCH<0)iCH=0;
    var iLW=iWidth-iLeft-iRight;
    var iLH=iHeight-iHeader-iFooter;
    if(iLH<0)iLH=0;
    var iStatusLen=iCW-iResize;
    this._setWidth(this.statusBar,"status",iStatusLen);
    var oM=_sysDom.getParentByTagName(this.objects.m,"table");
    var oFrame=oContent.firstChild;
    if(oFrame&&oFrame.nodeName=="IFRAME"&&oContent.childNodes.length==1)
    {
        with(oFrame.style)
        {
            width=iBaseCW+"px";
            height=iBaseCH+"px";
        }
    }
    if(iCH==0)
    {
        iLH=0;
        oContent.style.display="none";
        this.objects.m.innerHTML="";
        if(!this.isUrl)this.setPadding(0,1);
    }
    else
    {
        if(oContent.style.display=="none")
        {
            if(_sysDom.browser.name=="netscape")this.objects.m.innerHTML="&nbsp;";
            oContent.style.display="block";
            if(!this.isUrl)this.setPadding();
        }
    }
    if(!this.isUrl)oContent.style.height=iCH+"px";
    else oContent.style.height=iBaseCH+"px";
    oM.style.height=iLH+"px";
    
    this.layoutSize.baseCW=iBaseCW;
    this.layoutSize.baseCH=iBaseCH;
    this.layoutSize.cw=iCW;
    this.layoutSize.ch=iCH;
    this.layoutSize.lw=iLW;
    this.layoutSize.lh=iLH;
}
ETSOOWindow.prototype.getNumberValue=function(sName,sA)
{
    var sValue=_sysDom.getDefinedStyle(this.styleObject,"."+this.configs.theme+"_"+sName,sA);
    return _sysDom.toInt(sValue);
}
ETSOOWindow.prototype.toTopMost=function()
{
    if(this.readyState<2)return;
    var iZIndex=this.zIndex;
    var iCurrentZIndex=ETSOOWindow.CurrentZIndex;
    if(iCurrentZIndex-iZIndex>3)
    {
        if(this.onFocus!=null)
        {
            if(this.onFocus()==false)return false;
        }
        if(this.deliverEvent("focus")==false)return false;
        this.container.style.zIndex=iCurrentZIndex;
        this.zIndex=iCurrentZIndex;
        if(this.coverFrame!=null)
        {
            this.coverFrame.style.zIndex=iCurrentZIndex-1;
        }
        ETSOOWindow.CurrentZIndex+=4;
    }
	this.configs.topmost="yes";
}
ETSOOWindow.prototype.setModal=function(bY)
{
    if(this.readyState<2)
    {
        this.configs.modal=bY?"yes":"no";
        return;
    }
	_sysDom.setOpacity(this.coverFrame,bY?this.coverFrameOpacity:0);
    var oBody=document.body;
    if(bY)
    {
        this.toTopMost();
		var aS=_sysDom.getMaxSize();
        with(this.coverFrame.style)
        {
            left="0px";
            top="0px";
            width=aS[0]+"px";
            height=aS[1]+"px";
        }
        this.configs.modal="yes";
    }
    else
    {
        if(this.testKey("modal"))
        {
            with(this.coverFrame.style)
            {
                left=this.configs.left+"px";
                top=this.configs.top+"px";
                width=this.configs.width+"px";
                height=this.configs.height+"px";
            }
            this.configs.modal="no";
        }
    }
}
ETSOOWindow.prototype.moveTo=function(iLeft,iTop)
{
    if(iLeft)
    {
        iLeft=_sysDom.toInt(iLeft);
        if(iLeft<0)iLeft=null;
        else
        {
            this.basePoints[2]=iLeft;
            this.configs.left=iLeft;
        }
    }
    if(iTop)
    {
        iTop=_sysDom.toInt(iTop);
        if(iTop<0)iTop=null;
        else
        {
            this.basePoints[3]=iTop;
            this.configs.top=iTop;
        }
    }
    if(this.readyState==4)
    {
        if(this.sizeMode!="max")this._setSameSize(null,null,iLeft,iTop);
    }
}
ETSOOWindow.prototype.setWidth=function(iWidth)
{
    iWidth=_sysDom.toInt(iWidth);
    if(iWidth<this.minimumSize[0])iWidth=this.minimumSize[0];
    this.basePoints[0]=iWidth;
    this.configs.width=iWidth;
    if(this.readyState==4)
    {
        if(this.sizeMode=="normal")
        {
            this._setSameSize(iWidth,null,null,null);
            this.testSize();
        }
    }
}
ETSOOWindow.prototype.setHeight=function(iHeight)
{
    iHeight=_sysDom.toInt(iHeight);
    if(iHeight<this.minimumSize[1])iHeight=this.minimumSize[1];
    this.basePoints[0]=iHeight;
    this.configs.height=iHeight;
    if(this.readyState==4)
    {
        if(this.sizeMode=="normal")
        {
            this._setSameSize(null,iHeight,null,null);
            this.testSize();
        }
    }
}
ETSOOWindow.prototype.setSize=function(iWidth,iHeight)
{
    this.setWidth(iWidth);
    this.setHeight(iHeight);
}