self.onError=null;
document.writeln("<script src='themes/dialog/"+theskin+"/config.js'></script>");
var Onez_Status=new Array();
try{
  var LineCount=parseInt(document.body.clientWidth/120);
  for(i=0;i<=OnezDivCount;i++){
    var Onez_L=(i % LineCount)*120;
    var Onez_T=document.body.clientHeight-parseInt(i / LineCount + 1)*FTLH;
    Onez_Status[i]=new Array(Onez_L,Onez_T,0);//Left,Top,Used
  }
}catch(e){

}
for(i=0;i<=OnezDivCount;i++){
  document.writeln("<div id=\"onezdiv"+i+"\" style=\"display:none\"></div>");
}
var CurZ=1;
var CurCount=0;
window.onload=function(){
  var LineCount=parseInt(document.body.clientWidth/120);
  for(i=0;i<=OnezDivCount;i++){
    var Onez_L=(i % LineCount)*120;
    var Onez_T=document.body.clientHeight-parseInt(i / LineCount + 1)*FTLH;
    Onez_Status[i]=new Array(Onez_L,Onez_T,0);//Left,Top,Used
  }
  MainLoad();
}
function OnezVars(){
  this.state=0;
  this.max=0;
  this.left=0;
  this.top=0;
  this.MinIndex=0;
  this.DivIndex=0;
}
function LoadFrame(idtbl,caption,url,W,H,L,T,pos,state,min,max,close){
  //表格位置
  if(pos==1){//上左
    var myl=0;
    var myt=0;
  }else if(pos==2){//上中
    var myl=(screen.Width-W)/2;
    var myt=0;
  }else if(pos==3){//上右
    var myl=screen.Width-W;
    var myt=0;
  }else if(pos==4){//中左
    var myl=0;
    var myt=(document.body.scrollTop+document.body.clientHeight-H-FTLH-FBBLH)/2;
  }else if(pos==5){//正中
    var myl=(document.body.scrollLeft+document.body.clientWidth-W)/2;
    var myt=(document.body.scrollTop+document.body.clientHeight-H-FTLH-FBBLH)/2;
  }else if(pos==6){//中右
    var myl=document.body.scrollLeft+document.body.clientWidth-W;
    var myt=(document.body.scrollTop+document.body.clientHeight-H-FTLH-FBBLH)/2;
  }else if(pos==7){//下左
    var myl=0;
    var myt=document.body.scrollTop+document.body.clientHeight-H-FTLH-FBBLH;
  }else if(pos==8){//下中
    var myl=(document.body.scrollLeft+document.body.clientWidth-W)/2;
    var myt=document.body.scrollTop+document.body.clientHeight-H-FTLH-FBBLH;
  }else if(pos==9){//下右
    var myl=document.body.scrollLeft+document.body.clientWidth-W;
    var myt=document.body.scrollTop+document.body.clientHeight-H-FTLH-FBBLH;
  }else{
    var myl=L;
    var myt=T;
  }
  if(myt<0){
    myt=0;
  }
  var myw=W;
  var myh=H;
  var mytabel=eval("document.all."+idtbl);
  if(url==""){
    url="blank.php";
  }
  var theurl=url.indexOf("?")==-1 ? url + "?onezid="+idtbl : url + "&onezid="+idtbl;
  if(typeof(mytabel)!=="undefined"){
    CurZ++;
    mytabel.style.zIndex=CurZ;
    //窗体状态；正常、最小化、最大化
    if(state==1){//最小化
      if(eval(idtbl+"_vars").state==0){
        eval(idtbl+"_vars").left=mytabel.style.pixelLeft;
        eval(idtbl+"_vars").top=mytabel.style.pixelTop;
      }
      for(i=0;i<=OnezDivCount;i++){
        if(Onez_Status[i][2]==0){
          var myl=Onez_Status[i][0];
          var myt=Onez_Status[i][1];
          Onez_Status[i][2]=1;
          eval(idtbl+"_vars").MinIndex=i;
          break;
        }
      }
      myw=120;
      myh=0;
      if(caption.length>4){
        caption=caption.substring(0,4)+".";
      }
      eval("document.all."+idtbl+"_caption").innerHTML=caption;
      eval("document.all."+idtbl+"_main").style.display="none";
      eval("document.all."+idtbl+"_bottom").style.display="none";
      mytabel.style.zIndex=999+CurZ;
      eval(idtbl+"_vars").state=1;
    }else if(state==2){
      if(eval(idtbl+"_vars").state==1){
        if(eval(idtbl+"_vars").max==1){
          var myl=0;
          var myt=0;
          myw=document.body.clientWidth;
          myh=document.body.scrollTop+document.body.clientHeight-FTLH-FBBLH;
          eval(idtbl+"_vars").state=2;
        }else{
          var myl=eval(idtbl+"_vars").left;
          var myt=eval(idtbl+"_vars").top;
          eval(idtbl+"_vars").state=0;
        }
        eval("document.all."+idtbl+"_caption").innerHTML=caption;
        Onez_Status[eval(idtbl+"_vars").MinIndex][2]=0;
      }else if(eval(idtbl+"_vars").state==2){
        var myl=eval(idtbl+"_vars").left;
        var myt=eval(idtbl+"_vars").top;
        eval(idtbl+"_vars").max=0;
        eval(idtbl+"_vars").state=0;
      }else{
        eval(idtbl+"_vars").left=mytabel.style.pixelLeft;
        eval(idtbl+"_vars").top=mytabel.style.pixelTop;
        var myl=0;
        var myt=0;
        myw=document.body.clientWidth;
        myh=document.body.clientHeight-FTLH-FBBLH;
        eval(idtbl+"_vars").max=1;
        eval(idtbl+"_vars").state=2;
      }
      eval("document.all."+idtbl+"_main").style.display="";
      eval("document.all."+idtbl+"_bottom").style.display="";
      eval("document.all."+idtbl+"_table1").width=myw;
      eval("document.all."+idtbl+"_table1").height=myh;
      eval("document.all."+idtbl+"_table2").width=myw-FTLW-FTRW;
    }else{
      eval(idtbl+"_vars").state=0;
    }
    eval("document.all."+idtbl+"_title").width=myw-FTLW-FTRW;
    eval("document.all."+idtbl+"_table").width=myw;
    mytabel.style.pixelLeft=myl;
    mytabel.style.pixelTop=myt;
    mytabel.style.display="";
    return true;
  }
  if(CurCount>=OnezDivCount-1 && idtbl!=="oneztipwindow"){
    alert("当前窗口已达到最大数,请关闭部分窗口后重试");
    return false;
  }
  CurZ++;
  eval(idtbl+"_vars=new OnezVars();");
  tmponez=("<div id=\""+idtbl+"\" style=\"display:; position: absolute;left:"+myl+"px;top:"+myt+"px;z-index:"+CurZ+"\" onmousedown=\"SetTop("+idtbl+")\">");
  tmponez+=("<table id=\""+idtbl+"_table\" width=\""+myw+"\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" onselectstart=\"return false\">");
  tmponez+=("<tr>");
  tmponez+=("<td width=\""+FTLW+"\" height=\""+FTLH+"\"><img src=\"themes/dialog/"+theskin+"/frame_title_left.gif\" width=\""+FTLW+"\" height=\""+FTLH+"\" border=\"0\"></td>");
  tmponez+=("<td id=\""+idtbl+"_title\" width=\""+(myw-FTLW-FTRW)+"\" background=\"themes/dialog/"+theskin+"/frame_title_mid.gif\">");
  tmponez+=("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
  tmponez+=("<tr>");
  tmponez+=("<td id=\""+idtbl+"_caption\" title=\""+caption+"\" style=\"color:"+TITLECOLOR+";font-size:"+TITLESIZE+";font-weight:Bold;cursor:move;overflow:hidden;padding-top:4px\" onmousedown=\"if("+idtbl+"_vars.max==0){dargit("+idtbl+")}\" ondblclick=\"if("+max+"==1){FrameMax('"+idtbl+"','"+caption+"','',"+myw+","+myh+","+myl+","+myt+","+pos+",2,"+min+","+max+","+close+")}\">"+caption+"&nbsp;</td>");
  if(min==1){
    tmponez+=("<td width=\""+MinW+"\"><img src=\"themes/dialog/"+theskin+"/min_normal.gif\" width=\""+MinW+"\" height=\""+MinH+"\" border=\"0\" onmouseover=\"this.src='themes/dialog/"+theskin+"/min_hover.gif'\" onmouseout=\"this.src='themes/dialog/"+theskin+"/min_normal.gif'\" onmousedown=\"this.src='themes/dialog/"+theskin+"/min_down.gif'\" onmouseup=\"this.src='themes/dialog/"+theskin+"/min_hover.gif'\" onclick=\"FrameMin('"+idtbl+"','"+caption+"','',"+myw+","+myh+","+myl+","+myt+","+pos+",1,"+min+","+max+","+close+")\"></td>");
  }
  if(max==1){
    tmponez+=("<td width=\""+MaxW+"\"><img src=\"themes/dialog/"+theskin+"/max_normal.gif\" width=\""+MaxW+"\" height=\""+MaxH+"\" border=\"0\" onmouseover=\"this.src='themes/dialog/"+theskin+"/max_hover.gif'\" onmouseout=\"this.src='themes/dialog/"+theskin+"/max_normal.gif'\" onmousedown=\"this.src='themes/dialog/"+theskin+"/max_down.gif'\" onmouseup=\"this.src='themes/dialog/"+theskin+"/max_hover.gif'\" onclick=\"FrameMax('"+idtbl+"','"+caption+"','',"+myw+","+myh+","+myl+","+myt+","+pos+",2,"+min+","+max+","+close+")\"></td>");
  }
  if(close==1){
    tmponez+=("<td width=\""+CloseW+"\"><img src=\"themes/dialog/"+theskin+"/close_normal.gif\" width=\""+CloseW+"\" height=\""+CloseH+"\" border=\"0\" onmouseover=\"this.src='themes/dialog/"+theskin+"/close_hover.gif'\" onmouseout=\"this.src='themes/dialog/"+theskin+"/close_normal.gif'\" onmousedown=\"this.src='themes/dialog/"+theskin+"/close_down.gif'\" onmouseup=\"this.src='themes/dialog/"+theskin+"/close_hover.gif'\" onclick=\"FrameClose('"+idtbl+"')\"></td>");
  }
  tmponez+=("</tr>");
  tmponez+=("</table>");
  tmponez+=("</td>");
  tmponez+=("<td width=\""+FTRW+"\"><img src=\"themes/dialog/"+theskin+"/frame_title_right.gif\" width=\""+FTRW+"\" height=\""+FTLH+"\" border=\"0\"></td>");
  tmponez+=("</tr>");
  tmponez+=("<tr>");
  tmponez+=("<td colspan=\"3\" id=\""+idtbl+"_main\">");
  tmponez+=("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
  tmponez+=("<tr>");
  tmponez+=("<td width=\""+FBLW+"\" background=\"themes/dialog/"+theskin+"/frame_border_left.gif\"></td>");
  tmponez+=("<td id=\""+idtbl+"_table1\" width=\""+(myw-FBLW-FBRW)+"\" height=\""+myh+"\" style=\"background-color:#FFFFFF; border:0px solid "+BorderColor+"\"><iframe id=\""+idtbl+"_body\" style=\"WIDTH: 100%; HEIGHT: 100%\" marginWidth=\"0\" marginHeight=\"0\" src=\""+theurl+"\"></iframe></td>");
  tmponez+=("<td width=\""+FBRW+"\" background=\"themes/dialog/"+theskin+"/frame_border_right.gif\"></td>");
  tmponez+=("</tr>");
  tmponez+=("</table>");
  tmponez+=("</td>");
  tmponez+=("</tr>");
  tmponez+=("<tr>");
  tmponez+=("<td colspan=\"3\" id=\""+idtbl+"_bottom\">");
  tmponez+=("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
  tmponez+=("<tr>");
  tmponez+=("<td width=\""+FBBLW+"\" background=\"themes/dialog/"+theskin+"/frame_bottom_left.gif\" height=\""+FBBLH+"\"></td>");
  tmponez+=("<td id=\""+idtbl+"_table2\" width=\""+(myw-FBBLW-FBBRW)+"\" background=\"themes/dialog/"+theskin+"/frame_bottom_mid.gif\"> </td>");
  tmponez+=("<td width=\""+FBBRW+"\" background=\"themes/dialog/"+theskin+"/frame_bottom_right.gif\"></td>");
  tmponez+=("</tr>");
  tmponez+=("</table>");
  tmponez+=("</td>");
  tmponez+=("</tr>");
  tmponez+=("</table>");
  tmponez+=("</div>");
  for(i=0;i<=OnezDivCount;i++){//写入空白层
    if(window.eval("onezdiv"+i).innerHTML.length==0){
      window.eval("onezdiv"+i).innerHTML=tmponez;
      window.eval("onezdiv"+i).style.display="";
      eval(idtbl+"_vars").DivIndex=i;
      CurCount++;
      break;
    }
  }
}
//右下角提示
var oneztimer1;
var oneztimer2;
var oneztimer3;
var sec=0;
function oneztip(text){
  LoadFrame("oneztipwindow","系统消息","",160,80,document.body.clientWidth-160,document.body.clientHeight,0,0,0,0,1);
  oneztipwindow.style.zIndex=2046;
  try{
    sec=0;
    clearInterval(oneztimer1);
    clearInterval(oneztimer2);
    clearInterval(oneztimer3);
  }catch(e){
  }
  oneztimer1=setInterval("showoneztip('"+text+"')",10);
}
function showoneztip(text){
  try{
    window.oneztipwindow_body.document.body.innerHTML=text;
    if(oneztipwindow.style.pixelTop<=document.body.clientHeight-80-FTLH-FBBLH){
      clearInterval(oneztimer1);
      sec=0;
      oneztimer2=setInterval("leaveoneztip()",1000);
    }else{
      oneztipwindow.style.pixelTop--;
    }
  }catch(e){
  }
}
function leaveoneztip(){
  sec++;
  if(sec>=5){
    sec=0;
    clearInterval(oneztimer2);
    oneztimer3=setInterval("hideoneztip()",10);
  }
}
function hideoneztip(){
  if(oneztipwindow.style.pixelTop>=document.body.clientHeight){
    clearInterval(oneztimer3);
    //FrameClose("oneztipwindow");
  }else{
    oneztipwindow.style.pixelTop++;
  }
}
//最小化
function FrameMin(idtbl,caption,url,W,H,L,T,pos,state,min,max,close){
  if(eval(idtbl+"_vars").state==1){
    return false;
  }
  LoadFrame(idtbl,caption,url,W,H,L,T,pos,state,min,max,close);
}
//最大化
function FrameMax(idtbl,caption,url,W,H,L,T,pos,state,min,max,close){
  LoadFrame(idtbl,caption,url,W,H,L,T,pos,state,min,max,close);
}
//关闭
function FrameClose(idtbl,issys){
  if(idtbl=="Login" && !issys){
    return;
    OpenLoginDialog();
  }
  if(idtbl=="Group"){
    CloseTopWin();
    return;
  }
  var TheIndex=eval(idtbl+"_vars").DivIndex;
  window.eval("onezdiv"+TheIndex).innerHTML="";
  window.eval("onezdiv"+TheIndex).style.display="none";
  CurCount--;
}
//设置为最顶端
function SetTop(obj){
  if(obj.style.zIndex==CurZ||obj.style.zIndex>999){
    return;
  }
  CurZ++;
  obj.style.zIndex=CurZ;
}
//设置图标
function SetIcon(idtbl,icon){
  var obj=window.eval(idtbl+"_caption");
  if(icon){
    obj.style.paddingLeft="20px";
    obj.style.backgroundImage="url(images/icon/"+icon+".gif)";
    obj.style.backgroundPosition="0 2px";
    obj.style.backgroundRepeat="no-repeat";
  }else{
    obj.style.paddingLeft="5px";
    obj.style.backgroundImage="";
  }
}
