(function($){
    function _returnOffset(l,t){
          var result = [l, t];
          result.left = l;
          result.top = t;
          return result;
    }

    var Extends ={
        makeClipping:function(){
            this.each(function(){               
                if(this._overflow) return;
                this._overflow = $(this).css('overflow') || 'auto';
                $(this).css('overflow','hidden');                
            });

            return this;
        },
        undoClipping:function(){
            this.each(function(){                
                if(!this._overflow) return;
                $(this).css('overflow',this._overflow);
                delete this._overflow;                
            });

            return this;
        },
        makePositioned:function(){
            this.each(function(){
                var pos = $(this).css('position');
                if(pos == 'static' || !pos){
                    this._madePositioned = true;
                    this.style.position  = 'relative';
                    if($.browser.opera){
                        this.style.top = 0;
                        this.style.left = 0;
                    }
                }
            });
            return this;
        },
        undoPositioned:function(){
            this.each(function(){
                if (this._madePositioned) {
                    delete this._madePositioned;                    
                    this.style.left =
                    this.style.top =
                    this.style.right =
                    this.style.bottom = 0

                }
            });
            return this;
        },
         cumulativeOffset: function() {
            var element = this[0];
            var valueT = 0, valueL = 0;
            do {
              valueT += element.offsetTop  || 0;
              valueL += element.offsetLeft || 0;
              element = element.offsetParent;
            } while (element);
            return _returnOffset(valueL, valueT);
          },

          positionedOffset: function() {
            var element = this[0];
            var valueT = 0, valueL = 0;
            do {
              valueT += element.offsetTop  || 0;
              valueL += element.offsetLeft || 0;
              element = element.offsetParent;
              if (element) {
                if (element.tagName.toUpperCase() == 'BODY') break;
                var p = element.style.position;
                if (p !== 'static') break;
              }
            } while (element);
            return _returnOffset(valueL, valueT);
          }

    }
    $.extend($.fn, Extends);    

})(jQuery)
