(function(F,H){F.ui=F.ui||{};var C=/left|center|right/,E="center",D=/top|center|bottom/,G="center",A=F.fn.position,B=F.fn.offset;F.fn.position=function(J){if(!J||!J.of){return A.apply(this,arguments)}J=F.extend({},J);var M=F(J.of),O=(J.collision||"flip").split(" "),N=J.offset?J.offset.split(" "):[0,0],L,I,K;if(J.of.nodeType===9){L=M.width();I=M.height();K={top:0,left:0}}else{if(J.of.scrollTo&&J.of.document){L=M.width();I=M.height();K={top:M.scrollTop(),left:M.scrollLeft()}}else{if(J.of.preventDefault){J.at="left top";L=I=0;K={top:J.of.pageY,left:J.of.pageX}}else{L=M.outerWidth();I=M.outerHeight();K=M.offset()}}}F.each(["my","at"],function(){var P=(J[this]||"").split(" ");if(P.length===1){P=C.test(P[0])?P.concat([G]):D.test(P[0])?[E].concat(P):[E,G]}P[0]=C.test(P[0])?P[0]:E;P[1]=D.test(P[1])?P[1]:G;J[this]=P});if(O.length===1){O[1]=O[0]}N[0]=parseInt(N[0],10)||0;if(N.length===1){N[1]=N[0]}N[1]=parseInt(N[1],10)||0;if(J.at[0]==="right"){K.left+=L}else{if(J.at[0]===E){K.left+=L/2}}if(J.at[1]==="bottom"){K.top+=I}else{if(J.at[1]===G){K.top+=I/2}}K.left+=N[0];K.top+=N[1];return this.each(function(){var S=F(this),R=S.outerWidth(),Q=S.outerHeight(),P=F.extend({},K);if(J.my[0]==="right"){P.left-=R}else{if(J.my[0]===E){P.left-=R/2}}if(J.my[1]==="bottom"){P.top-=Q}else{if(J.my[1]===G){P.top-=Q/2}}P.left=parseInt(P.left);P.top=parseInt(P.top);F.each(["left","top"],function(U,T){if(F.ui.position[O[U]]){F.ui.position[O[U]][T](P,{targetWidth:L,targetHeight:I,elemWidth:R,elemHeight:Q,offset:N,my:J.my,at:J.at})}});if(F.fn.bgiframe){S.bgiframe()}S.offset(F.extend(P,{using:J.using}))})};F.ui.position={fit:{left:function(I,J){var L=F(window),K=I.left+J.elemWidth-L.width()-L.scrollLeft();I.left=K>0?I.left-K:Math.max(0,I.left)},top:function(I,J){var L=F(window),K=I.top+J.elemHeight-L.height()-L.scrollTop();I.top=K>0?I.top-K:Math.max(0,I.top)}},flip:{left:function(J,K){if(K.at[0]==="center"){return}var M=F(window),L=J.left+K.elemWidth-M.width()-M.scrollLeft(),I=K.my[0]==="left"?-K.elemWidth:K.my[0]==="right"?K.elemWidth:0,N=-2*K.offset[0];J.left+=J.left<0?I+K.targetWidth+N:L>0?I-K.targetWidth+N:0},top:function(J,L){if(L.at[1]==="center"){return}var N=F(window),M=J.top+L.elemHeight-N.height()-N.scrollTop(),I=L.my[1]==="top"?-L.elemHeight:L.my[1]==="bottom"?L.elemHeight:0,K=L.at[1]==="top"?L.targetHeight:-L.targetHeight,O=-2*L.offset[1];J.top+=J.top<0?I+L.targetHeight+O:M>0?I+K+O:0}}};if(!F.offset.setOffset){F.offset.setOffset=function(M,J){if(/static/.test(F.curCSS(M,"position"))){M.style.position="relative"}var L=F(M),O=L.offset(),I=parseInt(F.curCSS(M,"top",true),10)||0,N=parseInt(F.curCSS(M,"left",true),10)||0,K={top:(J.top-O.top)+I,left:(J.left-O.left)+N};if("using" in J){J.using.call(M,K)}else{L.css(K)}};F.fn.offset=function(I){var J=this[0];if(!J||!J.ownerDocument){return null}if(I){return this.each(function(){F.offset.setOffset(this,I)})}return B.call(this)}}}(jQuery));
