///////  Note this replaces the dragdrop.sj code pp 379-380  ///////

// file dragdrop.sj
var ball, ballstyle, cursor_x0, cursor_y0, left0, top0, old;

function init()
{   ball = document.getElementById('ball');
    ballstyle = ball.style;
    old = ballstyle.cursor;
}

function drag(e)
{   if ( document.onmousemove ) 
    {    document.onmousemove = null;         // (2)
         ballstyle.cursor = old;
    }
    else 
    {   cursor_x0 = e.clientX;
        cursor_y0 = e.clientY;
        left0 = ball.offsetLeft; 
        top0 = ball.offsetTop;
        document.onmousemove = trackMouse;   // (3)
        ballstyle.cursor = "move";
    }
}

function trackMouse(e)                       // (4)
{   if (window.event) e=window.event;// IE
    var x = e.clientX - cursor_x0;           // (5)
    var y = e.clientY - cursor_y0;           // (6)
    ballstyle.left = (left0 + x) + "px";
    ballstyle.top = (top0 + y) + "px";
}

