 drawGuidewires(mousedown.x, mousedown.y);
            }
        }
    };

    canvas.onmouseup = function (e) {
        var loc = windowToCanvas(e);

        dragging = false;

        if (!editing) {
            restoreDrawingSurface();
            updateRubberband(loc);
        }
    };

    eraseAllButton.onclick = function (e) {
        context.clearRect(0, 0, canvas.width, canvas.height);
        drawGrid('lightgray', 10, 10);
        saveDrawingSurface();
    };

    strokeStyleSelect.onchange = func