/*!
 * jQuery UI Position 1.10.1
 * http://jqueryui.com
 *
 * Copyright 2013 jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 *
 * http://api.jqueryui.com/position/
 */
(function(d,E){function C(a,b,c){return[parseFloat(a[0])*(u.test(a[0])?b/100:1),parseFloat(a[1])*(u.test(a[1])?c/100:1)]}function F(a){var b=a[0];return 9===b.nodeType?{width:a.width(),height:a.height(),offset:{top:0,left:0}}:d.isWindow(b)?{width:a.width(),height:a.height(),offset:{top:a.scrollTop(),left:a.scrollLeft()}}:b.preventDefault?{width:0,height:0,offset:{top:b.pageY,left:b.pageX}}:{width:a.outerWidth(),height:a.outerHeight(),offset:a.offset()}}d.ui=d.ui||{};var q,y=Math.max,n=Math.abs,D= Math.round,v=/left|center|right/,w=/top|center|bottom/,z=/[\+\-]\d+(\.[\d]+)?%?/,A=/^\w+/,u=/%$/,G=d.fn.position;d.position={scrollbarWidth:function(){if(q!==E)return q;var a,b,c=d("<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>");b=c.children()[0];d("body").append(c);a=b.offsetWidth;c.css("overflow","scroll");b=b.offsetWidth;a===b&&(b=c[0].clientWidth);c.remove();return q=a-b},getScrollInfo:function(a){var b=a.isWindow?"":a.element.css("overflow-x"), c=a.isWindow?"":a.element.css("overflow-y"),c="scroll"===c||"auto"===c&&a.height<a.element[0].scrollHeight;return{width:"scroll"===b||"auto"===b&&a.width<a.element[0].scrollWidth?d.position.scrollbarWidth():0,height:c?d.position.scrollbarWidth():0}},getWithinInfo:function(a){a=d(a||window);var b=d.isWindow(a[0]);return{element:a,isWindow:b,offset:a.offset()||{left:0,top:0},scrollLeft:a.scrollLeft(),scrollTop:a.scrollTop(),width:b?a.width():a.outerWidth(),height:b?a.height():a.outerHeight()}}};d.fn.position= function(a){if(!a||!a.of)return G.apply(this,arguments);a=d.extend({},a);var b,c,g,l,f,e,p=d(a.of),m=d.position.getWithinInfo(a.within),k=d.position.getScrollInfo(m),x=(a.collision||"flip").split(" "),q={};e=F(p);p[0].preventDefault&&(a.at="left top");c=e.width;g=e.height;l=e.offset;f=d.extend({},l);d.each(["my","at"],function(){var b=(a[this]||"").split(" "),c,g;1===b.length&&(b=v.test(b[0])?b.concat(["center"]):w.test(b[0])?["center"].concat(b):["center","center"]);b[0]=v.test(b[0])?b[0]:"center"; b[1]=w.test(b[1])?b[1]:"center";c=z.exec(b[0]);g=z.exec(b[1]);q[this]=[c?c[0]:0,g?g[0]:0];a[this]=[A.exec(b[0])[0],A.exec(b[1])[0]]});1===x.length&&(x[1]=x[0]);"right"===a.at[0]?f.left+=c:"center"===a.at[0]&&(f.left+=c/2);"bottom"===a.at[1]?f.top+=g:"center"===a.at[1]&&(f.top+=g/2);b=C(q.at,c,g);f.left+=b[0];f.top+=b[1];return this.each(function(){var e,u,r=d(this),s=r.outerWidth(),t=r.outerHeight(),v=parseInt(d.css(this,"marginLeft"),10)||0,w=parseInt(d.css(this,"marginTop"),10)||0,z=s+v+(parseInt(d.css(this, "marginRight"),10)||0)+k.width,A=t+w+(parseInt(d.css(this,"marginBottom"),10)||0)+k.height,h=d.extend({},f),B=C(q.my,r.outerWidth(),r.outerHeight());"right"===a.my[0]?h.left-=s:"center"===a.my[0]&&(h.left-=s/2);"bottom"===a.my[1]?h.top-=t:"center"===a.my[1]&&(h.top-=t/2);h.left+=B[0];h.top+=B[1];d.support.offsetFractions||(h.left=D(h.left),h.top=D(h.top));e={marginLeft:v,marginTop:w};d.each(["left","top"],function(f,l){if(d.ui.position[x[f]])d.ui.position[x[f]][l](h,{targetWidth:c,targetHeight:g, elemWidth:s,elemHeight:t,collisionPosition:e,collisionWidth:z,collisionHeight:A,offset:[b[0]+B[0],b[1]+B[1]],my:a.my,at:a.at,within:m,elem:r})});a.using&&(u=function(b){var d=l.left-h.left,e=d+c-s,f=l.top-h.top,m=f+g-t,k={target:{element:p,left:l.left,top:l.top,width:c,height:g},element:{element:r,left:h.left,top:h.top,width:s,height:t},horizontal:0>e?"left":0<d?"right":"center",vertical:0>m?"top":0<f?"bottom":"middle"};c<s&&n(d+e)<c&&(k.horizontal="center");g<t&&n(f+m)<g&&(k.vertical="middle");y(n(d), n(e))>y(n(f),n(m))?k.important="horizontal":k.important="vertical";a.using.call(this,b,k)});r.offset(d.extend(h,{using:u}))})};d.ui.position={fit:{left:function(a,b){var c=b.within,g=c.isWindow?c.scrollLeft:c.offset.left,d=c.width,f=a.left-b.collisionPosition.marginLeft,c=g-f,e=f+b.collisionWidth-d-g;b.collisionWidth>d?0<c&&0>=e?(g=a.left+c+b.collisionWidth-d-g,a.left+=c-g):a.left=0<e&&0>=c?g:c>e?g+d-b.collisionWidth:g:a.left=0<c?a.left+c:0<e?a.left-e:y(a.left-f,a.left)},top:function(a,b){var c=b.within, g=c.isWindow?c.scrollTop:c.offset.top,d=b.within.height,f=a.top-b.collisionPosition.marginTop,c=g-f,e=f+b.collisionHeight-d-g;b.collisionHeight>d?0<c&&0>=e?(g=a.top+c+b.collisionHeight-d-g,a.top+=c-g):a.top=0<e&&0>=c?g:c>e?g+d-b.collisionHeight:g:a.top=0<c?a.top+c:0<e?a.top-e:y(a.top-f,a.top)}},flip:{left:function(a,b){var c=b.within,d=c.offset.left+c.scrollLeft,l=c.width,f=c.isWindow?c.scrollLeft:c.offset.left,e=a.left-b.collisionPosition.marginLeft,c=e-f,p=e+b.collisionWidth-l-f,e="left"===b.my[0]? -b.elemWidth:"right"===b.my[0]?b.elemWidth:0,m="left"===b.at[0]?b.targetWidth:"right"===b.at[0]?-b.targetWidth:0,k=-2*b.offset[0];if(0>c){if(d=a.left+e+m+k+b.collisionWidth-l-d,0>d||d<n(c))a.left+=e+m+k}else 0<p&&(d=a.left-b.collisionPosition.marginLeft+e+m+k-f,0<d||n(d)<p)&&(a.left+=e+m+k)},top:function(a,b){var c=b.within,d=c.offset.top+c.scrollTop,l=c.height,f=c.isWindow?c.scrollTop:c.offset.top,e=a.top-b.collisionPosition.marginTop,c=e-f,p=e+b.collisionHeight-l-f,e="top"===b.my[1]?-b.elemHeight: "bottom"===b.my[1]?b.elemHeight:0,m="top"===b.at[1]?b.targetHeight:"bottom"===b.at[1]?-b.targetHeight:0,k=-2*b.offset[1];0>c?(d=a.top+e+m+k+b.collisionHeight-l-d,a.top+e+m+k>c&&(0>d||d<n(c))&&(a.top+=e+m+k)):0<p&&(d=a.top-b.collisionPosition.marginTop+e+m+k-f,a.top+e+m+k>p&&(0<d||n(d)<p)&&(a.top+=e+m+k))}},flipfit:{left:function(){d.ui.position.flip.left.apply(this,arguments);d.ui.position.fit.left.apply(this,arguments)},top:function(){d.ui.position.flip.top.apply(this,arguments);d.ui.position.fit.top.apply(this, arguments)}}};(function(){var a,b,c,g,l=document.getElementsByTagName("body")[0];c=document.createElement("div");a=document.createElement(l?"div":"body");b={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"};l&&d.extend(b,{position:"absolute",left:"-1000px",top:"-1000px"});for(g in b)a.style[g]=b[g];a.appendChild(c);b=l||document.documentElement;b.insertBefore(a,b.firstChild);c.style.cssText="position: absolute; left: 10.7432222px;";c=d(c).offset().left;d.support.offsetFractions= 10<c&&11>c;a.innerHTML="";b.removeChild(a)})()})(jQuery);