     rect.startX = e.pageX - this.offsetLeft;
            rect.startY = e.pageY - this.offsetTop;
            drag = true;
        }

        function mouseUp() {
            drag = false;
            document.getElementById('output').innerHTML = rect.startY + "," + (rect.startY + rect.h) + "," + rect.startX + "," + (rect.startX + rect.w);
        }

        function mouseMove(e) {
            if (drag) {
                rect.w = (e.pageX - this.offsetLeft) - rect.startX;
                rect.h = (e.pageY -