/*
 * jQuery UI Position 1.9m6
 *
 * 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(f,A){f.ui=f.ui||{};var r=/left|center|right/,s=/top|center|bottom/,t=/[+-]\d+%?/,u=/^\w+/,p=/%$/,B=f.fn.position;f.position={scrollbarWidth:function(){var b,a,c=f("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>");a=c.children()[0];f("body").append(c);b=a.offsetWidth;c.css("overflow","scroll");a=a.offsetWidth;if(b===a)a=c[0].clientWidth;c.remove();return b-a},getScrollInfo:function(b){var a=b[0]!==window,c=a?b.css("overflow-x"):
"";a=a?b.css("overflow-y"):"";c=c==="auto"||c==="scroll"?f.position.scrollbarWidth():0;a=a==="auto"||a==="scroll"?f.position.scrollbarWidth():0;return{height:b.height()<b[0].scrollHeight?a:0,width:b.width()<b[0].scrollWidth?c:0}}};f.fn.position=function(b){if(!b||!b.of)return B.apply(this,arguments);b=f.extend({},b);var a=f(b.of),c=f(b.within||window),d=a[0],e=(b.collision||"flip").split(" "),g={},i,j,k,l;if(d.nodeType===9){j=a.width();k=a.height();l={top:0,left:0}}else if(f.isWindow(d)){j=a.width();
k=a.height();l={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";j=k=0;l={top:b.of.pageY,left:b.of.pageX}}else{j=a.outerWidth();k=a.outerHeight();l=a.offset()}f.each(["my","at"],function(){var h=(b[this]||"").split(" "),m,n;if(h.length===1)h=r.test(h[0])?h.concat(["center"]):s.test(h[0])?["center"].concat(h):["center","center"];h[0]=r.test(h[0])?h[0]:"center";h[1]=s.test(h[1])?h[1]:"center";m=t.exec(h[0]);n=t.exec(h[1]);g[this]=[m?m[0]:0,n?n[0]:0];b[this]=[u.exec(h[0])[0],
u.exec(h[1])[0]]});if(e.length===1)e[1]=e[0];if(b.at[0]==="right")l.left+=j;else if(b.at[0]==="center")l.left+=j/2;if(b.at[1]==="bottom")l.top+=k;else if(b.at[1]==="center")l.top+=k/2;i=[parseInt(g.at[0],10)*(p.test(g.at[0])?j/100:1),parseInt(g.at[1],10)*(p.test(g.at[1])?k/100:1)];l.left+=i[0];l.top+=i[1];return this.each(function(){var h=f(this),m=h.outerWidth(),n=h.outerHeight(),v=parseInt(f.curCSS(this,"marginLeft",true))||0,w=parseInt(f.curCSS(this,"marginTop",true))||0,x=f.position.getScrollInfo(c),
C=m+v+(parseInt(f.curCSS(this,"marginRight",true))||0)+x.width,D=n+w+(parseInt(f.curCSS(this,"marginBottom",true))||0)+x.height,o=f.extend({},l),q=[parseInt(g.my[0],10)*(p.test(g.my[0])?h.outerWidth()/100:1),parseInt(g.my[1],10)*(p.test(g.my[1])?h.outerHeight()/100:1)],y;if(b.my[0]==="right")o.left-=m;else if(b.my[0]==="center")o.left-=m/2;if(b.my[1]==="bottom")o.top-=n;else if(b.my[1]==="center")o.top-=n/2;o.left+=q[0];o.top+=q[1];y={marginLeft:v,marginTop:w};f.each(["left","top"],function(z,E){if(f.ui.position[e[z]])f.ui.position[e[z]][E](o,
{targetWidth:j,targetHeight:k,elemWidth:m,elemHeight:n,collisionPosition:y,collisionWidth:C,collisionHeight:D,offset:[i[0]+q[0],i[1]+q[1]],my:b.my,at:b.at,within:c,elem:h})});f.fn.bgiframe&&h.bgiframe();h.offset(f.extend(o,{using:b.using}))})};f.ui.position={fit:{left:function(b,a){var c=a.within,d=f(window),e=f.isWindow(a.within[0]),g=e?d.scrollLeft():c.offset().left;d=e?d.width():c.outerWidth();e=b.left-a.collisionPosition.marginLeft;c=g-e;var i=e+a.collisionWidth-d-g;if(a.collisionWidth>d)if(c>
0&&i<=0){g=b.left+c+a.collisionWidth-d-g;b.left+=c-g}else b.left=i>0&&c<=0?g:c>i?g+d-a.collisionWidth:g;else if(c>0)b.left+=c;else if(i>0)b.left-=i;else b.left=Math.max(b.left-e,b.left)},top:function(b,a){var c=a.within,d=f(window),e=f.isWindow(a.within[0]),g=e?d.scrollTop():c.offset().top;d=e?d.height():c.outerHeight();e=b.top-a.collisionPosition.marginTop;c=g-e;var i=e+a.collisionHeight-d-g;if(a.collisionHeight>d)if(c>0&&i<=0){g=b.top+c+a.collisionHeight-d-g;b.top+=c-g}else b.top=i>0&&c<=0?g:c>
i?g+d-a.collisionHeight:g;else if(c>0)b.top+=c;else if(i>0)b.top-=i;else b.top=Math.max(b.top-e,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){a.elem.removeClass("ui-flipped-left ui-flipped-right");var c=a.within;f(window);var d=f.isWindow(a.within[0]),e=(d?0:c.offset().left)+c.scrollLeft(),g=d?c.width():c.outerWidth();d=b.left-a.collisionPosition.marginLeft;c=d-e;var i=d+a.collisionWidth-g-e;d=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0;var j=a.at[0]==="left"?a.targetWidth:
-a.targetWidth,k=-2*a.offset[0];if(c<0){e=b.left+d+j+k+a.collisionWidth-g-e;if(e<0||e<Math.abs(c)){a.elem.addClass("ui-flipped-right");b.left+=d+j+k}}else if(i>0){e=b.left-a.collisionPosition.marginLeft+d+j+k-e;if(e>0||Math.abs(e)<i){a.elem.addClass("ui-flipped-left");b.left+=d+j+k}}}},top:function(b,a){if(a.at[1]!=="center"){a.elem.removeClass("ui-flipped-top ui-flipped-bottom");var c=a.within;f(window);var d=f.isWindow(a.within[0]),e=(d?0:c.offset().top)+c.scrollTop(),g=d?c.height():c.outerHeight();
d=b.top-a.collisionPosition.marginTop;c=d-e;var i=d+a.collisionHeight-g-e;d=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0;var j=a.at[1]==="top"?a.targetHeight:-a.targetHeight,k=-2*a.offset[1];if(c<0){e=b.top+d+j+k+a.collisionHeight-g-e;if(e<0||e<Math.abs(c)){a.elem.addClass("ui-flipped-bottom");b.top+=d+j+k}}else if(i>0){e=b.top-a.collisionPosition.marginTop+d+j+k-e;if(e>0||Math.abs(e)<i){a.elem.addClass("ui-flipped-top");b.top+=d+j+k}}}}},flipfit:{left:function(){f.ui.position.flip.left.apply(this,
arguments);f.ui.position.fit.left.apply(this,arguments)},top:function(){f.ui.position.flip.top.apply(this,arguments);f.ui.position.fit.top.apply(this,arguments)}}};f.uiBackCompat!==false&&function(b){var a=b.fn.position;b.fn.position=function(c){if(!c||!c.offset)return a.call(this,c);var d=c.offset.split(" "),e=c.at.split(" ");if(d.length===1)d[1]=d[0];if(/^\d/.test(d[0]))d[0]="+"+d[0];if(/^\d/.test(d[1]))d[1]="+"+d[1];if(e.length===1)if(/left|center|right/.test(e[0]))e[1]="center";else{e[1]=e[0];
e[0]="center"}return a.call(this,b.extend(c,{at:e[0]+d[0]+" "+e[1]+d[1],offset:A}))}}(jQuery)})(jQuery);

