/*!
 * jQuery.FullBleed
 * Copyright (c) 2010 Robin North <http://www.phenotype.net>
 * Heavily based upon Supersized by Sam Dunn 
 * (buildinternet.com / onemightyroar.com)
 * 
 */
 
(function($){$.fn.fullbleed=function(options){var opts=$.extend({},$.fn.fullbleed.defaults,options);return this.each(function(){var $this=$(this);$this.css({'width':'auto','height':'auto'});resizeImage($this,opts);$(window).bind('resize.default',function(){resizeImage($this,opts);});});};$.fn.fullbleed.defaults={minSizeFactor:0.5};function debug($debug){if(window.console&&window.console.log){window.console.log($debug);}};function resizeImage($this,opts){var imageWidth=$this.width();var imageHeight=$this.height();var browserWidth=$(window).width();var browserHeight=$(window).height();var minWidth=opts.minSize*(imageWidth);var minHeight=opts.minSize*(imageHeight);var aspectRatio=imageHeight/imageWidth;if((browserHeight<minHeight)&&(browserWidth<minWidth)){$this.height(minHeight);$this.width(minWidth);}else{if(browserHeight>browserWidth){imageHeight=browserHeight;$this.height(browserHeight);imageWidth=browserHeight/aspectRatio;$this.width(imageWidth);if(browserWidth>imageWidth){imageWidth=browserWidth;$this.width(browserWidth);imageHeight=browserWidth*aspectRatio;$this.height(imageHeight);}}
if(browserWidth>=browserHeight){imageWidth=browserWidth;$this.width(browserWidth);imageHeight=browserWidth*aspectRatio;$this.height(imageHeight);if(browserHeight>imageHeight){imageHeight=browserHeight;$this.height(browserHeight);imageWidth=browserHeight/aspectRatio;$this.width(imageWidth);}}}};})(jQuery);
