﻿$(document).ajaxStart(function() {
    $.blockUI({
        css: { width: '200px', left: '40%' },
        message: '<div class="header">Loading, please wait...</div><div class="body"><img src="../images/ajax-loader.gif" /></div>'
    });
}).ajaxStop(function() {
    $.unblockUI();
});

function showMessage(message, redirectUrl) {
    $content = $('<div class="dialog"></div>');
    $content.append(message).dialog({
        modal: true,

        buttons: {
            Ok: function() {
                $(this).dialog('close');
                if (redirectUrl != null) {
                    window.location.href = redirectUrl;
                }
            }
        }
    });
}

function escapeHtml(element) {
    return element.replace(/&/g, '&amp;')
                .replace(/"/g, '&quot;')
                .replace(/</g, '&lt;')
                .replace(/>/g, '&gt;');
}

function encodeHtml(element) {
    return element.replace(/&quot;/g, '"')
                .replace(/&lt;/g, '<')
                .replace(/&gt;/g, '>')
                .replace(/&amp;/g, '&');
}
