/*
ARIAwork.com, Professional Script creating Group

ARIAwindow.js 2008/09/17

desc    : ARIAwindowClass Class / UTF-8

history : 2008/09/17, squall

Copyright (c) 2000-2008 NAMUsoft, Inc. All Rights Reserved.

This software is the proprietary information of NAMUsoft, Inc.
Use is subject to license terms.

===============================================================
*/

var ARIAwindowClass = Class.create({
  initialize: function() {
  	this.wins = [];
  },
  open: function(urls, winsName, options){
    // check window name
    var maxSeq = this.wins.max(function(n){return n.idx;});
    
    if(maxSeq != undefined) maxSeq++;
    else maxSeq = 0;
    
    winSeq = maxSeq;

    if(!winsName) winsName = "ARIAwinsInstance"+winSeq;
    var doYouHaveSameName = this.wins.any(function(n){
      return n.winsName == winsName;
    });
    // alert("My name is "+winsName+" "+doYouHaveSameName);
    // add window instance
    if(!doYouHaveSameName){
      if(!options) options = {};
      var myBtnClicks = this.onBtnClick.bind(this);
      var myWinMoving = this.onWinsMove.bind(this);
      var myWinClose = this.onWinsClose.bind(this);
      options.onBtnClick = myBtnClicks;
      options.onMoving = myWinMoving;
      options.onClose = myWinClose;
      options.zindex = 100+winSeq;
      var winPanel = new ARIApanel(winsName, urls, options);
      this.wins.push({idx:winSeq, urls:urls, winsName:winsName, options:options, panel:winPanel});
      return winPanel;
    }else{
      // reload window
      var myWins = this.wins.find(function(n){
        return n.winsName == winsName; 
      });
      if(myWins){
        var winsSeq = myWins.idx;
        this.changeDepth(myWins);
      }
      
      myWins.panel.statCheck(); // if minimize then restore
      return myWins.panel;
    }

  },
  close: function(winsName){
    // check window name
    winsName = winsName.replace("frames_", "");
    var myWins = this.wins.find(function(n){
      return n.winsName == winsName; 
    });
    
    if(myWins){
      myWins.panel.del();
      this.wins = this.wins.without(myWins);
    }
  },
  winResize: function(nWidth, nHeight, winsName){
    // check window name
    winsName = winsName.replace("frames_", "");
    var myWins = this.wins.find(function(n){
      return n.winsName == winsName; 
    });
    
    if(myWins){
      myWins.panel.winResize(nWidth, nHeight);
    }
  },
  winMove: function(nLeft, nTop, winsName){
    // check window name
    winsName = winsName.replace("frames_", "");
    var myWins = this.wins.find(function(n){
      return n.winsName == winsName; 
    });
    
    if(myWins){
      myWins.panel.winMove(nLeft, nTop);
    }
  },
  onBtnClick: function(tgName, tgID){
    

    
    var myWins = this.wins.find(function(n){
      return n.winsName == tgName; 
    });
    
    if(tgID == "close"){
      myWins.panel.del();
      this.wins = this.wins.without(myWins);
    }
    if(tgID == "max"){
      myWins.panel.maximize(); 
    }
    if(tgID == "restore"){
      myWins.panel.restore();
    }
    if(tgID == "mini"){
      myWins.panel.minimize(myWins.idx);
    }
    if(tgID == "focus"){
      this.changeDepth(myWins);
    }
  },
  onWinsMove: function(control){
    this.wins.each(function(n){
      n.panel.contentShowHide(control);
    });
  },
  onWinsClose: function(winName){
    var myWins = this.wins.find(function(n){
      return n.winsName == winName; 
    });
    
    if(myWins){
      this.wins = this.wins.without(myWins);
    }
  },
  changeDepth: function(winObj){
    var maxZ = this.wins.max(function(n){
      return n.options.zindex;
    });
    if(winObj.options.zindex < maxZ){
     
      var maxWins = this.wins.find(function(n){
        return n.options.zindex == maxZ; 
      });
      
      maxWins.panel.setDepth(winObj.options.zindex);
      maxWins.options.zindex = winObj.options.zindex;
      
      winObj.panel.setDepth(maxZ);
      winObj.options.zindex = maxZ;
    }
  }
});

var ARIApanel = Class.create({
  initialize: function(name, urls, options){
    this.OPT = options;
    this.name = name;
    this.urls = urls;
    this.resized = false;
    this.moved = false;
    this.mousemoved = false;
    this.maxed = false;
    
    //panel option init
    this.panelBorder = 5;
    if(this.OPT.Border) this.panelBorder = this.OPT.border;
    this.width = 400;
    if(this.OPT.width) this.width = this.OPT.width;
    this.height = 300;
    if(this.OPT.height) this.height = this.OPT.height;
    
    if(document.body.clientWidth < this.width) this.width = document.body.clientWidth - 10;
    if(document.body.clientHeight < this.height) this.height = document.body.clientHeight - 10;
    
    this.left = document.body.clientWidth / 2 - this.width / 2;
    if(this.OPT.left != undefined) this.left = this.OPT.left;
    this.top = document.body.clientHeight / 2 - this.height / 2;
    if(this.OPT.top != undefined) this.top = this.OPT.top;
    
    if(!this.OPT.max_w)  this.OPT.max_w  = 0;
    if(!this.OPT.max_h)  this.OPT.max_h  = 0;
  
    if(!this.OPT.min_w)  this.OPT.min_w  = 150;
    if(!this.OPT.min_h)  this.OPT.min_h  = 150;
    
    this.title = "ARIAWindow";
    if(this.OPT.title != undefined) this.title = this.OPT.title;
    
    //리사이즈 구현
    var newElementR = new Element("div", {id:"#ARIApanel{"+name+"}#id{resizer}", "class":"ARIAPanel"}); 
    Element.insert(document.body, {top:newElementR});
    this.TGR = newElementR;// initialize container
    
    this.TGR.setStyle({
      left:eval(this.left-3)+"px", top:eval(this.top-3)+"px", width:eval(this.width+6)+"px", height:eval(this.height+6)+"px"
      , border:"1px dashed #000000"
      , "zIndex":this.OPT.zindex, display:"none"
    });
    this.TGR.setOpacity(0.7);
    
    this.resizeObj = {cursor:"", left:eval(this.left-3), top:eval(this.top-3), width:eval(this.width+6), height:eval(this.height+6)}; 
    
    var newElement = new Element("div", {id:"#ARIApanel{"+name+"}", "class":"ARIAPanel"}); 
    Element.insert(document.body, {top:newElement});
    this.TG = newElement;// initialize container
    this.TG.setStyle({
      left:this.left+"px", top:this.top+"px", width:this.width+"px", height:this.height+"px", "zIndex":this.OPT.zindex
    });
    
    
    var winContent = [];
    winContent.push("<table width=\"100%\" cellpadding=0 cellspacing=0 border=0 style=\"table-layout:fixed;height:100%;\" unselectable=\"on\">");
    winContent.push(" <tr>");
    winContent.push("   <td style=\"height:23px\" unselectable=\"on\">");
    
    winContent.push("       <div class=\"panelTitle\" id=\"#ARIApanel{"+name+"}#id{handle}\" nowrap title=\""+this.title+"\" unselectable=\"on\" style=\"cursor:default;\"><nobr unselectable=\"on\">"+this.title+"</nobr></div></td>");
    
    winContent.push("   </td>");
    winContent.push(" </tr>");
    winContent.push(" <tr>");
    winContent.push("   <td id=\"#ARIApanel{"+name+"}#id{content}\" valign=\"top\">");
    winContent.push("   <iframe src=\""+this.urls+"\" class=\"pannelframe\" frameborder=0 name=\"frames_"+name+"\" id=\"frames_"+name+"\" style=\"margin:1px;height:"+(this.height-27)+"px;width:"+(this.width-4)+"px;\"></iframe>");
    winContent.push("   </td>");
    winContent.push(" </tr>");
    winContent.push("</table>");
    
    var p_out = [];
    p_out.push("<li class=\"TL\"></li>");
    p_out.push("<li class=\"TM\"></li>");
    p_out.push("<li class=\"TR\"></li>");
    p_out.push("<li class=\"ML\"></li>");
    p_out.push("<li class=\"MM\" unselectable=\"on\">"+winContent.join('')+"</li>");
    p_out.push("<li class=\"MR\"></li>");   
    p_out.push("<li class=\"BL\"></li>");
    p_out.push("<li class=\"BM\"></li>");
    p_out.push("<li class=\"BR\"></li>");

    //버튼 생성
    p_out.push("<div class=\"btnSet\" id=\"#ARIApanel{"+name+"}#id{handle}\" unselectable=\"on\">");
    p_out.push("  <ul id=\"#ARIApanel{"+name+"}#id{btnSet}\" unselectable=\"on\">");
    p_out.push("    <li id=\"#ARIApanel{"+name+"}#panelBtn{mini}\" class=\"btnMini\"></li>");
    p_out.push("    <li id=\"#ARIApanel{"+name+"}#panelBtn{restore}\" class=\"btnRestore\" style=\"display:none;\"></li>");
    p_out.push("    <li id=\"#ARIApanel{"+name+"}#panelBtn{max}\" class=\"btnMax\"></li>");
    p_out.push("    <li id=\"#ARIApanel{"+name+"}#panelBtn{close}\" class=\"btnClose\"></li>");
    p_out.push("  </ul>");
    p_out.push("</div>");

    this.TG.update(p_out.join(''));
    
    var btnClicks = this.panelButtonClick.bind(this);
    this.winPanelButton = new ARIApanelButton(name, {onClick:btnClicks});

    Event.observe(this.TG, 'mousedown', this.onmousedown.bindAsEventListener(this));
    
    this.panelDownobserve = this.onmouseup.bindAsEventListener(this);
    this.panelMoveobserve = this.onmousemove.bindAsEventListener(this);

    //iframe Event
    if(isIE){
      Event.observe($("frames_"+name), 'focus', this.focus.bind(this));
    }else{
      eval("var frameObj = frames_"+name+";");
      Event.observe(frameObj, 'focus', this.focus.bind(this));
    }
        
    //title bar Event
    /*
    Event.observe($("#ARIApanel{"+name+"}#id{handle}"), 'dblclick', this.ondblclick.bindAsEventListener(this));
    if(isIE) $("#ARIApanel{"+name+"}#id{handle}").attachEvent("onselectstart", this.returnFalse);
    else $("#ARIApanel{"+name+"}#id{handle}").addEventListener("selectstart", this.returnFalse, true);
    */
  },
  ondblclick: function(event){
    var name = this.name;
    if(isFF) $("frames_"+name).focus();
    if(this.OPT.onBtnClick){
      if(this.maxed) this.OPT.onBtnClick(name, "restore");
      else if(this.minied)  this.OPT.onBtnClick(name, "restore");
      else  this.OPT.onBtnClick(name, "max");
    }
  },
  onmousedown: function(event){
    var name = this.name;
    
    if(!this.minied && !this.maxed){
      var eventLI = Event.findElement(event, "LI");
      var eventTD = Event.findElement(event, "DIV");
      
      if(eventLI){
        var reAt = ["TL","TM","TR","ML","MR","BL","BM","BR"];
        if(reAt.include(eventLI.className)){
          this.resized = true;
          this.mousemoved = false;
          this.resizeObj.cursor = eventLI.className;
          Event.observe(document.body, 'mouseup', this.panelDownobserve);
          Event.observe(document.body, 'mousemove', this.panelMoveobserve);
  
          this.onselectstart(true);
        }else if(eventTD.id == "#ARIApanel{"+name+"}#id{handle}"){
          this.moved = true;
          this.mousemoved = false;
          
          var bodyBox = document.body.getDimensions();

          if(isIE && ieVer < 7)
          var bodyScroll = {left:document.body.scrollLeft, top:document.body.scrollTop};
          else
          var bodyScroll = {left:document.documentElement.scrollLeft, top:document.documentElement.scrollTop};
          var mX = Event.pointerX(event);
          var mY = Event.pointerY(event);
          
          this.moverObj = {
            gapX:eval(mX-this.resizeObj.left.toNumber()), 
            gapY:eval(mY-this.resizeObj.top.toNumber()), 
            width:this.resizeObj.width.toNumber(), 
            height:this.resizeObj.height.toNumber(),
            bodyWidth:bodyBox.width.toNumber(), 
            bodyHeight:bodyBox.height.toNumber(), 
            scrollTop:bodyScroll.top.toNumber(), 
            scrollLeft:bodyScroll.left.toNumber()
          };
                    
          Event.observe(document.body, 'mouseup', this.panelDownobserve);
          Event.observe(document.body, 'mousemove', this.panelMoveobserve);
          this.onselectstart(true);        
        }
      }
    }
    this.focus();
  },
  onmouseup: function(event){
    var name = this.name;
    if(this.resized){
      this.onmoving(false);
      
      this.resized = false;
      this.TGR.hide();
      this.TG.setOpacity(1);
      Event.stopObserving(document.body, "mouseup", this.panelDownobserve);
      Event.stopObserving(document.body, "mousemove", this.panelMoveobserve);
      this.onselectstart(false);
      this.syncPanelResizer();
    }
    if(this.moved){
      this.onmoving(false);
      
      this.moved = false;
      this.TGR.hide();
      this.TG.setOpacity(1);
      Event.stopObserving(document.body, "mouseup", this.panelDownobserve);
      Event.stopObserving(document.body, "mousemove", this.panelMoveobserve);      
      this.onselectstart(false);
      this.syncPanelResizer();
    }
  },
  onmousemove: function(event){
    var name = this.name;
    if(this.resized && !this.minied && !this.maxed){
      if(!this.mousemoved){
        this.onmoving(true);
        this.TGR.show();
        this.TG.setOpacity(0.7);
        this.mousemoved = true;
      }
      if(isFF) $("frames_"+name).focus();
      var myResizer = this.resizeObj;
      var rLeft, rTop, rWidth, rHeight;
      var mX = Event.pointerX(event);
      var mY = Event.pointerY(event);
      
      if(myResizer.cursor == "BM"){
        rLeft = myResizer.left;
        rTop = myResizer.top;
        rWidth = myResizer.width;
        rHeight = mY - (myResizer.top);
      }
      if(myResizer.cursor == "BR"){
        rLeft = myResizer.left;
        rTop = myResizer.top;
        rWidth = mX - myResizer.left;
        rHeight = mY - (myResizer.top);
      }
      if(myResizer.cursor == "MR"){
        rLeft = myResizer.left;
        rTop = myResizer.top;
        rWidth = mX - myResizer.left;
        rHeight = myResizer.height;
      }
      if(myResizer.cursor == "BL"){
        rLeft = mX;
        rTop = myResizer.top;
        rWidth = (myResizer.left + myResizer.width) - mX;
        rHeight = mY - (myResizer.top);
        if((rLeft+this.OPT.min_w) > (myResizer.left + myResizer.width)) rLeft = (myResizer.left + myResizer.width) - this.OPT.min_w
      }
      if(myResizer.cursor == "ML"){
        rLeft = mX;
        rTop = myResizer.top;
        rWidth = (myResizer.left + myResizer.width) - mX;
        rHeight = myResizer.height;
        if((rLeft+this.OPT.min_w) > (myResizer.left + myResizer.width)) rLeft = (myResizer.left + myResizer.width) - this.OPT.min_w
      }
      if(myResizer.cursor == "TL"){
        rLeft = mX;
        rTop = mY;
        rWidth = (myResizer.left + myResizer.width) - mX;
        rHeight = (myResizer.top + myResizer.height) - mY;
        if((rLeft+this.OPT.min_w) > (myResizer.left + myResizer.width)) rLeft = (myResizer.left + myResizer.width) - this.OPT.min_w;
        if((rTop+this.OPT.min_h) > (myResizer.top + myResizer.height)) rTop = (myResizer.top + myResizer.height) - this.OPT.min_h;
      }
      if(myResizer.cursor == "TM"){
        rLeft = myResizer.left;
        rTop = mY;
        rWidth = myResizer.width;
        rHeight = (myResizer.top + myResizer.height) - mY;
        if((rTop+this.OPT.min_h) > (myResizer.top + myResizer.height)) rTop = (myResizer.top + myResizer.height) - this.OPT.min_h;
      }
      if(myResizer.cursor == "TR"){
        rLeft = myResizer.left;
        rTop = mY;
        rWidth = mX - myResizer.left;
        rHeight = (myResizer.top + myResizer.height) - mY;
        if((rTop+this.OPT.min_h) > (myResizer.top + myResizer.height)) rTop = (myResizer.top + myResizer.height) - this.OPT.min_h;
      }
      
      if(rWidth < this.OPT.min_w) rWidth = this.OPT.min_w;
      if(rHeight < this.OPT.min_h) rHeight = this.OPT.min_h;
      
      $(this.TGR).setStyle({
        left:rLeft+"px", top:rTop+"px", width:rWidth+"px", height:rHeight+"px"
      });
      
      this.resizeObj.left = rLeft;
      this.resizeObj.top = rTop;
      this.resizeObj.width = rWidth;
      this.resizeObj.height = rHeight;
      
    }
    
    if(this.moved && !this.maxed){
      if(!this.mousemoved){
        this.onmoving(true);
        this.TGR.show();
        this.TG.setOpacity(0.7);
        this.mousemoved = true;
      }
      if(isFF) $("frames_"+name).focus();
      
      var myMover = this.moverObj;
      var mLeft, mTop;
      var mX = Event.pointerX(event);
      var mY = Event.pointerY(event);  
      
      var moveBody = {
        x:myMover.scrollLeft+1+myMover.scrollLeft, 
        y:myMover.scrollTop+1+myMover.scrollTop, 
        w:myMover.bodyWidth-1+myMover.scrollLeft, 
        h:myMover.bodyHeight-1+myMover.scrollTop
      }
      
      //$("showx").update("mY="+mY+"/ moveBody.y="+moveBody.y+"/mX="+mX+"/ moveBody.x="+moveBody.x);
      
      if(this.moved && (mX+myMover.scrollLeft < moveBody.x || mY+myMover.scrollTop < moveBody.y || mX > moveBody.w || mY > moveBody.h)){
        this.onmoving(false);
        this.moved = false;
        this.TGR.hide();
        Event.stopObserving(document.body, "mouseup", this.panelDownobserve);
        Event.stopObserving(document.body, "mousemove", this.panelMoveobserve);      
        this.onselectstart(false);
        this.syncPanelResizer();
      }
     
      mLeft = mX - myMover.gapX;
      mTop = mY - myMover.gapY;

      $(this.TGR).setStyle({
        left:mLeft+"px", top:mTop+"px", width:myMover.width, height:myMover.height
      });
      
      this.resizeObj.left = mLeft;
      this.resizeObj.top = mTop;
      
    }
  },
  onselectstart: function(control){
    if(control){
      if(isIE)
      document.body.attachEvent("onselectstart", this.returnFalse);
      else
      document.body.addEventListener("selectstart", this.returnFalse, true);
    }else{
      if(isIE)
      document.body.detachEvent("onselectstart", this.returnFalse);
      else
      document.body.removeEventListener("selectstart", this.returnFalse, true);
    }
    
  },
  onmoving: function(control){
    if(this.OPT.onMoving) this.OPT.onMoving(control);
  },
  contentShowHide: function(control){
    if(this.minied){

    }else{
      var name = this.name;
      (control) ? $("frames_"+name).hide() : $("frames_"+name).show();
    }
  },
  returnFalse: function(event){
    Event.stop(event)
  },
  syncPanelResizer: function(){
    var name = this.name;
    this.TG.setStyle({
      left:eval(this.resizeObj.left+3)+"px", 
      top:eval(this.resizeObj.top+3)+"px", 
      width:eval(this.resizeObj.width-6)+"px", 
      height:eval(this.resizeObj.height-6)+"px"
    });
    //
    $("frames_"+name).setStyle({
      width:eval(this.resizeObj.width-6-4)+"px", 
      height:eval(this.resizeObj.height-6-27)+"px"
    });
  },
  del: function(){
    this.TG.remove();
    this.TGR.remove();
  },
  close: function(){
    this.TG.remove();
    this.TGR.remove();
    if(this.OPT.onClose) this.OPT.onClose(this.name);
  },
  maximize: function(){
    if(!this.maxed){
      var name = this.name;
      var bodyBox = document.body.getDimensions();
      
      this.restoreObj = {cursor:"", left:this.resizeObj.left, top:this.resizeObj.top, width:this.resizeObj.width, height:this.resizeObj.height}
      this.resizeObj.left = 3;
      this.resizeObj.top = 3;
      this.resizeObj.width = bodyBox.width-6;
      this.resizeObj.height = bodyBox.height-6;
      
      this.contentShowHide(false);
      this.syncPanelResizer();
      this.winPanelButton.maximize();
      this.maxed = true;
    }
  },
  restore: function(){
    if(this.maxed || this.minied){
      this.resizeObj = this.restoreObj;

      this.contentShowHide(false);
      this.syncPanelResizer();

      this.winPanelButton.restore();
      this.maxed = false;
      this.minied = false;
      this.onmoving(false);

    }
  },
  minimize: function(idx){
    if(!this.minied){
      if(!this.miniLeft){
        this.miniLeft = 0;
        this.miniTop = 0;
      }
      var name = this.name;
      var bodyBox = document.body.getDimensions();
      this.contentShowHide(true);
      this.winPanelButton.minimize();
      this.minied = true;
            
      this.restoreObj = {cursor:"", left:this.resizeObj.left, top:this.resizeObj.top, width:this.resizeObj.width, height:this.resizeObj.height}
      
      
      var divideCnt = parseInt(bodyBox.width / 150);
      
      this.resizeObj.left = (idx % divideCnt) * 150 + 5;
      this.resizeObj.top = bodyBox.height - (35 * parseInt(idx / divideCnt)) - 45;
      
      this.resizeObj.width = 150;
      this.resizeObj.height = 25;
      
      this.syncPanelResizer();
    }
  },
  panelButtonClick: function(tgName, tgID){
    if(this.OPT.onBtnClick) this.OPT.onBtnClick(tgName, tgID);
  },
  focus: function(){
    if(this.OPT.onBtnClick) this.OPT.onBtnClick(this.name, "focus");
  },
  setDepth: function(zindex){
    this.TGR.setStyle({"zIndex":zindex});
    this.TG.setStyle({"zIndex":zindex});
  },
  statCheck: function(){
    if(this.minied) this.restore();   
  },
  
  winResize: function(rWidth, rHeight){
    this.resizeObj.width  = rWidth;
    this.resizeObj.height = rHeight;
    
    this.syncPanelResizer();
  },
  winMove: function(rLeft, rTop){
    this.resizeObj.left = rLeft;
    this.resizeObj.top  = rTop;
    
    this.syncPanelResizer();
  }
  
});

var ARIApanelButton = Class.create({
  initialize: function(name, options){
    this.name = name;
    this.OPT = options;
    // button Event Observe
    Event.observe($("#ARIApanel{"+name+"}#id{btnSet}"), 'mouseover', this.onmouseover.bindAsEventListener(this));
    Event.observe($("#ARIApanel{"+name+"}#id{btnSet}"), 'mouseout', this.onmouseout.bindAsEventListener(this));
    Event.observe($("#ARIApanel{"+name+"}#id{btnSet}"), 'mousedown', this.onmousedown.bindAsEventListener(this));
    Event.observe($("#ARIApanel{"+name+"}#id{btnSet}"), 'mouseup', this.onmouseup.bindAsEventListener(this));
    Event.observe($("#ARIApanel{"+name+"}#id{btnSet}"), 'click', this.onclick.bindAsEventListener(this));
  },
  onmouseover: function(event){
    var name = this.name;
    var eventDIV = Event.findElement(event, "LI");
    if(eventDIV){
      var myID = ARIA.findID(eventDIV.id, "panelBtn");
      if(myID){
        try{
          var myClass = eventDIV.classNames().first();
          eventDIV.addClassName(myClass+"-hovered");
        }catch(e){}
      }
    }
  },
  onmouseout: function(event){
    var name = this.name;
    var eventDIV = Event.findElement(event, "LI");
    if(eventDIV){
      var myID = ARIA.findID(eventDIV.id, "panelBtn");
      if(myID){
        try{
          var myClass = eventDIV.classNames().last();
          eventDIV.removeClassName(myClass);
        }catch(e){}
      }
    }
  },
  onmousedown: function(event){
    var name = this.name;
    var eventDIV = Event.findElement(event, "LI");
    if(eventDIV){
      var myID = ARIA.findID(eventDIV.id, "panelBtn");
      if(myID){
        try{
          var myClass = eventDIV.classNames().first();
          eventDIV.addClassName(myClass+"-pushed");
        }catch(e){}
      }
    }
  },
  onmouseup: function(event){
    var name = this.name;
    var eventDIV = Event.findElement(event, "LI");
    if(eventDIV){
      var myID = ARIA.findID(eventDIV.id, "panelBtn");
      if(myID){
        try{
          var myClass = eventDIV.classNames().last();
          eventDIV.removeClassName(myClass);
        }catch(e){}
      }
    }
  },
  onclick: function(event){
    var name = this.name;
    var eventDIV = Event.findElement(event, "LI");
    if(eventDIV){
      var myID = ARIA.findID(eventDIV.id, "panelBtn");
      //$("msgShow").update(myID);
      if(myID){
        try{
          if($("#ARIApanel{"+name+"}#panelBtn{"+myID+"}")){
            if(this.OPT.onClick) this.OPT.onClick(name, myID);
          }
        }catch(e){}
      }
    }
  },
  maximize: function(){
    var name = this.name;
    $("#ARIApanel{"+name+"}#panelBtn{max}").hide();
    $("#ARIApanel{"+name+"}#panelBtn{restore}").show();
  },
  restore: function(){
    var name = this.name;
    $("#ARIApanel{"+name+"}#panelBtn{max}").show();
    $("#ARIApanel{"+name+"}#panelBtn{restore}").hide();
  },
  minimize: function(){
    var name = this.name;
    $("#ARIApanel{"+name+"}#panelBtn{max}").hide();
    $("#ARIApanel{"+name+"}#panelBtn{restore}").show();
  }
});

var ARIAwindow = new ARIAwindowClass();
