/*! backstretch - v2.0.4 - 2013-06-19 * http://srobbin.com/jquery-plugins/backstretch/ * copyright (c) 2013 scott robbin; licensed mit */ (function(a,d,p){a.fn.backstretch=function(c,b){(c===p||0===c.length)&&a.error("no images were supplied for backstretch");0===a(d).scrolltop()&&d.scrollto(0,0);return this.each(function(){var d=a(this),g=d.data("backstretch");if(g){if("string"==typeof c&&"function"==typeof g[c]){g[c](b);return}b=a.extend(g.options,b);g.destroy(!0)}g=new q(this,c,b);d.data("backstretch",g)})};a.backstretch=function(c,b){return a("body").backstretch(c,b).data("backstretch")};a.expr[":"].backstretch=function(c){return a(c).data("backstretch")!==p};a.fn.backstretch.defaults={centeredx:!0,centeredy:!0,duration:5e3,fade:0};var r={left:0,top:0,overflow:"hidden",margin:0,padding:0,height:"100%",width:"100%",zindex:-999999},s={position:"absolute",display:"none",margin:0,padding:0,border:"none",width:"auto",height:"auto",maxheight:"none",maxwidth:"none",zindex:-999999},q=function(c,b,e){this.options=a.extend({},a.fn.backstretch.defaults,e||{});this.images=a.isarray(b)?b:[b];a.each(this.images,function(){a("")[0].src=this});this.isbody=c===document.body;this.$container=a(c);this.$root=this.isbody?l?a(d):a(document):this.$container;c=this.$container.children(".backstretch").first();this.$wrap=c.length?c:a('
').css(r).appendto(this.$container);this.isbody||(c=this.$container.css("position"),b=this.$container.css("zindex"),this.$container.css({position:"static"===c?"relative":c,zindex:"auto"===b?0:b,background:"none"}),this.$wrap.css({zindex:-999998}));this.$wrap.css({position:this.isbody&&l?"fixed":"absolute"});this.index=0;this.show(this.index);a(d).on("resize.backstretch",a.proxy(this.resize,this)).on("orientationchange.backstretch",a.proxy(function(){this.isbody&&0===d.pageyoffset&&(d.scrollto(0,1),this.resize())},this))};q.prototype={resize:function(){try{var a={left:0,top:0},b=this.isbody?this.$root.width():this.$root.innerwidth(),e=b,g=this.isbody?d.innerheight?d.innerheight:this.$root.height():this.$root.innerheight(),j=e/this.$img.data("ratio"),f;j>=g?(f=(j-g)/2,this.options.centeredy&&(a.top="-"+f+"px")):(j=g,e=j*this.$img.data("ratio"),f=(e-b)/2,this.options.centeredx&&(a.left="-"+f+"px"));this.$wrap.css({width:b,height:g}).find("img:not(.deleteable)").css({width:e,height:j}).css(a)}catch(h){}return this},show:function(c){if(!(math.abs(c)>this.images.length-1)){var b=this,e=b.$wrap.find("img").addclass("deleteable"),d={relatedtarget:b.$container[0]};b.$container.trigger(a.event("backstretch.before",d),[b,c]);this.index=c;clearinterval(b.interval);b.$img=a("").css(s).bind("load",function(f){var h=this.width||a(f.target).width();f=this.height||a(f.target).height();a(this).data("ratio",h/f);a(this).fadein(b.options.speed||b.options.fade,function(){e.remove();b.paused||b.cycle();a(["after","show"]).each(function(){b.$container.trigger(a.event("backstretch."+this,d),[b,c])})});b.resize()}).appendto(b.$wrap);b.$img.attr("src",b.images[c]);return b}},next:function(){return this.show(this.index