/*
 * jQuery UI Position 1.8.16
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Position
 */

(function(d){d.ui=d.ui||{};var k=/left|center|right/,l=/top|center|bottom/,n=d.fn.position,o=d.fn.offset;d.fn.position=function(b){if(!b||!b.of)return n.apply(this,arguments);var b=d.extend({},b),a=d(b.of),c=a[0],f=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],g,j,h;c.nodeType===9?(g=a.width(),j=a.height(),h={top:0,left:0}):c.setTimeout?(g=a.width(),j=a.height(),h={top:a.scrollTop(),left:a.scrollLeft()}):c.preventDefault?(b.at="left top",g=j=0,h={top:b.of.pageY,left:b.of.pageX}):
(g=a.outerWidth(),j=a.outerHeight(),h=a.offset());d.each(["my","at"],function(){var a=(b[this]||"").split(" ");a.length===1&&(a=k.test(a[0])?a.concat(["center"]):l.test(a[0])?["center"].concat(a):["center","center"]);a[0]=k.test(a[0])?a[0]:"center";a[1]=l.test(a[1])?a[1]:"center";b[this]=a});f.length===1&&(f[1]=f[0]);e[0]=parseInt(e[0],10)||0;e.length===1&&(e[1]=e[0]);e[1]=parseInt(e[1],10)||0;b.at[0]==="right"?h.left+=g:b.at[0]==="center"&&(h.left+=g/2);b.at[1]==="bottom"?h.top+=j:b.at[1]==="center"&&
(h.top+=j/2);h.left+=e[0];h.top+=e[1];return this.each(function(){var a=d(this),c=a.outerWidth(),m=a.outerHeight(),k=parseInt(d.curCSS(this,"marginLeft",!0))||0,l=parseInt(d.curCSS(this,"marginTop",!0))||0,n=c+k+(parseInt(d.curCSS(this,"marginRight",!0))||0),o=m+l+(parseInt(d.curCSS(this,"marginBottom",!0))||0),i=d.extend({},h),p;b.my[0]==="right"?i.left-=c:b.my[0]==="center"&&(i.left-=c/2);b.my[1]==="bottom"?i.top-=m:b.my[1]==="center"&&(i.top-=m/2);i.left=Math.round(i.left);i.top=Math.round(i.top);
p={left:i.left-k,top:i.top-l};d.each(["left","top"],function(a,h){if(d.ui.position[f[a]])d.ui.position[f[a]][h](i,{targetWidth:g,targetHeight:j,elemWidth:c,elemHeight:m,collisionPosition:p,collisionWidth:n,collisionHeight:o,offset:e,my:b.my,at:b.at})});d.fn.bgiframe&&a.bgiframe();a.offset(d.extend(i,{using:b.using}))})};d.ui.position={fit:{left:function(b,a){var c=d(window),c=a.collisionPosition.left+a.collisionWidth-c.width()-c.scrollLeft();b.left=c>0?b.left-c:Math.max(b.left-a.collisionPosition.left,
b.left)},top:function(b,a){var c=d(window),c=a.collisionPosition.top+a.collisionHeight-c.height()-c.scrollTop();b.top=c>0?b.top-c:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var c=d(window),c=a.collisionPosition.left+a.collisionWidth-c.width()-c.scrollLeft(),f=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,g=-2*a.offset[0];b.left+=a.collisionPosition.left<0?f+e+g:c>0?f+e+g:0}},top:function(b,
a){if(a.at[1]!=="center"){var c=d(window),c=a.collisionPosition.top+a.collisionHeight-c.height()-c.scrollTop(),f=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,g=-2*a.offset[1];b.top+=a.collisionPosition.top<0?f+e+g:c>0?f+e+g:0}}}};if(!d.offset.setOffset)d.offset.setOffset=function(b,a){if(/static/.test(d.curCSS(b,"position")))b.style.position="relative";var c=d(b),f=c.offset(),e=parseInt(d.curCSS(b,"top",!0),10)||0,g=parseInt(d.curCSS(b,
"left",!0),10)||0,f={top:a.top-f.top+e,left:a.left-f.left+g};"using"in a?a.using.call(b,f):c.css(f)},d.fn.offset=function(b){var a=this[0];return!a||!a.ownerDocument?null:b?this.each(function(){d.offset.setOffset(this,b)}):o.call(this)}})(jQuery);
