﻿/* Global JS file for ScotGovMailer project */

(function($) {
    $.extend($.validator, {
        messages: {
            required: "Required"
        }
    });

    $.fn.center = function() {
        this.css("position", "absolute");
        this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
        this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
        return this;
    }

    $.fn.showModal = function(message) {
        $('<div />').addClass('lightbox_bg').appendTo('body').show();
        var modal = $('<div />').html('<div class="message notice"><span class="icon"></span><p>' + message + '</p></div>').addClass('interstitialModal').appendTo('body').center();
        return modal;
    }
})(jQuery);

function removeEditorControls(domElement) {
    $(':contains("UserMessage"):last', domElement).show()
    $("body .editor-action, body :not(:visible), link, style, script, body .action-container", domElement).remove();
    $(".editable", domElement).removeClass("editable");
}

