// Copyright 2006 Peter Michaux
//
// This file is released under the BSD license
//
// more info about using this file
// http://peter.michaux.ca/articles/2006/06/02/yui-better-dragdrop-constructors



YAHOO.util.DragDrop.prototype.init = function(element, sGroup) {
  this.initTarget(element, sGroup);
  // The listener should really be added in the DD constructor
  // but for backwards compatibility it must stay here.
  // Someone might be directly instantiating this class
  // or subclassing it directly.
  this.initDraggable();
};

YAHOO.util.DragDrop.prototype.initDraggable = function(){
  YAHOO.util.Event.addListener(this.id, "mousedown", 
                               this.handleMouseDown, this, true);
};



// a little helper object to fix the DD, DDProxy and DDTarget constructors
var fixer = {};
fixer.remember = function(original){
  fixer.holder = original;
};
fixer.repair = function(original){
  for (p in fixer.holder){
    original[p] = fixer.holder[p];
  }
};



// Store the original DD because redefining the constructor
// will delete all of the properties defined in dragdrop.js
fixer.remember(YAHOO.util.DD);
// Redefine the constructor
YAHOO.util.DD = function(id, sGroup) {
  YAHOO.util.DD.superclass.call(this, id, sGroup);
};
// DD will extend DragDrop
extend(YAHOO.util.DD, YAHOO.util.DragDrop);
// Repair the DD properties defined in dragdrop.js
fixer.repair(YAHOO.util.DD);



fixer.remember(YAHOO.util.DDProxy);
YAHOO.util.DDProxy = function(id, sGroup) {
  YAHOO.util.DD.superclass.call(this, id, sGroup);
  this.forceCssPosition = false;
  this.initFrame();
};
extend(YAHOO.util.DDProxy, YAHOO.util.DragDrop);
fixer.repair(YAHOO.util.DDProxy);



// For version 0.10 the remember and repair lines 
// are not needed below but maybe in the future.
fixer.remember(YAHOO.util.DDTarget);
YAHOO.util.DDTarget = function(id, sGroup) {
  YAHOO.util.DDTarget.superclass.call(this, id, sGroup);
};
extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop);
fixer.repair(YAHOO.util.DDTarget);
// Next line is needed for the backwards compatibility issue mentioned above.
YAHOO.util.DDTarget.prototype.initDraggable = function(){};
