static function redefineConfirm()
{
echo self::scriptBlock("\n var confirmed = false;\n var lastClickedElement;\n\n // store last clicked element on dom\n \$(document).click(function(event) {\n lastClickedElement = \$(event.target);\n });\n\n // asynchronous confirm dialog with jquery ui\n var newConfirm = function(message, caption) {\n message = message.replace('\\n', '<br>');\n caption = caption || '';\n\n \$('<div>').html(message).dialog({\n title: caption,\n dialogClass: 'fixed',\n buttons: {\n '" . _sx('button', 'Confirm') . "': function () {\n \$(this).dialog('close');\n confirmed = true;\n\n //trigger click on the same element (to return true value)\n lastClickedElement.click();\n\n // re-init confirmed (to permit usage of 'confirm' function again in the page)\n // maybe timeout is not essential ...\n setTimeout(function(){ confirmed = false; }, 100);\n },\n '" . _sx('button', 'Cancel') . "': function () {\n \$(this).dialog('close');\n confirmed = false;\n }\n },\n close: function () {\n \$(this).remove();\n },\n draggable: true,\n modal: true,\n resizable: false,\n width: 'auto'\n });\n };\n\n window.nativeConfirm = window.confirm;\n\n // redefine native 'confirm' function\n window.confirm = function (message, caption) {\n // if watched var isn't true, we can display dialog\n if(!confirmed) {\n // call asynchronous dialog\n newConfirm(message, caption);\n }\n\n // return early\n return confirmed;\n };");
}