/*
		Supersized - Fullscreen Slideshow jQuery Plugin
		Version : Core 3.2.0
		Site	: www.buildinternet.com/project/supersized
		
		Author	: Sam Dunn
		Company : One Mighty Roar (www.onemightyroar.com)
		License : MIT License / GPL License
*/
	
(function(c){c(document).ready(function(){c("body").append('<div id="supersized"></div>')});c.supersized=function(h){var a=this;a.$el=c("#supersized");a.el="#supersized";vars=c.supersized.vars;a.$el.data("supersized",a);api=a.$el.data("supersized");a.init=function(){c.supersized.vars.options=c.extend({},c.supersized.defaultOptions,h);a.options=c.supersized.vars.options;a._build()};a._build=function(){a._start()};a._start=function(){vars.current_slide=a.options.start_slide?a.options.start_slide-1:
Math.floor(Math.random()*a.options.slides.length);var g=a.options.new_window?' target="_blank"':"";imageLink=api.getField("url")?"href='"+api.getField("url")+"'":"";var f=c('<img src="'+api.getField("image")+'"/>');f.appendTo(a.el).wrap('<a class="image-loading activeslide" '+imageLink+g+"></a>").css("visibility","hidden");f.load(function(){a._origDim(c(this));a.resizeNow();a.launch()});a.$el.css("visibility","hidden")};a.launch=function(){a.$el.css("visibility","visible");c(window).resize(function(){a.resizeNow()})};
a.resizeNow=function(){return a.$el.each(function(){c("img",a.el).each(function(){function g(c){if(c){if(thisSlide.width()<d||thisSlide.width()<a.options.min_width)thisSlide.width()*b>=a.options.min_height?(thisSlide.width(a.options.min_width),thisSlide.height(thisSlide.width()*b)):f()}else a.options.min_height>=e&&!a.options.fit_landscape?d*b>=a.options.min_height||d*b>=a.options.min_height&&b<=1?(thisSlide.width(d),thisSlide.height(d*b)):b>1?(thisSlide.height(a.options.min_height),thisSlide.width(thisSlide.height()/
b)):thisSlide.width()<d&&(thisSlide.width(d),thisSlide.height(thisSlide.width()*b)):(thisSlide.width(d),thisSlide.height(d*b))}function f(c){c?thisSlide.height()<e&&(thisSlide.height()/b>=a.options.min_width?(thisSlide.height(a.options.min_height),thisSlide.width(thisSlide.height()/b)):g(true)):a.options.min_width>=d?e/b>=a.options.min_width||b>1?(thisSlide.height(e),thisSlide.width(e/b)):b<=1&&(thisSlide.width(a.options.min_width),thisSlide.height(thisSlide.width()*b)):(thisSlide.height(e),thisSlide.width(e/
b))}thisSlide=c(this);var b=(thisSlide.data("origHeight")/thisSlide.data("origWidth")).toFixed(2),d=a.$el.width(),e=a.$el.height();a.options.fit_always?e/d>b?g():f():e<=a.options.min_height&&d<=a.options.min_width?e/d>b?a.options.fit_landscape&&b<1?g(true):f(true):a.options.fit_portrait&&b>=1?f(true):g(true):d<=a.options.min_width?e/d>b?a.options.fit_landscape&&b<1?g(true):f():a.options.fit_portrait&&b>=1?f():g(true):e<=a.options.min_height?e/d>b?a.options.fit_landscape&&b<1?g():f(true):a.options.fit_portrait&&
b>=1?f(true):g():e/d>b?a.options.fit_landscape&&b<1?g():f():a.options.fit_portrait&&b>=1?f():g();thisSlide.parent().hasClass("image-loading")&&c(".image-loading").removeClass("image-loading");a.options.horizontal_center&&c(this).css("left",(d-c(this).width())/2);a.options.vertical_center&&c(this).css("top",(e-c(this).height())/2)});a.options.image_protect&&c("img",a.el).bind("contextmenu mousedown",function(){return false});return false})};a._origDim=function(a){a.data("origWidth",a.width()).data("origHeight",
a.height()).css("visibility","visible")};a.getField=function(c){return a.options.slides[vars.current_slide][c]};a.init()};c.supersized.vars={current_slide:0,options:{}};c.supersized.defaultOptions={start_slide:1,new_window:1,image_protect:1,min_width:0,min_height:0,vertical_center:1,horizontal_center:1,fit_always:0,fit_portrait:1,fit_landscape:0};c.fn.supersized=function(h){return this.each(function(){new c.supersized(h)})}})(jQuery);
