$(function () {
    $("#item-delete-button").bind("click", function () {
        if ( confirm("本当に削除しますか?") ) {
           Deferred.next(function () {
              Lightbox.show();
           }).wait(0).next(function () {
              $.post("/internal_api/item/delete", {
                  item_id : $("#item_id").val()
              }, function (json) {
                 eval("var res = " + json);
                 if ( res.status == 'success' ) {
                    setTimeout(function () {
                       location.href = $("#archive").attr("href")
                    }, 1000);
                 } else {

                 }
              });
           });
        }
    });
    // space to &nbsp;
    var b = $("#memo-body").html();
    $("#memo-body").html( b.replace(/  /g, "&nbsp;&nbsp;") );
    // bind-keys
    $.hotkeys.add("e", function () { location.href = $("#edit a").attr("href"); });
    $.hotkeys.add("d", function () { $("#item-delete-button").click() });
});

