/*
*  Plugin for cross-browser mouse selection reset 
*
*  Distributed under the terms of the GNU Library General Public License
*
*  @package ddi (Drag'n'Drop Interface)
*  @version 1.4
*  @title Reset mouse selection plugin
*  @author Ilya Lebedev (ilya@lebedev.net), (c) 2005
*
*  Revision history:
*  v1.4
*  % execution moved to drag.after
*  + dragend.after method
*  + plugin group DDI_CORE
*  + shutdown method
*
*  v1.3
*  % execution phase moved to 'after' DragStart, now it's possible to disable this behaviour from event handler
*
*  v1.2
*  + first public release
*/
__DDI__.plugin.fixNoMouseSelect = new function () {
  this.name = 'No mouse select';
  this.description = 'Plugin is used to disable mouse selection during drag';
  this.group = 'DDI_CORE';
  var el = false;
  var reset = false;
  this.init = function () {
    if (!el) {
      el = document.createElementExt('INPUT', null, null,
                                     [['width',0],
                                      ['height',0],
                                      ['border',0],
                                      ['padding',0],
                                      ['margin',0],
                                      ['background','transparent'],
                                      ['font-size','0']
                                     ], null, 
                                     [['disabled','disabled'],['id','mouse_select_input_fixx']]);

      var body = document.getElementsByTagName('body')[0];
      body.appendChild(el);
    }
  }
  this.drag = {
    'after' : function (e) {
      if (!reset) {
        try {el.focus();} catch(e) {el.disabled=false; el.focus(); el.disabled=true}
        reset = true;
      }
    }
  }
  this.dragend = {
    'after' : function (e) {
      reset = false;
    }
  }
  this.shutdown = function () {
    if (el != null) {
      el.removeNode();
      el = null;
    }
  }
}
