$(document).ready(function() {
    var match_ticket = /\/ticket\/(\d+)/.exec(document.location);
    if (match_ticket == undefined) {
        return;
    }
    var ticket = match_ticket[1];
    var delete_link = '<a href="../admin/ticket/delete/'+ticket+'"title="チケットを削除">削除</a>';
    var ticket_buttons = $('#ticket .inlinebuttons')[0];
    if (ticket_buttons) {
        $(ticket_buttons).append(delete_link);
    } else {
        $('#ticket table.properties').after('<div class="description"><h3><span class="inlinebuttons">'+delete_link+'</span>&nbsp;</h3></div>');
    }
    $('#changelog .printableform').each(function() {
        var comment = $('.inlinebuttons input[@name=replyto]', this)[0];
        if (comment) {

            $('.inlinebuttons', this).append('<a href="../admin/ticket/comments/'+ticket+'?cnum='+comment.value+'" title="コメント '+comment.value+' を削除">削除</a>');
        }
    });
});
