!function(a,b,c,d){function e(b,c){this.container=b,this.options=a.extend({},g,c),this._defaults=g,this._name=f,this.init()}var f="centerImages",g={enableCentering:!0,onresize:!0,oncustom:[],imgSel:"img",defaultCSSVal:{width:"auto",height:"auto"},leftAdjust:0,zeroLeftAdjust:0,topAdjust:0,zeroTopAdjust:-2,enableGoldenRatio:!1,goldenRatioLimitHeightTo:350,goldenRatioVal:1.618,skipGoldenRatioClasses:["no-gold-ratio"],disableGRUnder:767,useImgAttr:!1};e.prototype.init=function(){var c=this;this._maybe_apply_golden_r();var d=a(this.options.imgSel,this.container);d.length&&this.options.enableCentering?this._parse_imgs(d):a(b).bind("resize",{},function(a){c._maybe_apply_golden_r(a)})},e.prototype._maybe_apply_golden_r=function(b){if(this.options.enableGoldenRatio&&this.options.goldenRatioVal&&0!==this.options.goldenRatioVal&&this._is_selector_allowed()){if(!this._is_window_width_allowed())return void a(this.container).attr("style","");var c=Math.round(a(this.container).width()/this.options.goldenRatioVal);c=c>this.options.goldenRatioLimitHeightTo?this.options.goldenRatioLimitHeightTo:c,a(this.container).css({"line-height":c+"px",height:c+"px"}).trigger("golden-ratio-applied")}},e.prototype._is_window_width_allowed=function(){return a(b).width()>this.options.disableGRUnder-15},e.prototype._parse_imgs=function(b){var c=this;b.each(function(b,d){c._pre_img_cent(a(d)),c._bind_evt(a(d))})},e.prototype._bind_evt=function(c){var d=this,e=a.isArray(this.options.oncustom)?this.options.oncustom:this.options.oncustom.split(" ");a(b).bind("resize",{},function(a){d._maybe_apply_golden_r(a)}),this.options.onresize&&a(b).resize(function(){d._pre_img_cent(c)}),e.map(function(a){c.bind(a,{},function(a){d._pre_img_cent(c)})})},e.prototype._pre_img_cent=function(a){var b=this._get_current_state(a);this._maybe_center_img(a,b)},e.prototype._get_current_state=function(b){var c=b.closest(this.container).outerWidth(),d=a(this.container).outerHeight(),e=this._get_img_dim(b,"x"),f=this._get_img_dim(b,"y"),g=f*d!==0?Math.round(e/f*d):c,h=e*c!==0?Math.round(f/e*c):d,i="h";0!==c*e&&(i=d/c>=f/e?"h":"v");var j={h:{dim:{name:"height",val:d},dir:{name:"left",val:(c-g)/2+(this.options.leftAdjust||0)},_class:"h-centered"},v:{dim:{name:"width",val:c},dir:{name:"top",val:(d-h)/2+(this.options.topAdjust||0)},_class:"v-centered"}};return{current:i,prop:j}},e.prototype._get_img_dim=function(a,b){if(!this.options.useImgAttr)return"x"==b?a.outerWidth():a.outerHeight();if(a.is(":visible"))return"x"==b?a.outerWidth():a.outerHeight();if("x"==b){var c=a.originalWidth();return typeof c===d?0:c}if("y"==b){var e=a.originalHeight();return typeof e===d?0:e}},e.prototype._maybe_center_img=function(a,b){var c=b.current,d=b.prop[c],e=b.prop["h"==c?"v":"h"],f="h"==c?this.options.zeroTopAdjust||0:this.options.zeroLeftAdjust||0;a.css(d.dim.name,d.dim.val).css(e.dim.name,this.options.defaultCSSVal[e.dim.name]||"auto").addClass(d._class).removeClass(e._class).css(d.dir.name,d.dir.val).css(e.dir.name,f)},e.prototype._is_selector_allowed=function(){if(!a(this.container).attr("class"))return!0;if(!this.options.skipGoldenRatioClasses||!a.isArray(this.options.skipGoldenRatioClasses))return!0;var b=a(this.container).attr("class").split(" "),c=this.options.skipGoldenRatioClasses,d=b.filter(function(b){return-1!=a.inArray(b,c)});return 0===d.length},a.fn[f]=function(b){return this.each(function(){a.data(this,"plugin_"+f)||a.data(this,"plugin_"+f,new e(this,b))})}}(jQuery,window,document);