+ $.fn.positionOn = function(element, align) {
+ return this.each(function() {
+ var target = $(this);
+ var position = element.offset();
+
+ var x = position.left;
+ var y = position.top;
+
+ if(align == 'right') {
+ x -= (target.outerWidth() - element.outerWidth());
+ } else if(align == 'center') {
+ x -= target.outerWidth() / 2 - element.outerWidth() / 2;
+ }
+
+ target.css({
+ position: 'absolute',
+ zIndex: 5000,
+ top: y,
+ left: x
+ });
+ });
+ };
+