/*
 * jQuery UI Position 1.9m5
 *
 * 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,y){f.ui=f.ui||{};var q=/left|center|right/,r=/top|center|bottom/,s=/[+-]\d+%?/,t=/^\w+/,o=/%$/,z=f.fn.position;f.fn.position=function(b){if(!b||!b.of)return z.apply(this,arguments);b=f.extend({},b);var a=f(b.of),c=a[0],e=(b.collision||"flip").split(" "),d={},i,k,l,j;if(c.nodeType===9){k=a.width();l=a.height();j={top:0,left:0}}else if(f.isWindow(c)){k=a.width();l=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(c.preventDefault){b.at="left top";k=l=0;j={top:b.of.pageY,left:b.of.pageX}}else{k=
a.outerWidth();l=a.outerHeight();j=a.offset()}f.each(["my","at"],function(){var g=(b[this]||"").split(" "),m,n;if(g.length===1)g=q.test(g[0])?g.concat(["center"]):r.test(g[0])?["center"].concat(g):["center","center"];g[0]=q.test(g[0])?g[0]:"center";g[1]=r.test(g[1])?g[1]:"center";m=s.exec(g[0]);n=s.exec(g[1]);d[this]=[m?m[0]:0,n?n[0]:0];b[this]=[t.exec(g[0])[0],t.exec(g[1])[0]]});if(e.length===1)e[1]=e[0];if(b.at[0]==="right")j.left+=k;else if(b.at[0]==="center")j.left+=k/2;if(b.at[1]==="bottom")j.top+=
l;else if(b.at[1]==="center")j.top+=l/2;i=[parseInt(d.at[0],10)*(o.test(d.at[0])?k/100:1),parseInt(d.at[1],10)*(o.test(d.at[1])?l/100:1)];j.left+=i[0];j.top+=i[1];return this.each(function(){var g=f(this),m=g.outerWidth(),n=g.outerHeight(),u=parseInt(f.curCSS(this,"marginLeft",true))||0,v=parseInt(f.curCSS(this,"marginTop",true))||0,A=m+u+(parseInt(f.curCSS(this,"marginRight",true))||0),B=n+v+(parseInt(f.curCSS(this,"marginBottom",true))||0),h=f.extend({},j),p=[parseInt(d.my[0],10)*(o.test(d.my[0])?
g.outerWidth()/100:1),parseInt(d.my[1],10)*(o.test(d.my[1])?g.outerHeight()/100:1)],w;if(b.my[0]==="right")h.left-=m;else if(b.my[0]==="center")h.left-=m/2;if(b.my[1]==="bottom")h.top-=n;else if(b.my[1]==="center")h.top-=n/2;h.left+=p[0];h.top+=p[1];h.left=Math.round(h.left);h.top=Math.round(h.top);w={left:h.left-u,top:h.top-v};f.each(["left","top"],function(x,C){if(f.ui.position[e[x]])f.ui.position[e[x]][C](h,{targetWidth:k,targetHeight:l,elemWidth:m,elemHeight:n,collisionPosition:w,collisionWidth:A,
collisionHeight:B,offset:[i[0]+p[0],i[1]+p[1]],my:b.my,at:b.at})});f.fn.bgiframe&&g.bgiframe();g.offset(f.extend(h,{using:b.using}))})};f.ui.position={fit:{left:function(b,a){var c=f(window),e=c.scrollLeft()-a.collisionPosition.left,d=a.collisionPosition.left+a.collisionWidth-c.width()-c.scrollLeft();if(a.collisionWidth>c.width()||e>0)b.left+=e;else if(d>0)b.left-=d;else b.left=Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var c=f(window),e=c.scrollTop()-a.collisionPosition.top,
d=a.collisionPosition.top+a.collisionHeight-c.height()-c.scrollTop();if(a.collisionHeight>c.height()||e>0)b.top+=e;else if(d>0)b.top-=d;else b.top=Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var c=f(window);c=a.collisionPosition.left+a.collisionWidth-c.width()-c.scrollLeft();var e=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,d=a.at[0]==="left"?a.targetWidth:-a.targetWidth,i=-2*a.offset[0];b.left+=a.collisionPosition.left<0?e+d+i:
c>0?e+d+i:0}},top:function(b,a){if(a.at[1]!=="center"){var c=f(window);c=a.collisionPosition.top+a.collisionHeight-c.height()-c.scrollTop();var e=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,d=a.at[1]==="top"?a.targetHeight:-a.targetHeight,i=-2*a.offset[1];b.top+=a.collisionPosition.top<0?e+d+i:c>0?e+d+i:0}}}};f.uiBackCompat!==false&&function(b){var a=b.fn.position;b.fn.position=function(c){if(!c||!("offset"in c))return a.call(this,c);var e=c.offset.split(" "),d=c.at.split(" ");
if(e.length===1)e[1]=e[0];if(/^\d/.test(e[0]))e[0]="+"+e[0];if(/^\d/.test(e[1]))e[1]="+"+e[1];if(d.length===1)if(/left|center|right/.test(d[0]))d[1]="center";else{d[1]=d[0];d[0]="center"}return a.call(this,b.extend(c,{at:d[0]+e[0]+" "+d[1]+e[1],offset:y}))}}(jQuery)})(jQuery);

