﻿// JavaScript Document
(function($) {

    jQuery.fn.MyOverlay = function(options) {
        jQuery.MyOverlay._init(jQuery(this), options);
    }

    $.MyOverlay = {

        defaults: {
            backgroudColor: false
        },

        _init: function(selector, options) {
            this.options = $.extend({}, this.defaults, options);
            this.render();
        },

        render: function() {
            var self = this;
            var dimensions = this.browserDimensions();
            var styles = {
                'height': dimensions.height + 'px',
                'width': dimensions.width + 'px',
                'top': '0px',
                'left': '0px',
                'z-index': '20000',
                'position': 'absolute',
                'display' : 'none' 
            };

            this.element = $("<div class='frameset-ajax-overlay'></div>");
            this.element.css(styles);

            $(window).bind("resize", function(e) {
                var dimensions = self.browserDimensions();
                var styles = {
                    'height': dimensions.height + 'px',
                    'width': dimensions.width + 'px'
                };
                self.element.css(styles);
            });

            this.element.appendTo('body');

        },

        browserDimensions: function() {
            var dimensions = { width: 0, height: 0 };
            if (document.documentElement) {
                dimensions.width = document.documentElement.offsetWidth;
                dimensions.height = document.documentElement.offsetHeight;
            } else if (window.innerWidth && window.innerHeight) {
                dimensions.width = window.innerWidth;
                dimensions.height = window.innerHeight;
            }
            return dimensions;
        },

        show: function() {
            $('div.frameset-ajax-overlay').show();
        },

        hide: function() {
            $('div.frameset-ajax-overlay').hide();
        },

        emptyFunction: function(selector) {
            alert(selector.selector)
        }
    }

})(jQuery);
