(function($){

 $.fn.popMeUp = function(options) {
    return this.each(function()
    {
        var settings = jQuery.extend({
            fullScreen:false
          }, options);

        if (settings.fullScreen)
        {
            // Full-screen mode
            var w = $(window).width()-16;
            var h = $(window).height()-16;            
            $(this).css("width",w);
            $(this).css("height",h);
        }

        $(this).css("z-index","15");
        $(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");

        if ($("#popupoverlay").length==0)
        {            
            var h = "<div id=\"popupoverlay\" style=\"display:none;position:absolute;left:0;top:0;width:100%;background-color:#000000;z-index:3;opacity:0.2;filter:alpha(opacity=20);\"></div>"
            $(this).after(h);
            $(window).resize(function()
            {
                $("#popupoverlay").height( $(document).height() );
            });
        }        
        $("#popupoverlay").height( $(document).height() );
        $(this).fadeIn("slow");
        $("#popupoverlay").fadeIn("slow");
    })};

$.fn.popMeDown = function(options) {
    return this.each(function()
    {
        $(this).hide();
        $("#popupoverlay").hide();
    })};

})(jQuery);
