(function(a){a.fn.imagesLoaded=function(d){var c=this.filter("img"),b=c.length;c.bind("load",function(){if(--b<=0){d.call(c,this)}}).each(function(){var e=this.src;this.src="#";this.src=e});return this}}(jQuery));(function(a){a.fn.extend({cjObjectScaler:function(c,d){var b={scaleObj:function(f){var j=f.data("cj"),g=j.options,p=a(g.destElem).width(),k=a(g.destElem).height(),n,m,h,i,e,q=parseInt(f.css("borderLeftWidth"),10)+parseInt(f.css("borderRightWidth"),10),l=parseInt(f.css("borderTopWidth"),10)+parseInt(f.css("borderBottomWidth"),10);q=isNaN(q)?0:q;l=isNaN(l)?0:l;n=p/f.width();m=k/f.height();if(n<1.5&&m<1.5){if(!f.hasClass("cf_image_scaler_fill")&&(f.hasClass("cf_image_scaler_fit")||g.method==="fit")){h=n<m?n:m}else{if(!f.hasClass("cf_image_scaler_fit")&&(f.hasClass("cf_image_scaler_fill")||g.method==="fill")){h=n>m?n:m}}i=parseInt(f.width()*h,10)-q;e=parseInt(f.height()*h,10)-l;f.css({width:i+"px",height:e+"px",position:"absolute",top:(parseInt((k-e)/2,10)-parseInt(l/2,10))+"px",left:(parseInt((p-i)/2,10)-parseInt(q/2,10))+"px"}).attr({width:i,height:e})}else{f.css({position:"absolute",top:(parseInt((k)/2,10)-parseInt(f.height()/2,10))+"px",left:(parseInt((p)/2,10)-parseInt(f.width()/2,10))+"px"})}if(g.fade>0){f.fadeIn(g.fade)}if(typeof d==="function"){d()}}};if(typeof c==="object"||!c){return this.each(function(){var g=a(this),e=g.data("cj"),f;if(!e){g.data("cj",{options:{method:"fill",destElem:null,fade:0}});e=g.data("cj")}if(c){e.options=a.extend(e.options,c)}f=e.options;if(f.destElem===null){f.destElem=g.parent()}if(a(f.destElem).css("position")==="static"){a(f.destElem).css({position:"relative"})}if(typeof g==="object"&&typeof f.destElem==="object"&&typeof f.method==="string"){if(f.fade>0){g.hide()}if(g.get(0).nodeName==="IMG"){g.width("auto");g.height("auto");g.imagesLoaded(function(){b.scaleObj(g)})}else{b.scaleObj(g)}}else{a.error("CJ Object Scaler could not initialize. Bad parameters.")}})}else{a.error("Method/Option "+c+" does not exist.")}}})}(jQuery));
