//  DragDropExtra Scriptaculous Enhancement, version 0.2
//  (c) 2007-2008 Christopher Williams, Iterative Designs
//
// v0.3 release
//	  - Fixed bug found by Phillip Sauerbeck psauerbeck@gmail. Tests added based on Phillip's efforts.
// v0.2 release
//		- Minor bug fix for the releasing of objects after they have been dropped, prevents memory leak.
// v0.1 release
//		- initial release for the super ghosting capability
//		- Drags from one scrolling list to the other (overflow:auto)
//		- Retains the original object so that it can remain present despite being dragged
// 
// dragdropextra.js is freely distributable under the terms of an MIT-style license.
// For details, see the Iterative Designs web site: http://www.iterativedesigns.com/
// Parts of this code have been taken from the original dragdrop.js library which is 
// copyrighted by (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, 
// http://mir.aculo.us) and (c) 2005-2007 Sammi Williams 
// (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) and available under 
// a MIT-style license.

Droppables.isAffected = function(point, element, drop) {
	Position.prepare();
	positioned_within = Position.withinIncludingScrolloffsets(drop.element, point[0], point[1])
	return (
      (drop.element!=element) &&
      ((!drop._containers) ||
        this.isContained(element, drop)) &&
      ((!drop.accept) ||
        (Element.classNames(element).detect( 
          function(v) { return drop.accept.include(v) } ) )) && positioned_within );


}

/*    
Draggable.prototype.finishDrag =  function(event, success) {
  this.dragging = false;
  if(this.options.quiet){
    Position.prepare();
    var pointer = [Event.pointerX(event), Event.pointerY(event)];
    Droppables.show(pointer, this.element);
  }

  if(this.options.ghosting) {
      if (!this.element._originallyAbsolute)
        Position.relativize(this.element);
      delete this.element._originallyAbsolute;
      Element.remove(this._clone);
      this._clone = null;
  }

	

  if(this.options.superghosting) {
      
      console.log('bah1');
	  new Draggable(this._clone, this.options);
	}

  var dropped = false; 
  if(success) {
    console.log('drop'); 
    dropped = Droppables.fire(event, this.element); 
    if (!dropped) dropped = false; 
  }
  if(dropped && this.options.onDropped) this.options.onDropped(this.element);
  console.log('onEnd');
  Draggables.notify('onEnd', this, event);
  console.log('revert');
  var revert = this.options.revert;
  if(revert && Object.isFunction(revert)) revert = revert(this.element);
  
  var d = this.currentDelta();
  if(revert && this.options.reverteffect) {
    if (dropped == 0 || revert != 'failure')
      this.options.reverteffect(this.element,
        d[1]-this.delta[1], d[0]-this.delta[0]);
  } else {
    this.delta = d;
  }

  if(this.options.zindex)
    this.element.style.zIndex = this.originalZ;

  if(this.options.endeffect) 
    this.options.endeffect(this.element);


  Draggables.deactivate(this);
  if(this.options.superghosting) {  
       console.log('bah2');    
      body = document.getElementsByTagName("body")[0];
      this._clone.hide();
      Element.remove(this._clone);
  }
  Droppables.reset();
}
*/