How to implement touch events for iOS with plain javascript?
<p>I have a plain javascript which is used to drag and move the DIV tags in HTML page
this works fine with the mouse move, mouse up and mouse down events
Now i want to extend this and make it work for touch devices(iPhones)
Can someone help me to do that</p>

<pre><code> if (document.getElementById) {

        (function () {

            var n = 500;
            var dragok = false;
            var y, x, d, dy, dx;

            function move(e) {
                if (!e) e = window.event;
                if (dragok) {
                    d.style.left = dx + e.clientX - x + "px";
                    d.style.top = dy + e.clientY - y + "px";
                    return false;
                }
            }

            function down(e) {
                if (!e) e = window.event;
                var temp = (typeof e.target != "undefined") ? e.target : e.srcElement;
                if (temp.tagName != "HTML" | "BODY" &amp;&amp; temp.className != "dragclass") {
                    temp = (typeof temp.parentNode != "undefined") ? temp.parentNode : temp.parentElement;
                }
                if (temp.className == "dragclass") {
                    dragok = true;
                    temp.style.zIndex = n++;
                    d = temp;
                    dx = parseInt(temp.style.left + 0);
                    dy = parseInt(temp.style.top + 0);
                    x = e.clientX;
                    y = e.clientY;
                    document.onmousemove = move;
                    return false;
                }
            }

            function up() {
                dragok = false;
                document.onmousemove = null;
            }

            document.onmousedown = down;
            document.onmouseup = up;

            document.body.addEventListener("touchstart", down, true);
            document.body.addEventListener("touchcancel", up, true);
            document.body.addEventListener("touchmove", move, true);


        })();
</code></pre>
