<script type='text/javascript'>
(function() {
    var aheader, dbg;

    function isWindow(obj) {
        return obj && obj.self && obj.self === obj;
    }

    // Try to find the header frame in backend
    if (isWindow(parent.parent.header)) {
        aheader = parent.parent.header;
    } else if (isWindow(parent.parent.parent.header)) {
        aheader = parent.parent.parent.header;
    } else {
        // We might not be the backend return here.
        return;
    }

    // Add the buttons for text select
    dbg = aheader.document.getElementById('debug_msg');
    dbg.innerHTML += "<pre>{DBG_MESSAGE_CONTENT}</pre><input type='button' onclick='selectText()' value='Select all'>";
    dbg.scrollTop = dbg.scrollHeight;
})();
</script>
