jQuery.fn.showWaitWindow = function(options)
{
        var options = jQuery.extend({Class:'alx_waitwindowlocalshadow',MinHeight:0,MinWidth:0},options);
        return this.each(function()
        {
                var w = jQuery(this).width();
                var h = jQuery(this).height();

                function GetWindowSize()
                {
                        var innerWidth, innerHeight;

                        if (self.innerHeight) // all except Explorer
                        {
                                innerWidth = self.innerWidth;
                                innerHeight = self.innerHeight;
                        }
                        else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
                        {
                                innerWidth = document.documentElement.clientWidth;
                                innerHeight = document.documentElement.clientHeight;
                        }
                        else if (document.body) // other Explorers
                        {
                                innerWidth = document.body.clientWidth;
                                innerHeight = document.body.clientHeight;
                        }

                        var scrollLeft, scrollTop;
                        if (self.pageYOffset) // all except Explorer
                        {
                                scrollLeft = self.pageXOffset;
                                scrollTop = self.pageYOffset;
                        }
                        else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
                        {
                                scrollLeft = document.documentElement.scrollLeft;
                                scrollTop = document.documentElement.scrollTop;
                        }
                        else if (document.body) // all other Explorers
                        {
                                scrollLeft = document.body.scrollLeft;
                                scrollTop = document.body.scrollTop;
                        }

                        var scrollWidth, scrollHeight;

                        if ( (document.compatMode && document.compatMode == "CSS1Compat"))
                        {
                                scrollWidth = document.documentElement.scrollWidth;
                                scrollHeight = document.documentElement.scrollHeight;
                        }
                        else
                        {
                                if (document.body.scrollHeight > document.body.offsetHeight)
                                        scrollHeight = document.body.scrollHeight;
                                else
                                        scrollHeight = document.body.offsetHeight;

                                if (document.body.scrollWidth > document.body.offsetWidth ||
                                        (document.compatMode && document.compatMode == "BackCompat") ||
                                        (document.documentElement && !document.documentElement.clientWidth)
                                )
                                        scrollWidth = document.body.scrollWidth;
                                else
                                        scrollWidth = document.body.offsetWidth;
                        }

                        return  {"innerWidth" : innerWidth, "innerHeight" : innerHeight, "scrollLeft" : scrollLeft, "scrollTop" : scrollTop, "scrollWidth" : scrollWidth, "scrollHeight" : scrollHeight};
                };

                function GetRealPos(el)
                {

                        if (el.getBoundingClientRect)
                        {
                                var obRect = el.getBoundingClientRect();
                                var obWndSize = GetWindowSize();
                                var arPos = {
                                        left: obRect.left + obWndSize.scrollLeft,
                                        top: obRect.top + obWndSize.scrollTop,
                                        right: obRect.right + obWndSize.scrollLeft,
                                        bottom: obRect.bottom + obWndSize.scrollTop
                                };
                                return arPos;
                        }


                        var res = Array();

                        res["left"] = el.offsetLeft;
                        res["top"] = el.offsetTop;
                        var objParent = el.offsetParent;

                        while(objParent && objParent.tagName != "BODY")
                        {
                                res["left"] += objParent.offsetLeft;
                                res["top"] += objParent.offsetTop;
                                objParent = objParent.offsetParent;
                        }
                        return res;
                };

                arPosition = GetRealPos(this);


                if(w < options.MinWidth)w = options.MinWidth;
                if(h < options.MinHeight)h = options.MinHeight;

                jQuery("body").append("<div id='ajaxLoader_"+this.id+"' style='display:none; top:"+arPosition["top"]+"px; left:"+arPosition["left"]+"px; width:"+w+"px;height:"+h+"px; position:absolute; z-index:1000;' class='"+options.Class+"'></div>");
                $("#ajaxLoader_"+this.id).css("display","block");

        });
}

jQuery.fn.closeWaitWindow = function()
{
        return this.each(function()
        {
                $('#ajaxLoader_'+this.id).remove();
        });
}
