// *********************************************************************
// *                   EVENTS					       *
// *********************************************************************

// * Floater_OnLoadFailed(SENDER, EXCEPTION)
// * Floater_OnAttachFailed(SENDER, EXCEPTION)
// * Floater_OnDetachFailed(SENDER, EXCEPTION)
// * Floater_OnMoveStart(SENDER, e)
// * Floater_OnMoveEnd(SENDER, e)
// * Floater_OnMove(SENDER, e)
// * Floater_OnMouseDown(SENDER, e)
// * Floater_OnMouseUp(SENDER, e)
// * Floater_OnShowByFadeStart(SENDER);
// * Floater_OnShowByFadeEnd(SENDER);
// * Floater_OnHideByFadeStart(SENDER);
// * Floater_OnHideByFadeEnd(SENDER);
// * Floater_OnSlideStart(SENDER);
// * Floater_OnSlideEnd(SENDER);
// * Floater_OnDragOver(SENDER, DRAGGEDOBJECT)
// * Floater_OnDragOut(SENDER, DRAGGEDOBJECT)
// * Floater_OnDrop(SENDER, DROPPEDOBJECT)
// * Floater_OnResizeStart(SENDER)
// * Floater_OnResizeEnd(SENDER)
// * Floater_OnAfterDelete(SENDER)

// * Floater_OnShadowMoveEnd(SENDER, POSITION)
// * Floater_OnShadowResizeEnd(SENDER, ARRAY[0:WIDTH, 1:HEIGHT])

// * Floater_OnPageSizeChanged(SUPERVISOR)

// -- INTERNAL

var internalEvents =
{
'Floater_OnHideByFade': true,
'Floater_OnShowByFade': true,
'Floater_OnSlide': true, 
'Floater_OnDragZoneMouseMove': true,
'Floater_OnDragZoneMouseDown': true,
'Floater_OnHandleMouseMove': true,
'Floater_OnHandleMouseDown': true,
'Floater_OnFollowScreen': true
}

// * Floater_OnHideByFade(SENDER);
// * Floater_OnShowByFade(SENDER);
// * Floater_OnSlide(SENDER, ARRAY[0:DESTINATION, 1:STEP])
// * Floater_OnDragZoneMouseMove(SENDER)
// * Floater_OnDragZoneMouseDown(SENDER)
// * Floater_OnHandleMouseMove(SENDER)
// * Floater_OnHandleMouseDown(SENDER)
// * Floater_OnFollowScreen(SENDER, ARRAY[0:EVENT, 1:STEP])

// *********************************************************************
// *                   PUBLIC					       *
// *********************************************************************

function Floater(id, dragZone, group, attached, useShadow, allowResize)
{  
   // *********************************************************************
   // *                   CONSTRUCTOR				     	  *
   // *********************************************************************
   try
   {          
      var MySelf = this;
      this.group = group;
      this.useShadow = useShadow;
      this.allowResize = allowResize;
      
      this.DragZoneMouseMove = function(e)
      {
         if(MySelf.isDragEnabled) { MySelf.dragZone.style.cursor = 'move'; }
   	 else { if(MySelf.usePointers) { MySelf.dragZone.style.cursor = 'not-allowed'; } }
      }
      
      this.DragZoneMouseDown = function(e)
      {
         var authority = (MySelf.useShadow && !MySelf.customs['Floater_attached']) ? MySelf.CreateShadow() : MySelf;
         authority.clip.x = supervisor.mouse.x - authority.position.x;
         authority.clip.y = supervisor.mouse.y - authority.position.y;
         authority.Detach();
         MySelf.LoadEvent((MySelf.isDragEnabled) ? 'Floater_OnMoveStart' : 'Floater_OnMouseDown', e);
         if((authority.isDetached || authority.IsInResizeMode()) && e) { e.preventDefault(); }
      }
   
      this.DragZoneMouseUp = function(e)
      {
      	 this.RefreshFollowPoint();
      	 MySelf.LoadEvent((MySelf.isDragEnabled) ? 'Floater_OnMoveEnd' : 'Floater_OnMouseUp', e);
      }
      
      this.HandleMouseMove = function(e)
      {
         if((!supervisor.customs['Supervisor_attachedObject'] || MySelf == supervisor.customs['Supervisor_attachedObject'])
            && MySelf.allowResize && !MySelf.customs['Floater_attached'])
         {
            var endX = MySelf.position.x + MySelf.handle.offsetWidth;
	    var endY = MySelf.position.y + MySelf.handle.offsetHeight;	    
	    if((supervisor.mouse.x - endX) >= -5 && (supervisor.mouse.y - endY) >= -5 && this.hResize && this.wResize) { MySelf.css.cursor = 'se-resize'; }
	    else if((supervisor.mouse.x - endX) >= -5 && this.wResize) { MySelf.css.cursor = 'e-resize'; }
	    else if((supervisor.mouse.y - endY) >= -5 && this.hResize) { MySelf.css.cursor = 's-resize'; }
	    else if(MySelf.dragZone == MySelf.handle) { MySelf.DragZoneMouseMove(e); }
	    else { MySelf.css.cursor = ''; }
	 }
	 else
	 {
	    if(MySelf.dragZone == MySelf.handle) { MySelf.DragZoneMouseMove(e); }
	    else { MySelf.css.cursor = ''; }
	 }
      }
      
      this.HandleMouseDown = function(e)
      {
         var authority = (MySelf.useShadow  && !MySelf.customs['Floater_attached'] && MySelf.IsInResizeMode()) ? MySelf.CreateShadow() : MySelf;
         if(authority.allowResize && authority.IsInResizeMode())
         { 
            AttachEvent(document, 'selectstart', authority.CancelSelection);
	    supervisor.customs['Supervisor_attachedObject'] = authority;
            authority.Focus(true);
            MySelf.LoadEvent('Floater_OnResizeStart', null);
         }
         else if(MySelf.dragZone == MySelf.handle) { MySelf.DragZoneMouseDown(e); }
         if((authority.isDetached || authority.IsInResizeMode()) && e) { e.preventDefault(); }
      }
      
      this.HandleMouseUp = function(e)
      {
         if(MySelf.IsInResizeMode()) { MySelf.LoadEvent('Floater_OnResizeEnd', null); }
      }
      
      this.EntityScroll = function(e)
      {
	 if (!e) var e = window.event;
	 if(!MySelf.intervalId['ScrollSlide'])
	 {
	    MySelf.intervalId['ScrollSlide'] = setInterval(function()
	    {
	       MySelf.LoadEvent('Floater_OnFollowScreen', new Array(e, 10));
	    }, 15);
         }
      }
   
      this.CancelSelection = function(e)
      {
   	return false;
      }
      
      this.IsInResizeMode = function()
      {
         return (MySelf.css.cursor.indexOf('resize') != -1);
      }
      
      // *********************************************************************
      // *                   DAD					     *
      // *********************************************************************

      this.HandleOnDrop = function()
      {
         var authority = (supervisor.customs['Supervisor_attachedObject'] && supervisor.customs['Supervisor_attachedObject'].customs['Floater_shadowOwner']) 
	    ? supervisor.customs['Supervisor_attachedObject'].customs['Floater_shadowOwner'] 
            : supervisor.customs['Supervisor_attachedObject'];
         if(supervisor.customs['Supervisor_dropTargets'][this.id] && authority.isDropEnabled)
         {
            MySelf.LoadEvent('Floater_OnDrop', (authority && !authority.IsInResizeMode()) ? authority : null);
         }
      }
      
      this.HandleMouseOver = function()
      {
         var authority = (supervisor.customs['Supervisor_attachedObject'] && supervisor.customs['Supervisor_attachedObject'].customs['Floater_shadowOwner']) 
            ? supervisor.customs['Supervisor_attachedObject'].customs['Floater_shadowOwner'] 
            : supervisor.customs['Supervisor_attachedObject'];
     	 if(supervisor.customs['Supervisor_dropTargets'][this.id])
         {
     	    MySelf.LoadEvent('Floater_OnDragOver', (authority && !authority.IsInResizeMode()) ? authority : null);
     	 }
      }
      
      this.HandleMouseOut = function()
      {
         var authority = (supervisor.customs['Supervisor_attachedObject'] && supervisor.customs['Supervisor_attachedObject'].customs['Floater_shadowOwner']) 
	    ? supervisor.customs['Supervisor_attachedObject'].customs['Floater_shadowOwner'] 
            : supervisor.customs['Supervisor_attachedObject'];
         if(supervisor.customs['Supervisor_dropTargets'][this.id])
         {
            MySelf.LoadEvent('Floater_OnDragOut', (authority && !authority.IsInResizeMode()) ? authority : null);
         }
      }
      
      // *********************************************************************
      // *                   EFFETCS					     *
      // *********************************************************************
      
      this.ShowByFade = function(speed, maxFadeValue)
      {
         if(!MySelf.intervalId['ShowByFade'])
         {
            MySelf.css.display = 'block';
            MySelf.intervalId['ShowByFade'] = setInterval(function()
            {
               MySelf.LoadEvent('Floater_OnShowByFade', (maxFadeValue) ? maxFadeValue : 10);
            }, speed);
            MySelf.LoadEvent('Floater_OnShowByFadeStart', null);
         }
      }
      
      this.HideByFade = function(speed)
      {
         if(!MySelf.intervalId['HideByFade'])
         {
            MySelf.intervalId['HideByFade'] = setInterval(function()
            {
               MySelf.LoadEvent('Floater_OnHideByFade', null);
            }, speed);
            MySelf.LoadEvent('Floater_OnHideByFadeStart', null);
         }
      }
      
      this.SlideTo = function(x, y, speed, step)
      {
         if(!MySelf.intervalId['Slide'])
         {
            MySelf.intervalId['Slide'] = setInterval(function()
            {
               MySelf.LoadEvent('Floater_OnSlide', Array(new Point(x, y), step));
            }, speed);
            MySelf.LoadEvent('Floater_OnSlideStart', null);
         }
      }
    
      this.New(id, dragZone, attached);
   }
   catch(e)
   {
      this.LoadEvent('Floater_OnLoadFailed', (typeof(e) == 'object') ? e : new Exception(0, e));
   }
}

Floater.prototype = 
{
   id: null,
   position: null,
   limitT: null,
   limitB: null,
   clip: null,
   isDragEnabled: true,
   isDropEnabled: false,
   isDetached: false,
   usePointers: true,
   intervalId: null,
   fade: 10,
   handle: null,
   dragZone: null,
   css: null,
   customs: null,
   group: null,
   allowResize: false,
   useShadow: false,
   useGreyShadow: false,
   onTop: false,
   hResize: true,
   wResize: true,
   minSize: null
}

Floater.prototype.Detach = function()
{
   try
   {
      if(this.isDragEnabled)
      {
         this.isDetached = true;
         AttachEvent(document, 'selectstart', this.CancelSelection);
         supervisor.customs['Supervisor_attachedObject'] = this;
         this.Focus(true);
      }
   }
   catch(e)
   {
      this.LoadEvent('Floater_OnDetachFailed', (typeof(e) == 'object') ? e : new Exception(0, e));
   }
}

Floater.prototype.Attach = function()
{
   try
   {
      this.isDetached = false;
      DetachEvent(document, 'selectstart', this.CancelSelection);
      supervisor.customs['Supervisor_attachedObject'] = null;
   }
   catch(e)
   {
      this.LoadEvent('Floater_OnAttachFailed', (typeof(e) == 'object') ? e : new Exception(0, e));
   }
}

Floater.prototype.MoveTo = function(x, y)
{
   this.LoadEvent('Floater_OnMoveStart', null);
   this.MoveX(x);
   this.MoveY(y);
   this.RefreshFollowPoint();
   this.LoadEvent('Floater_OnMoveEnd', null);
}

Floater.prototype.MoveX = function(x)
{
   if(this.limitT != null) { x = (x < this.limitT.x) ? this.limitT.x : x; }
   if(this.limitB != null) { x = (x > this.limitB.x) ? this.limitB.x : x; }
   this.css.left = (this.position.x = x) + 'px';
}

Floater.prototype.MoveY = function(y)
{
   if(this.limitT != null) { y = (y < this.limitT.y) ? this.limitT.y : y; }
   if(this.limitB != null) { y = (y > this.limitB.y) ? this.limitB.y : y; }
   this.css.top = (this.position.y = y) + 'px';
}

Floater.prototype.Fade = function(value)
{
   this.fade = value;  
   this.css.filter = 'alpha(opacity=' + value + '0)';
   this.css.opacity = '0' + ((value == 10) ? value : '.' + value);
}

Floater.prototype.ActivateDAD = function(value)
{
   supervisor.customs['Supervisor_dropTargets'][this.id] = (value) ? this : null;
}

Floater.prototype.Focus = function(value)
{
   if(!this.onTop)
   {
      this.css.zIndex = (value) ? (++supervisor.customs['Supervisor_zIndex']) : (supervisor.customs['Supervisor_zIndex'] - 1);
   }
}

Floater.prototype.Delete = function()
{
   supervisor.customs['Supervisor_GarbagesCollector'][this.id] = null;
   supervisor.customs['Supervisor_dropTargets'][this.id] = null;
   this.handle.parentNode.removeChild(this.handle);
   this.LoadEvent('Floater_OnAfterDelete', null);
}

Floater.prototype.ForceRefreshPosition = function()
{
   this.position = offsetPosition(this.handle);
}

Floater.prototype.OnTop = function(value)
{
   this.css.zIndex = (value) ? (supervisor.customs['Supervisor_zIndex']+10000) : (++supervisor.customs['Supervisor_zIndex']);
   this.onTop = value;
}

Floater.prototype.FollowScreen = function(value)
{
   if(value)
   {
      this.RefreshFollowPoint();
      AttachEvent(window, 'scroll', this.EntityScroll);
   }
   else
   { DetachEvent(window, 'scroll', this.EntityScroll); }
}

// *********************************************************************
// *                   PRIVATE					       *
// *********************************************************************

Floater.prototype.New = function(id, dragZoneId, attached)
{
   this.id = UniqID();
   this.handle = document.getElementById(id);
   if(this.handle == null) { throw new Exception(0, 'Object \'' + id + '\' does not exists.'); }
   this.css = this.handle.style;
   if(dragZoneId)
   {
      this.dragZone = document.getElementById(dragZoneId);
      if(this.dragZone == null) { throw new Exception(0, 'Object \'' + dragZoneId + '\' does not exists.'); }
   }
   else{ this.dragZone = this.handle; }
   
   InstanciateSupervisor();
   supervisor.RegisterGarbage(this, this.dragZone.id);
   supervisor.RegisterGarbage(this, this.handle.id);
   
   this.dragZone.onmousemove =  function(e) { supervisor.FireEvent(this.id, 'Floater_OnDragZoneMouseMove', e); };
   this.dragZone.onmousedown = function(e) { supervisor.FireEvent(this.id, 'Floater_OnDragZoneMouseDown', e); };
   this.handle.onmousemove = function(e) { supervisor.FireEvent(this.id, 'Floater_OnHandleMouseMove', e); };
   this.handle.onmousedown = function(e) { supervisor.FireEvent(this.id, 'Floater_OnHandleMouseDown', e); };
   
   this.position = new Point(0, 0);
   this.clip = new Point(0, 0);
   this.minSize = new Point(0, 0);
   this.intervalId = {};
   this.customs = {};
   if(!attached)
   { 
      this.css.position = 'absolute';
      this.MoveX(0);
      this.MoveY(0);
      this.customs['Floater_attached'] = false;
   }
   else
   {
      this.isDragEnabled = false;
      this.position = offsetPosition(this.handle);
      this.customs['Floater_attached'] = true;
   }
}

Floater.prototype.CreateShadow = function()
{
   if(!this.customs['Floater_shadow'])
   {
      if(this.useGreyShadow)
      {
         try
         {
            var owner = new XmlDom2(this.handle.parentNode);
            var dom = owner.CreateElement('div');
            dom.SetAttribute('style', 'background-color: #FFFFFF; border: 1px solid #999999; width: ' 
            + (this.handle.offsetWidth - 2) + 'px; height: ' + (this.handle.offsetHeight - 2) + 'px;');
            dom.SetAttribute('id', 'shadow_' + this.id);
            owner.AppendChild(dom);
            this.customs['Floater_shadow'] = new Floater('shadow_' + this.id, null, 'FloaterShadow');
            this.customs['Floater_shadow'].css.cursor = this.css.cursor;
         }
         catch(e) { alert(e.message); }
      }
      else 
      {
         var shadow = this.handle.cloneNode(true);
         shadow.setAttribute('id', 'shadow_' + this.id);
         this.handle.parentNode.appendChild(shadow);
         this.customs['Floater_shadow'] = new Floater(shadow.id, null, 'FloaterShadow');
      }
      this.customs['Floater_shadow'].allowResize = this.allowResize;
      this.customs['Floater_shadow'].MoveX(this.position.x);
      this.customs['Floater_shadow'].MoveY(this.position.y);
      this.customs['Floater_shadow'].limitT = this.limitT;
      this.customs['Floater_shadow'].limitB = this.limitB;
      this.customs['Floater_shadow'].Fade(Math.ceil(this.fade/2));
      this.customs['Floater_shadow'].minSize = this.minSize;
      this.customs['Floater_shadow'].customs['Floater_shadowOwner'] = this;
      this.customs['Floater_shadow'].Focus(true);
   }
   return this.customs['Floater_shadow'];
}

Floater.prototype.DeleteShadow = function()
{
   if(this.customs['Floater_shadow'])
   {
      this.customs['Floater_shadow'].Delete();
      this.customs['Floater_shadow'] = null;
   }
}

Floater.prototype.RefreshFollowPoint = function()
{
   this.customs['Floater_FollowPoint'] = 
   new Point(this.position.x - document.documentElement.scrollLeft, this.position.y - document.documentElement.scrollTop);
}

// *********************************************************************
// *                   EVENTS					       *
// *********************************************************************

Floater.prototype.LoadEvent = function(name, object)
{
  try
  {
     name = (this.group && !internalEvents[name]) ? name + '_' + this.group : name;
     eval(name + '(this' + ((object == null) ? ')' : ', object)'));
  }
  catch(e) { }
}

// *********************************************************************
// *                   INTERNAL EVENTS				       *
// *********************************************************************

function Floater_OnHideByFade(sender)
{
   sender.Fade(--sender.fade);
   if(sender.fade == 0)
   {
      sender.css.display = 'none';
      clearInterval(sender.intervalId['HideByFade']);
      sender.intervalId['HideByFade'] = null;
      sender.LoadEvent('Floater_OnHideByFadeEnd', null);
   }
}

function Floater_OnShowByFade(sender, maxFadeValue)
{
   sender.Fade(++sender.fade);
   if(sender.fade == maxFadeValue)
   {
      clearInterval(sender.intervalId['ShowByFade']);
      sender.intervalId['ShowByFade'] = null;
      sender.LoadEvent('Floater_OnShowByFadeEnd', null);
   }
}

function Floater_OnSlide(sender, objects)
{
   var destination = objects[0];
   var SLIDE_STEP = (objects[1]) ? objects[1] : 2;
   
   if(!sender.isDetached)
   {
      if(sender.position.x != destination.x || sender.position.y != destination.y)
      {       
         var xStep = (destination.x > sender.position.x) 
            ? (sender.position.x + SLIDE_STEP > destination.x) ? destination.x : sender.position.x + SLIDE_STEP
            : (sender.position.x - SLIDE_STEP < destination.x) ? destination.x : sender.position.x - SLIDE_STEP;
        
         var yStep = (destination.y > sender.position.y) 
            ? (sender.position.y + SLIDE_STEP > destination.y) ? destination.y : sender.position.y + SLIDE_STEP
            : (sender.position.y - SLIDE_STEP < destination.y) ? destination.y : sender.position.y - SLIDE_STEP;
         
         sender.MoveX(xStep);
         sender.MoveY(yStep);
      }
      else
      {
         clearInterval(sender.intervalId['Slide']);
         sender.intervalId['Slide'] = null;
         sender.LoadEvent('Floater_OnSlideEnd', null);
      }
   }
}

function Floater_OnFollowScreen(sender, objects)
{
   if(!sender.isDetached)
   {      
      var SLIDE_STEP = (objects[1]) ? objects[1] : 2;
      var destination = new Point(sender.customs['Floater_FollowPoint'].x + document.documentElement.scrollLeft,
   	   sender.customs['Floater_FollowPoint'].y + document.documentElement.scrollTop);
   
      if(sender.position.x != destination.x || sender.position.y != destination.y)
      {       
         var xStep = (destination.x > sender.position.x) 
            ? (sender.position.x + SLIDE_STEP > destination.x) ? destination.x : sender.position.x + SLIDE_STEP
            : (sender.position.x - SLIDE_STEP < destination.x) ? destination.x : sender.position.x - SLIDE_STEP;
           
         var yStep = (destination.y > sender.position.y) 
            ? (sender.position.y + SLIDE_STEP > destination.y) ? destination.y : sender.position.y + SLIDE_STEP
            : (sender.position.y - SLIDE_STEP < destination.y) ? destination.y : sender.position.y - SLIDE_STEP;
            
         if(destination.x < supervisor.wWidth) { sender.MoveX(xStep); }
         if(destination.y < supervisor.wHeight) { sender.MoveY(yStep); }
      }
      else
      {
         clearInterval(sender.intervalId['ScrollSlide']);
         sender.intervalId['ScrollSlide'] = null;
      }
   }
   else
   {
      clearInterval(sender.intervalId['ScrollSlide']);
      sender.intervalId['ScrollSlide'] = null;
   }
}

function Floater_OnDragZoneMouseMove(sender, e)
{
   sender.DragZoneMouseMove(e);
}

function Floater_OnDragZoneMouseDown(sender, e)
{
   sender.DragZoneMouseDown(e);
}

function Floater_OnHandleMouseMove(sender, e)
{
   sender.HandleMouseMove(e);
}

function Floater_OnHandleMouseDown(sender, e)
{
   sender.HandleMouseDown(e);
}

// *********************************************************************
// *                   SHADOW EVENTS				       *
// *********************************************************************
   
function Floater_OnMoveEnd_FloaterShadow(sender, e)
{
   sender.customs['Floater_shadowOwner'].Focus(true);
   sender.customs['Floater_shadowOwner'].LoadEvent('Floater_OnShadowMoveEnd', sender.position);
   sender.customs['Floater_shadowOwner'].DeleteShadow();
}

function Floater_OnAfterDelete_FloaterShadow(sender)
{
   sender = null;
}

function Floater_OnResizeEnd_FloaterShadow(sender, e)
{
   sender.customs['Floater_shadowOwner'].Focus(true);
   sender.customs['Floater_shadowOwner'].LoadEvent('Floater_OnShadowResizeEnd', new Array(sender.css.width, sender.css.height));
   sender.customs['Floater_shadowOwner'].DeleteShadow();
}

// *********************************************************************
// *                   SUPERVISOR EVENTS			       *
// *********************************************************************

function Supervisor_OnMouseMove(sender, e)
{     
   var attachedObject = sender.customs['Supervisor_attachedObject'];
   if(attachedObject != null)
   {
      if(attachedObject.IsInResizeMode() && supervisor.mouse.rightButtonPushed)
      {
         var endX = attachedObject.position.x + attachedObject.handle.offsetWidth;
         var endY = attachedObject.position.y + attachedObject.handle.offsetHeight;
         var wStep = (sender.mouse.x - endX) + attachedObject.handle.offsetWidth;
         var hStep = (sender.mouse.y - endY) + attachedObject.handle.offsetHeight;
   	 switch(attachedObject.css.cursor)
         {
            case 'se-resize': attachedObject.css.width = ((wStep < attachedObject.minSize.x) ? attachedObject.minWidth : wStep) + 'px';
           		      attachedObject.css.height = ((hStep < attachedObject.minSize.y) ? attachedObject.minHeight : hStep) + 'px';
               	     	      break;
               	     
            case 'e-resize':  attachedObject.css.width = ((wStep < attachedObject.minSize.x) ? attachedObject.minWidth : wStep) + 'px';
              		      break;
               
            case 's-resize':  attachedObject.css.height = ((hStep < attachedObject.minSize.y) ? attachedObject.minHeight : hStep) + 'px';
               		      break;
         }
      }
      else
      {
         if(attachedObject.isDetached)
         {
            attachedObject.MoveX(sender.mouse.x - attachedObject.clip.x);
            attachedObject.MoveY(sender.mouse.y - attachedObject.clip.y);
            attachedObject.LoadEvent('Floater_OnMove', null);
         }
      }
   }
}

function Supervisor_ScrollMove(sender, e)
{
   var attachedObject = sender.customs['Supervisor_attachedObject'];
   if(attachedObject != null)
   {
      if(attachedObject.IsInResizeMode())
      {
         var endX = attachedObject.position.x + attachedObject.handle.offsetWidth;
         var endY = attachedObject.position.y + attachedObject.handle.offsetHeight;
         var wStep = (sender.mouse.x - endX) + attachedObject.handle.offsetWidth;
         var hStep = (sender.mouse.y - endY) + attachedObject.handle.offsetHeight;
   	 switch(attachedObject.css.cursor)
         {
            case 'se-resize': attachedObject.css.width = ((wStep < attachedObject.minSize.x) ? attachedObject.minWidth : wStep) + 'px';
           		      attachedObject.css.height = ((hStep < attachedObject.minSize.y) ? attachedObject.minHeight : hStep) + 'px';
               	     	      break;
               	     
            case 'e-resize':  attachedObject.css.width = ((wStep < attachedObject.minSize.x) ? attachedObject.minWidth : wStep) + 'px';
              		      break;
               
            case 's-resize':  attachedObject.css.height = ((hStep < attachedObject.minSize.y) ? attachedObject.minHeight : hStep) + 'px';
               		      break;
         }
      }
      else
      {
         if(attachedObject.isDetached)
         {
            attachedObject.MoveX(sender.mouse.x - attachedObject.clip.x);
            attachedObject.MoveY(sender.mouse.y - attachedObject.clip.y);
            attachedObject.LoadEvent('Floater_OnMove', null);
         }
      }
   }
   eval('Window_OnScroll()');
}

function Supervisor_OnMouseUp(sender, e)
{
   if(sender.customs['Supervisor_attachedObject'] != null)
   {
      sender.customs['Supervisor_attachedObject'].DragZoneMouseUp(e);
      sender.customs['Supervisor_attachedObject'].HandleMouseUp(e);
      sender.customs['Supervisor_attachedObject'].Attach();
      sender.customs['Supervisor_attachedObject'].css.cursor = '';
   }
}

function Supervisor_OnResize(sender)
{ eval('Floater_OnPageSizeChanged(sender)'); }