
jQuery.fn.monkiiModal = function(options) {

    var options = jQuery.extend({
        mask_background: '#000',
        mask_opacity: '0.8'
    }, options);

    return this.each(function() {

        var docHeight = jQuery(document).height();
        var winHeight = jQuery(window).height();
        var winWidth = jQuery(window).width();

        var el_mask = jQuery('<div></div>');
        var el_window = jQuery(this).clone();

        el_mask
            .css({
                'position': 'absolute',
                'top': '0px',
                'left': '0px',
                'opacity': options.mask_opacity,
                'z-index': '9998',
                'background-color': options.mask_background,
                'width': winWidth,
                'height': docHeight
            });

        el_window
            .css({
                'position': 'absolute',
                'z-index': '9999',
                'top': (winHeight / 2) - (jQuery(this).height() / 2),
                'left': (winWidth / 2) - (jQuery(this).width() / 2)
            })
            .show();

        jQuery('body')
            .append(el_mask)
            .append(el_window);

        el_mask.click(function() {

            el_window.remove();

            el_mask.remove();

        });

        el_window.find('.closeBox').click(function() {

            el_window.remove();

            el_mask.remove();

            return false;

        });

    });

}

