Drag and Replace DIV in javascript
<p>I want to do DRAG and REPLACE div in javascript. For Ex: I am having 2 Div's. If i drag the 2nd Div and place it on the 1st Div, automatically the 1st div should be replaced to the 2nd position. The code which i am having now is overlapping..</p>

<p>my aspx page..</p>

<pre><code>&lt;body&gt;
&lt;div id="container"&gt;
    &lt;div id="info"&gt;
        Start drag process...&lt;/div&gt;
    &lt;div id="square" style="position: relative; width: 60px; height: 60px; background: #990033;
        border: 2px solid #3399CC;"&gt;
    &lt;/div&gt;
      &lt;div id="Div1" style="position: relative; width: 60px; height: 60px; background: #efe;
        border: 2px solid #3399CC;"&gt;
    &lt;/div&gt;
    &lt;script type="text/javascript"&gt;

        var square = DragHandler.attach(document.getElementById('square'));

        var Div1 = DragHandler.attach(document.getElementById('Div1'));


    &lt;/script&gt;
&lt;/div&gt;
</code></pre>

<p></p>

<p>my js file...</p>

<pre><code>/**
</code></pre>

<p>*
*  Crossbrowser Drag Handler
*  <a href="http://www.webtoolkit.info/" rel="nofollow">http://www.webtoolkit.info/</a>
*
**/</p>

<p>var DragHandler = {</p>

<pre><code>// private property.
_oElem : null,


// public method. Attach drag handler to an element.
attach : function(oElem) {
    oElem.onmousedown = DragHandler._dragBegin;

    // callbacks
    oElem.dragBegin = new Function();
    oElem.drag = new Function();
    oElem.dragEnd = new Function();

    return oElem;
},


// private method. Begin drag process.
_dragBegin : function(e) {
    var oElem = DragHandler._oElem = this;

    if (isNaN(parseInt(oElem.style.left))) { oElem.style.left = '0px'; }
    if (isNaN(parseInt(oElem.style.top))) { oElem.style.top = '0px'; }

    var x = parseInt(oElem.style.left);
    var y = parseInt(oElem.style.top);

    e = e ? e : window.event;
    oElem.mouseX = e.clientX;
    oElem.mouseY = e.clientY;

    oElem.dragBegin(oElem, x, y);

    document.onmousemove = DragHandler._drag;
    document.onmouseup = DragHandler._dragEnd;
    return false;
},


// private method. Drag (move) element.
_drag : function(e) {
    var oElem = DragHandler._oElem;

    var x = parseInt(oElem.style.left);
    var y = parseInt(oElem.style.top);

    e = e ? e : window.event;
    oElem.style.left = x + (e.clientX - oElem.mouseX) + 'px';
    oElem.style.top = y + (e.clientY - oElem.mouseY) + 'px';

    oElem.mouseX = e.clientX;
    oElem.mouseY = e.clientY;

    oElem.drag(oElem, x, y);

    return false;
},


// private method. Stop drag process.
_dragEnd : function() {
    var oElem = DragHandler._oElem;

    var x = parseInt(oElem.style.left);
    var y = parseInt(oElem.style.top);

    oElem.dragEnd(oElem, x, y);

    document.onmousemove = null;
    document.onmouseup = null;
    DragHandler._oElem = null;
}
</code></pre>

<p>}</p>

<p>How to do this...</p>
