(function($) {
    $.fn.saveScreen = function(screen) {
        $.ajax({
           type: "POST",
           url: "index.php",
           data: "lightbox=1&screen="+screen
        });
    };

    $.fn.overlay = function() {
        _buildOverlay(); // If the overlay is not there, inject it!

        // Window/Keyboard events
        $(window).scroll(function(){
            scrollPos = _getScroll();
            _resizeOverlay();
        });
        $(window).resize(function(){
            _resizeOverlay();
        });

        function _getScroll(){
            if (self.pageYOffset) {
                return {
                    scrollTop:self.pageYOffset,
                    scrollLeft:self.pageXOffset
                    };
            } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict
                return {
                    scrollTop:document.documentElement.scrollTop,
                    scrollLeft:document.documentElement.scrollLeft
                    };
            } else if (document.body) {// all other Explorers
                return {
                    scrollTop:document.body.scrollTop,
                    scrollLeft:document.body.scrollLeft
                    };
            };
        };

        function _resizeOverlay() {
            windowHeight = $(window).height();
            windowWidth = $(window).width();

            $('div.lb_overlay').css({
                'height':$(document).height()
            });
        };

        function _buildOverlay(){
            // Set my global selectors
            $('div.lb_overlay').css({
                'opacity':0.8,
                'height':$(document).height()
            });
        };
    };
})(jQuery);
