var _Window = 
{
    WindowObj :  new Array(),
    zIndex : 0,
    DragObj : null,
    setTrayPosition:function()
	{
	  var InnerHeight = (IE_) ? document.body.clientHeight : window.innerHeight;
	  this.SystemTray.style.top = InnerHeight - UI.getObjSize( this.SystemTray).h + 'px';
	},
	
    setTray : function ()
    {
        this.SystemTray = document.createElement("div") ;
        this.SystemTray.className =  'SystemTray';
        document.getElementsByTagName('BODY')[0].appendChild(this.SystemTray);
        this.setTrayPosition();
     
        addEvent( window, 'resize', this.setTrayPosition.bind(this));  
        addEvent( document, 'mousemove', this.Drag.bind(this)); 
        addEvent( document, 'mouseup', 
        function (e) { 
            document.body.onselectstart = null;
            document.body.style.cursor = "default"; 
            this.DragObj = null;
             }.bind(this)); 
    },
    
    setMinimize : function (N)
    {
        
        var Win = this.WindowObj[N];
       
        var Mini = new this.getPannel();
             Mini.setTitle(Win.Title);
             
             Mini.setHeight(24);
             if(IE6_) Mini.setWidth(100);
             else Mini.setWidth('auto');
             
             Mini.append(this.SystemTray);
            
             Mini.Num = N; 
             Mini.Win.onmousedown = function (e) 
             {
              
                  var Windows = _Window.WindowObj[this.Num];
                  Windows.setIndex();
                  Windows.setDisplay(true);
                  this.remove();
                 // cancel(e);
                 
             }.bind(Mini);
    },
    
   
    showPopUp : function ()
    {
    	if(!this.PopBack)
    	{
    		this.setPopUp();
    	}
    	
    	var Size1 = $(window.document.body).getSize();
    	var Size2 = $(window).getSize();
    	
    	
    	if(!IE_) Size1.size = Size2.scrollSize;
    	
    	var SizeH = (Size1.size.y > Size2.size.y) ? Size1.size.y : Size2.size.y
    	this.PopBack.style.height = SizeH +'px';
    	this.PopBack.style.display ='block';
    	this.PopIn.style.display ='block';
    	
    	return this.PopIn;
    },
    
    closePopUp : function (F)
    {
    
        this.PopBack.style.display ='none';
    	this.PopIn.style.display ='none';
        
        
    },
    
    
    setContent : function (URL, FileName, Parameter)
    {
            DOM.removeChilds(this.PopIn);
         
            this.URL            = URL || this.URL; 
            this.FileName      = FileName || this.FileName; 
            this.Parameter     = Parameter || this.Parameter;
            
         var LoadType     = (/^\//).test(this.URL);
         var  Param =    {  'MODE' : 'Call'  };  
    	      Param["Type"] = (!LoadType) ? "Component" : "Page";
        	  Param["File"] =  this.FileName ||  "Content.php";
        	
        	  if(!LoadType)
        	  {
        	      Param["Name"] = this.URL;
        	      var TURL = '/';
        	  }
        	  else var TURL = this.URL;
	  
	  Extends(this.Parameter, Param);
	  
       AutoRun.setDocument(this.PopIn, Param, TURL);
        
     },
    
    setPopUp : function ()
    {
    	
    	this.PopBack = document.createElement("div");
    	this.PopBack.className = 'PopBack';
    	this.PopBack.style.display = 'none';
    	
    	document.getElementsByTagName('BODY')[0].appendChild(this.PopBack);
    	
    	UI.setOpacity(this.PopBack, 50);
    	
    	
    	this.PopIn = document.createElement("div");
    	this.PopIn.className = 'PopIn';
    	this.PopIn.style.display = 'none';
    	document.getElementsByTagName('BODY')[0].appendChild(this.PopIn);
    	
    	
    },
    
    Drag : function (event)
    {
        
        if(!this.DragObj) return true;
        
        var MousePos = UI.getMousePos(event);
        
        if(this.DragObj.el) 
        {
        
                var MovedDistance =
                {
                    x : this.DragObj.MousePos.x - MousePos.x,
                    y : this.DragObj.MousePos.y - MousePos.y
                }
             
              var PosX = this.DragObj.Org.x - MovedDistance.x;
              var PosY = this.DragObj.Org.y - MovedDistance.y;
            
            
            // 레이어가 외부로 나가지 못하게 하는 부분
        
               
               if(isObject(this.DragObj.Max))
                {
                    PosX = ( this.DragObj.Max.x  < PosX ) ? this.DragObj.Max.x : PosX;
                    PosY = ( this.DragObj.Max.y  < PosY ) ? this.DragObj.Max.y : PosY;
                }
            
                if(isObject(this.DragObj.Min))
                {
                    PosX = ( this.DragObj.Min.x  > PosX ) ? this.DragObj.Min.x : PosX;
                    PosY = ( this.DragObj.Min.y  > PosY ) ? this.DragObj.Min.y : PosY;
                }
            
            /////////////////////////////////////////////////////////////////////////
            
            
            
            
            
              this.DragObj.el.style.left = PosX + 'px';
              this.DragObj.el.style.top = PosY + 'px';
                  
            return true;
		}
		
		
	   if( this.DragObj.resize != null ) 
		{
		
		 	var Win = this.WindowObj[this.DragObj.resize];
			
			
			var ObjPos =UI.getOffsetPos(Win.Win);
			
			var Size = 
			{
				w : Math.abs(MousePos.x - ObjPos.x),
				h : Math.abs(MousePos.y - ObjPos.y)
			}
		    
		    
		  //  alert(MousePos.y + ": " + ObjPos.top);
		    
		      
			if(Size.w-100 > 0 && Size.h-25 > 0)
			{
			    
			     
			     Win.setHeight(Size.h);
				 Win.setWidth(Size.w);
			}
		    
		   // this.DragObj.resize = null;
		   return true;
		}
		
                
       
        
        
        
    },
   
    getTabWin : function (URL)
    {
        this.TabWin = new this.tabMenu(URL);  
        
        return this.TabWin;
    },
    
    getBoard : function ()
    {
        var Win = new this.getPannel();
        Win.setContentArea();
        Win.setPosition(true);
        return Win;
    },
    
    getWinById : function (wid)
    {
        var Win = document.getElementById(wid);
        
        if(Win)
        {
            if(Win.getAttribute('ObjNum') !== null)
            return _Window.WindowObj[Win.getAttribute('ObjNum')];
        }    
       
       return false; 
    },
    
    getWin : function (P)
    {
        var Win = new this.getPannel();
        
        if(isObject(P))
        {
            if(isBoolean(P.Position))    Win.setPosition(P.Position);
            if(isString(P.wid))            Win.Win.id = P.wid;
            if(isString(P.Title))           Win.setTitle(P.Title);
            
            P.Buttons = P.Buttons || 3;
            Win.setButtons(P.Buttons);
            
            if(isBoolean(P.resize))      Win.setResizeBar(P.resize);
            
             Win.setContentArea();
            
           
            
            if(P.Height)                 Win.setHeight(P.Height);
            if(P.Width)                  Win.setWidth(P.Width);
            
            
        }
        
        Win.setDrag(true);
        
       
        
      
        return Win;
    },
    
    view : function (Wid, Title, W, H, BtType)
    {
         var Win = this.getWinById(Wid);
         
         if(!Win)
         {
            var Win = new this.getPannel();
                 Win.setPosition(true);
                 if(Wid)  Win.Win.id = Wid;
         }     
     
     
     
            Win.setTitle(Title);
            
            Win.setButtons(BtType || 3);
            //Win.setResizeBar(P.resize);
            
            Win.setContentArea();
            
            Win.Win.style.zIndex = _Window.zIndex;
        
            
            if(W)    Win.setWidth(W);
            if(H)     Win.setHeight(H);
        
             Win.setDrag(true);
      
        return Win;
    },
    
    showWindow : function (Obj, Title, URL, W, H, Param)
    {
           var Windows = new this.getPannel();
          Windows.setPosition(true);
          Windows.append(_Window.parentWindow(Obj).Content);
           
           
           
           Windows.setTitle(Title);
           Windows.setContentArea();
           Windows.setDrag(true);
          
          
          if(Param)
          
          
           Windows.setResizeBar(true);
           Windows.setButtons(3);
          
          
            
           
           if(W)    Windows.setWidth(W);
           if(H)     Windows.setHeight(H);
            
           var  Param = Param || {};
                    
          Param['onComplete'] =  function () { Windows.setCenter();   }    
          Windows.setContent(URL, "Content.php", Param );    
        
        return Windows;
    },
    
    
    parentWindow : function (Element)
    {
        var El = Element.parentNode;
        while(El.parentNode && El.parentNode.nodeName != 'BODY')
        {
            
            if(El.getAttribute('ObjNum') === null)    El = El.parentNode;
            else return _Window.WindowObj[El.getAttribute('ObjNum')];
        }
        
       return Element.parentNode;  
    },
    
    childWindow : function (Element)
    {
        var El = DOM.getRealChildNode(Element);
        var Cwin = new Array();
        for(var i=0; i< El.length; i++)
        {
            if(El[i].getAttribute('ObjNum'))  Cwin.push(El[i]); 
        }
        
        
       return Cwin;
    },
    
    childWindows : function (Element)
    {
        
          var El = DOM.getRealChildNode(Element);
          var Cwin = new Array();
          
            for(var i=0; i< El.length; i++)
            {
                var  ObjNum = El[i].getAttribute('ObjNum');
                
                if(ObjNum) 
                {
                    Cwin.push(_Window.WindowObj[ObjNum]); 
                }
                
                
                var Cwind = this.childWindows(El[i]);
                if(Cwind.length)    Cwin = Cwin.concat(Cwind);
            }
        
              
           return Cwin;  
         
    },
    
    claerAll : function ()
    {
        for(var N=0; N < this.WindowObj.length; N++)
        {
            var Win = this.WindowObj[N];
            if(Win)  Win.remove();
        }
        
    },
    
    
    getButton : function (Value)
    {
         var Table = document.createElement('table');
        
           Table.setAttribute("cellPadding",'0');
		   Table.setAttribute("cellSpacing",'0');
		   Table.setAttribute("border",'0');
		   Table.className = 'ButtonTable';
		
		
		if(IE_) document.body.appendChild(Table);
		
		
        var TBODY = document.createElement("TBODY");
              Table.appendChild(TBODY);
        
       // Table.border = '0';
        
        var Row = TBODY.insertRow(-1);
        
        var Left = Row.insertCell(-1);
             Left.setAttribute("width", '14');
        var Center = Row.insertCell(-1);
        var Right = Row.insertCell(-1);
             Right.setAttribute("width", '10');
        
        Center.onselectstart = function (e)
        {
            return false;
        }
        
        Center.onmousedown = function (e)
        {
            return false;
        }
        
        
        Left.className   = 'ButtonLeft';
        Center.className = 'ButtonBack';
        Right.className  = 'ButtonRight';
        
        var Title = document.createElement('SPAN');
        Center.appendChild(Title);
        Title.appendChild(document.createTextNode(Value));
      
        if(IE7_ && isOnlyKor(Value)) 
        {
           Title.style.display = 'inline-block';
           Title.style.verticalAlign = 'text-bottom';
           Title.style.paddingTop = '3px';
        }
     
      
        
      Table.onmouseover = function (e)
      {
            var Cnode = this.cells;
            Cnode[0].className =  'ButtonLeft_Press';
            Cnode[1].className =  'ButtonBack_Press';
            Cnode[2].className =  'ButtonRight_Press';
            
      }.bind(Row);
        
      Table.onmouseout = function (e)
      {
            var Cnode = this.cells;
            Cnode[0].className =  'ButtonLeft';
            Cnode[1].className =  'ButtonBack';
            Cnode[2].className =  'ButtonRight';
        
      }.bind(Row);
        
        
      return Table;
        
    },
    
    relativePos : function (Obj)
    {
    	var OPos = UI.getOffsetPos(Obj);
    	var Pos = UI.getOffsetPos(this.parentWindow(Obj).Content);
    	return { "x" : OPos.x - Pos.x , "y" :  OPos.y - Pos.y };
    },
	
	writeTabWin2 : function (bname , Obj, Title, URL, W, H, Param)
    {
		if($(bname) != null){
			_Window.parentWindow($(bname)).remove();
		}

		var Windows = new this.getPannel();
		Windows.setPosition(true);
		Windows.append(_Window.parentWindow(Obj).Content);

		Windows.setTitle(Title);
		Windows.setContentArea();
		Windows.setDrag(true);
		if(Param)
		Windows.setResizeBar(true);
		Windows.setButtons(3);

		if(W)    Windows.setWidth(W);
		if(H)     Windows.setHeight(H);

		var  Param = Param || {};
                    
        Param['onComplete'] =  function () { Windows.setCenter();   }  
		
        Windows.setContent(URL, "Content.php", Param ); 
        return Windows;

    }
    
    
}


_Window.getPannel = function ()
{
        
        this.UDIR = getComponentURL('_Window'),
		this.imgDir = this.UDIR +'_Images';
		this.ConDir = this.imgDir + '/WinControl/';
         var parentDiv = document.body;
          
         this.Win = document.createElement("div");
         parentDiv.appendChild( this.Win );
         
         this.Win.className = 'OutBox';
         this.Win.style.zIndex = _Window.zIndex++; 
          
          this.Win.setAttribute('ObjNum', _Window.WindowObj.length);
          _Window.WindowObj.push(this);
          this.Win.onmousedown = function (e) {    this.setIndex();  }.bind(this);
           
          this.In = document.createElement("div");
          this.Win.appendChild(this.In);
          this.In.className = 'InBox';
          
         return this;
}


_Window.getPannel.prototype = {
    
      setContentArea : function()
      {
          if(this.Content) return false;
          this.Content = document.createElement("div");
          this.In.appendChild(this.Content);
          this.Content.className = 'ContentBox';
         
      },
      
      setDisplay : function(value)
      {
         this.Win.style.display = (value) ? "block" : "none";    
      },
      
      setIndex : function ()
      {
          var brotherWins = _Window.childWindow(this.Win.parentNode);
          
          for(var i=0; i < brotherWins.length; i++)
          {
              var bW = brotherWins[i];
              bW.style.zIndex = 1;
              bW.setAttribute("display" , bW.style.display);
              bW.style.display = "none";
          }
          
          this.Win.style.zIndex = _Window.zIndex++;
          
          this.Win.style.display = 'block';
          this.Win.setAttribute("display" , 'block');
         
            
          for(var i=0; i < brotherWins.length; i++)
          {
              var bW = brotherWins[i];
              bW.style.display = bW.getAttribute("display");
          }
          
          
      },
      
      
      setTitleBar : function()
      {
          if(this.TitleBar) return false;
          
          this.TitleBar = document.createElement("div");
          this.TitleBar.className = 'TitleBar';
        
          this.TitleBar.onselectstart = new Function("return false");
          
          this.In.appendChild(this.TitleBar);
      },
      
      
      setDrag : function (value)
      {
         
         this.Drag = value;
         
         
         
        
         
         if(!value)
         {
             this.TitleBar.onmousedown = null;
             this.TitleBar.onmouseup = null;
             return;   
         } 
          
          
         this.TitleBar.onmousedown = function (e)
          {
              var MousePos = UI.getMousePos(e);
             
             this.Win.style.zIndex = _Window.zIndex++;
             
             
             
         
             var Pos = 
             {
                x : (isNaN(parseInt(this.Win.style.left))) ? 0 : parseInt(this.Win.style.left),
                y : (isNaN(parseInt(this.Win.style.top))) ? 0 : parseInt(this.Win.style.top)
             }
                    
            
             UI.setOpacity(this.Win, 50);
              
              var pSize = UI.getObjSize(this.Win.parentNode);
              var oSize = UI.getObjSize(this.Win);
                
                
             if(this.Win.style.position == 'absolute')
             {
                var Min = { "y" : 0, "x" : 0 };
                var Max = '';
             }
             else 
             {
                var pPos = UI.getOffsetPos(this.Win.parentNode);
                var Pos   = UI.getOffsetPos(this.Win);
               
                var Min = { "y" : pPos.y - Pos.y, "x" : pPos.x - Pos.x };
                var Max = ''; 
                 
             }
             
             _Window.DragObj = { "el" : this.Win, "MousePos" : MousePos  , "Org" : Pos , "Min" : Min, "Max" : Max};  
             return true;
          }.bind(this);
          
          
          this.TitleBar.onmouseup = function (e)
          {
             
              UI.setOpacity(this.Win, 100);
              return true;
          }.bind(this);
          
          
      },
      
      setTitle : function (Text)
      {
         this.setTitleBar();
         
         if(this.Title && this.Title == Text) return;
         
         DOM.removeChilds(this.TitleBar);
         
         this.Title = Text;
         
         var Logo = document.createElement('div');
              Logo.className = 'Logo';
         
        this.TitleBar.appendChild(Logo);
        
        var TitleArea = document.createElement('div');
        TitleArea.className ="TitleArea";
         this.TitleBar.appendChild(TitleArea);
         
         
         if(IE7_ && isOnlyKor(Text) )
         {
            TitleArea.style.top = "4px";
         }
         
         
           var TitleBack = document.createElement('span');
    			TitleBack.style.position 	       = 'relative';
    			TitleBack.style.width            = '100%';
    			TitleBack.style.top               = '0px';
    			TitleBack.style.left               = '0px';
    			TitleBack.style.fontWeight      = 'bold';
    			TitleBack.style.color             = '#000';
    		
    		 TitleArea.appendChild(TitleBack);
    		 TitleBack.appendChild(document.createTextNode(Text));
    		
    		
    		 var TitleIn = TitleBack.cloneNode(true);
    		 TitleIn.style.position 	= 'absolute';
    		 TitleArea.appendChild(TitleIn);
     
              	TitleIn.style.top = '0px';
    			TitleIn.style.left = '0px';
    			TitleIn.style.color =  '#FFF';
    			
    	 if(this.btType) this.setButtons(this.btType);
    	 
      },
      
      setButtons : function (btType)
      {
             this.setTitleBar();
             this.btType = btType;
               
             this.BtArea = document.createElement("div");
             this.BtArea.className = "BtArea";
             this.BtArea.setAttribute('align', 'right');
             
             this.TitleBar.appendChild(this.BtArea);
            
            var nodeType =  'span';
             
            
            if(btType > 1)
            {      
                var BtBox =  document.createElement(nodeType);
                     this.setEvent(BtBox);
                     this.BtArea.appendChild(BtBox);
                     BtBox.appendChild(this.getButtonImg('mini'));
                     BtBox.onclick = this.minimize.bind(this);
                     
               
                var BtBox =  document.createElement(nodeType);
                     this.setEvent(BtBox);
                     this.BtArea.appendChild(BtBox);
                     this.fullBt = this.getButtonImg('full');
                     
                     BtBox.appendChild(this.fullBt);
                     BtBox.onclick = this.fullScreen.bind(this);
                     
                     BtBox.style.marginRight = '2px';
             }
                      
            var BtBox = document.createElement(nodeType);
                 this.setEvent(BtBox);
                 this.BtArea.appendChild(BtBox);
                 BtBox.appendChild(this.getButtonImg('close'));
                 BtBox.onclick = this.remove.bind(this);
         
      },
      
      
        
       setEvent : function (BtBox)
       {
             BtBox.className = (IE_) ? "btBack" : "FFbtBack";
           
             BtBox.onmousedown =  function (e)
                 {
                     cancel(e);
                     this.className = (IE_) ? "btPress" : "FFbtPress";
                 }.bind(BtBox);
                  
             
                BtBox.onmouseout =  
                 function (e)
                 {
                     cancel(e);
                     this.className =  (IE_) ? "btBack" : "FFbtBack";
                 }.bind(BtBox);
            
             
             BtBox.onmouseup = 
                 function (e)
                 {
                     cancel(e);
                     this.className =  (IE_) ? "btBack" : "FFbtBack";
                 }.bind(BtBox);
          
        },
         
      getButtonImg : function (Type)
      {
          var Bt =  document.createElement('img');
               Bt.src = this.ConDir + Type + '.gif';
          return Bt;
     },
      
     setContent : function (URL, FileName, Parameter)
     {
            DOM.removeChilds(this.Content);
         
            this.URL            = URL || this.URL; 
            this.FileName      = FileName || this.FileName; 
            this.Parameter     = Parameter || this.Parameter;
            
         var LoadType     = (/^\//).test(this.URL);
         var  Param =    {  'MODE' : 'Call'  };  
    	      Param["Type"] = (!LoadType) ? "Component" : "Page";
        	  Param["File"] =  this.FileName ||  "Content.php";
        	
        	  if(!LoadType)
        	  {
        	      Param["Name"] = this.URL;
        	      var TURL = '/';
        	  }
        	  else var TURL = this.URL;
	  
	   Extends(this.Parameter, Param);
	 
       AutoRun.setDocument(this.Content, Param, TURL);
        
     },
    
    reload : function ()
    {
       if(this.URL)
       {
          this.setContent();    
       }
    },
     
    clean : function ()
    {
        DOM.removeChilds(this.Content);   
    },
    
     setCenter : function ()
     {
        this.setPosition(true);
        UI.setCenter(this.Win);
     },
    
    
     remove : function ()
     {
         if(isFunction(this.onClose)) this.onClose();
 
         if(this.Content)
         {
             var Cwin = _Window.childWindows(this.Content);
		     for(var i=0; i < Cwin.length; i++)      Cwin[i].remove();
         }
         
         
          DOM.remove(this.Win);
 
         delete  _Window.WindowObj[this.Win.getAttribute('ObjNum')];
         _Window.WindowObj[this.Win.getAttribute('ObjNum')]=null;
     },
    
     setHeight : function (H)
     {
         if(isNumber(H)) 
         {
              H = H-2;
             this.Win.style.height = H + 'px';
             this.In.style.height = H-2 + 'px';
             
            var TopSize =2;
            if(this.TitleBar)  TopSize += UI.getObjSize(this.TitleBar).h;
            if(this.tabArea)  TopSize += UI.getObjSize(this.tabArea).h;
            if(this.Content)     this.Content.style.height = H - (TopSize) + 'px';
         }
         else 
         {
            
              var H1 = parseFloat(H);
              if( H.replace(H1, "") == "%") 
              {
          		  this.setHeight(Math.round(UI.getObjSize( this.Win.parentNode ).h * (H1/100)));   
          		  return;
              }
          
              return;
         }
        
     },
     
     setWidth : function (W)
     {
         if(isNumber(W))
         {
            W = W-2;
            this.Win.style.width = W + 'px';
            this.In.style.width = W-2 + 'px';
            if(this.Content)
            this.Content.style.width = W-2 + 'px';
         }
         else 
         {
              var W1 = parseFloat(W);
       
              if( W.replace(W1, "") == "%") 
              {
                 this.setWidth(Math.round(UI.getObjSize( this.Win.parentNode ).w * (W1/100)));   
                 return;
              }
              
              if( W.replace(W1, "") == "") 
              {
                 this.setWidth(W1);   return;
              }
         
         
              this.Win.style.width = W;
              this.In.style.width = 'auto';
              
              if(this.Content)
              this.Content.style.width ="auto";
            
         }
        
       
     },
     
    
     append : function (Pnode)
     {
        if(isObject(Pnode))
        {
            this.Win.setAttribute('Type', 'Windows');
            Pnode.appendChild(this.Win);
            this.setIndex();
         }   
     },
     
     setPosition : function (value)
     {
        this.Win.style.position =  (value)  ? 'absolute' :  'relative';
     },
     
     fullScreen : function ()
     {
        if(this.Org)
        {
                this.Win.style.position    = this.Org.position;
                this.Win.style.top          = this.Org.top;
                this.Win.style.left          =  this.Org.left;
                
                
                this.setWidth(this.Org.width);
                this.setHeight(this.Org.height);
                
                if(this.Org.Drag) this.setDrag(true);
                if(this.Org.Resize) this.setResizeBar(true);
                
                this.Org = null;   
                
                if(this.fullBt)
                {
                     var Fullbt = this.getButtonImg('full');
                     this.fullBt.src = Fullbt.src;
                     Fullbt.removeNode(true);
                } 
             
        }
        else
        {
              this.Org = {};
              this.Org.position     = this.Win.style.position;	
              this.Org.top           = this.Win.style.top;	
    		  this.Org.left            = this.Win.style.left;
    		  this.Org.width         = UI.getObjSize(this.Win).w;
    		  this.Org.height        = UI.getObjSize(this.Win).h;
    		  this.Org.Drag          = this.Drag;
    		  this.Org.Resize        = this.Resize;
    		    
    		  this.Win.style.top      = "0px";
    		  this.Win.style.left       = "0px";
    		  var Size = UI.getObjSize(this.Win.parentNode);
    		  this.setHeight("100%");
    		  this.setWidth(Size.w);
    		  
    		  this.setDrag(false);
    		  this.setResizeBar(false);
    		  
    		  if(this.fullBt)
              {
                    var Fullbt = this.getButtonImg('cascade');
                    this.fullBt.src = Fullbt.src;
                    Fullbt.removeNode(true);
               }    
		}
     },
     
     minimize : function ()
     {
         this.setDisplay(false);
         _Window.setMinimize(this.Win.getAttribute('ObjNum'));
     },
     
    setResizeBar : function (value)
	{
		this.Resize = value;
		
		if(value)
		{
		    if(this.ResizeBox)
		    {
		         this.ResizeBox.style.display ='block'; return;
		    } 
		    
		    this.ResizeBox = document.createElement('DIV');
    	    this.ResizeBox.className = 'ResizeBox';
    		this.Win.appendChild(this.ResizeBox);
    		var ResizeImg = document.createElement('DIV');
    			 ResizeImg.className = 'ResizeImg';
    		
    		this.ResizeBox.appendChild(ResizeImg);
    	
        	
    		ResizeImg.onmousedown = function ()
    		{
    		   document.body.style.cursor = "nw-resize";
    		   document.body.onselectstart = new Function("return false");
    			_Window.DragObj = { "resize" :  this.Win.getAttribute('ObjNum') };
    		
    		}.bind(this);
		    
		    
		}
		else 
		if(this.ResizeBox)  this.ResizeBox.style.display ='none'; 
		
		
		
		
	},
	
	addMenu : function (Title, Func)
	{
		   var Div = document.createElement('DIV');
		   
		   this.Content.appendChild(Div);
		 
		   Div.style.position ='relative';
		   Div.style.margin ='1px';
		   Div.style.paddingTop = '3px';
		   Div.style.paddingLeft = '3px';
		   
		   Div.style.color ='#000099';
		   Div.style.backgroundColor ='';
		   Div.style.cursor ='pointer';
		   
		   Div.onmouseout = function (e) 
		   { 
		       cancel(e);
		       this.style.backgroundColor ='';
		       this.style.color ='#000099';
		   }
		   
		   Div.onmouseover = function (e) 
		   { 
		       cancel(e);
		       this.style.color ='#FFFFFF';
		       this.style.backgroundColor = '#000099';  
		   }
		   
		   Div.appendChild(document.createTextNode(Title));
		   Div.onclick = Func;
		    
	},
	
	addHR : function ()
	{
		   var Div = document.createElement('DIV');
		   Div.className = "HR";
		   this.Content.appendChild(Div);
	}
	
}
    

_Window.tabMenu = function (URL) 
{
    this.Win = new _Window.getPannel();
    
    this.Win.setPosition(true);
    this.setDirNodes(URL);
 
    this.Win.setTitle(this.Main.Menu);
    this.Win.setButtons(1);
    
    this.Win.tabArea = document.createElement('div');
    this.Win.tabArea.className = "TabArea";
    this.Win.In.appendChild(this.Win.tabArea);
    
    
    this.setSubMenus();
    
    this.Win.setContentArea();
    
    
    this.setMenuEvent();
      
    
    
    this.Win.setContent(URL);
    
  
    
    
    return this.Win;
 
}

_Window.tabMenu.prototype =
{

    setDirNodes : function (Path)
    {
        //var Result 	    = Ajaxexe(this.Win.UDIR + 'DirectoryList.php?Path='+Path).xml;
	    var  Test = Ajax.exec(this.Win.UDIR + 'DirectoryList.php?Path='+Path);
	    var  Result = Test.xml;
	    
	    
	    var Nodes 		= Result.getElementsByTagName('RESULT')[0];
		var MainDir 	    = DOM.getRealChildNode(Nodes);
        this.SubDir 		= DOM.getRealChildNode(MainDir[0]);
        this.Main         = DOM.getAttributes(MainDir[0]);
          
    },
    
    setSubMenus : function ()
    {
        for(var i=0; i<this.SubDir.length; i++)
        {
             var Menu = document.createElement("div");
             Menu.className = "TabMenu";
             
             this.Win.tabArea.appendChild(Menu);
             
             var TabLeft         =  document.createElement("div");
             var TabCenter     =  document.createElement("div");
             var TabRight       =  document.createElement("div");
             
             TabLeft.className         =  "TabLeft";
             TabCenter.className       = "TabCenter";
             TabRight.className        =  "TabRight";
            
            
            Menu.appendChild(TabLeft);
            Menu.appendChild(TabCenter);
            Menu.appendChild(TabRight);
             
             var SubAtt = DOM.getAttributes(this.SubDir[i]);  
             var Title = document.createElement("SPAN");
                  Title.className = "TabMenuTitle";
                  
                 if(IE_ && (/^[가-힣]/).test(SubAtt.Menu) ) Title.style.paddingTop = '3px';
                   
                  Title.appendChild(document.createTextNode(SubAtt.Menu));
                 TabCenter.appendChild(Title);
        
        
             Menu.setAttribute("Path", SubAtt.Path);
           
            Menu.onclick = function (e)
            {
               
               var oldWin = _Window.getWinById(this.Path);
               
               if(oldWin)
               {
                   if( oldWin.Win.style.display != 'none' )
                   oldWin.setIndex();
                   
                   return;
               }
               
               
                var Win = _Window.getWin({
                "wid" : this.Path,
                "Title" : this.Menu,
                "Position" : true,
                "resize" : true
                } );
        
              
                Win.append(_Window.TabWin.Content);
               
                Win.setWidth("50%");
                Win.setHeight("80%");
                
                Win.setContent(this.Path, "Content.php");
                
                
                Win.fullScreen();
                
                
            }.bind(SubAtt);
           
           
        
        }
        
    },
    
    setMenuEvent : function ()
    {
         var Menus = DOM.getRealChildNode(this.Win.tabArea);
         
         for(var i=0; i< Menus.length; i++)
         {
             var Menu = Menus[i];
             
             Menu.onmousedown = function (e)
             {
                 var AllMenus = DOM.getRealChildNode( this.parentNode );
                 
                 for(var M=0; M < AllMenus.length; M++)
                 {
                     if(AllMenus[M].getAttribute("Over"))
                     {
                         var Cnode = DOM.getRealChildNode ( AllMenus[M] );
                         Cnode[0].className =   "TabLeft";
                         Cnode[1].className =   "TabCenter";
                         Cnode[2].className =   "TabRight";
                         AllMenus[M].removeAttribute("Over");
                     }
                 }
              
                
                var sNodes = DOM.getRealChildNode(this);
                for(var i=0; i< sNodes.length; i++)    
                sNodes[i].className =  sNodes[i].className +'_Over';
                
                this.setAttribute("Over", "1");
                
                
       
           
             }
             
            
             
         }
        
    }
    
}



var Win = 
{
  getTableBt : function (Value)
  {
    var Img = Win.UDIR + '_Images/Button/';
   
  	var BtTable = document.createElement('Table');
  	
  	   	 BtTable.Img = Img;
			
			  BtTable.setAttribute("cellPadding",'0');
			  BtTable.setAttribute("cellSpacing",'0');
			  BtTable.setAttribute("border",'0');
			  
			  
			  BtTable.style.display ="inline";
			 
			  
			  BtTable.style.margin = '0px';
			  BtTable.style.verticalAlign = 'baseline';
			  BtTable.style.cursor = 'pointer';
			  
		BtTable.TBody = document.createElement('TBODY');
		BtTable.appendChild(BtTable.TBody);
		
		BtTable.Row = BtTable.TBody.insertRow(-1);
		
        
     var CellLeft = 	BtTable.Row.insertCell(-1);	
         
         BtTable.LeftImg = document.createElement('IMG');
          CellLeft.appendChild(BtTable.LeftImg);
   
          BtTable.CellCenter = 	BtTable.Row.insertCell(-1);	
         
           BtTable.CellCenter.vAlign = 'middle';
           BtTable.CellCenter.style.padding = '2px';
         
          
           BtTable.CellCenter.innerHTML = Value; 
           
           
          
          if(IE7_)
          {
                if(isEng(Value)) BtTable.CellCenter.style.paddingBottom = '2px';  
                else  BtTable.CellCenter.style.paddingTop = '4px';
          }
          
          if(!IE_) BtTable.CellCenter.style.paddingBottom = '4px';
          
          //BtTable.BtValue = document.createElement('SPAN');
         
           
          //BtTable.BtValue.innerHTML = Value;
          //BtTable.CellCenter.appendChild(BtTable.BtValue);
          
     var CellRight = 	BtTable.Row.insertCell(-1);	
        
     BtTable.RightImg = document.createElement('IMG');
     
           CellRight.appendChild(BtTable.RightImg);
           
           
    
     BtTable.onmouseover = function ()
     {
          this.LeftImg.src = this.Img + 'button_press_left.gif';
          this.CellCenter.style.background = 'url('+this.Img+'button_press_back.gif) repeat-x';
          this.RightImg.src = this.Img + 'button_press_right.gif';
          this.CellCenter.style.color = '#990000';
     }
     
     BtTable.onmouseout = function ()
     {
          this.LeftImg.src = this.Img + 'button_left.gif';
          this.CellCenter.style.background = 'url('+this.Img+'button_back.gif) repeat-x';
          this.RightImg.src = this.Img + 'button_right.gif';
          this.CellCenter.style.color = '#555';
     }
     
     BtTable.onmouseout();
    
     
     return BtTable;
    
	}
	
}






addEvent(window, 'load', _Window.setTray.bind( _Window));

