﻿$.fn.makeAbsolute = function (rebase) {
    
    // first collect all positions
    this.each(function () {
        $(this).data('pos', $(this).position());
    });

    // then make absolute
    return this.each(function () {
        var el = $(this);
        var pos = el.data('pos');
        el.css({ position: "absolute",
            marginLeft: 0, marginTop: 0,
            top: pos.top, left: pos.left
        });
        if (rebase)
            el.remove().appendTo("body");
    });
}
