/**
* Fullscreenr - lightweight full screen background jquery plugin
* By Jan Schneiders
* Version 1.0
* www.nanotux.com
**/
(function($){	
	$.fn.fullscreenr = function(options) {
		
		var defaults = { };
		var options = $.extend({}, defaults, options); 
		$(document).ready(function() { $(options.bgID).fullscreenrResizer(options);	});
		$(window).bind("resize", function() { jQuery.fn.fullscreenrResizer(options); });		
		return this; 		
	};	
	$.fn.fullscreenrResizer = function(options) {
		var browserwidth = $(window).width();
		var browserheight = $(window).height();	
		
		// Set bg size
		var imgArray = options.images;
		
		
		
		$.each(
			imgArray,
			function (intIndex, objValue){
				var ratio = objValue.height / objValue.width;	
				// Get browser window size
					
				
				// Scale the image
				if ((browserheight/browserwidth) > ratio){
				    $(objValue.bgID).height(browserheight);
				    $(objValue.bgID).width(browserheight / ratio);
				} else {
				    $(objValue.bgID).width(browserwidth);
				    $(objValue.bgID).height(browserwidth * ratio);
				}
				// Center the image
				$(objValue.bgID).css('left', (browserwidth - $(objValue.bgID).width())/2);
				$(objValue.bgID).css('top', (browserheight - $(objValue.bgID).height())/2);
			}
		);
		
		
		//$('.scrollable_splash').height(browserheight);
                //$('.scrollable_splash').width(browserwidth);
		
		//set container
		$('.container').height(browserheight);
		$('.container').width(browserwidth);
		
		if(options.api != null){
			$('.items').css('left', (options.api.getIndex()+1) * -1 * browserwidth);
		}
		return this; 		
	};
})(jQuery);
