var $j = jQuery.noConflict();	
(function($j){
	//Resize image on ready or resize
	$j.fn.supersize = function() {	
		//Invoke the resizenow() function on document ready
		$j(document).ready(function() {
			$j('#supersize').resizenow(); 
		});
		//Invoke the resizenow() function on browser resize
		$j(window).bind("resize", function() {
    		$j('#supersize').resizenow(); 
		});
	};
	//Adjust image size
	$j.fn.resizenow = function() {
		//Define starting width and height values for the original image
		var startwidth = 1400;  
		var startheight = 960;
		//Define image ratio
		var ratio = startheight/startwidth;
		//Gather browser dimensions
		var browserwidth = $j(window).width();
		var browserheight = $j(window).height();
		//Resize image to proper ratio
		if ((browserheight/browserwidth) > ratio) {
		    $j(this).height(browserheight);
		    $j(this).width(browserheight / ratio);
		    $j(this).children().height(browserheight);
		    $j(this).children().width(browserheight / ratio);
		} else {
		    $j(this).width(browserwidth);
		    $j(this).height(browserwidth * ratio);
		    $j(this).children().width(browserwidth);
		    $j(this).children().height(browserwidth * ratio);
		}
		//Make sure the image stays center in the window
		$j(this).children().css('left', (browserwidth - $j(this).width())/2);
		$j(this).children().css('top', (browserheight - $j(this).height())/2);
	};
})(jQuery);

$j(document).ready(function() {
	//Funtion to create the jQuery carousel tabs - The rotating images showing previous clients work
	$j(function() {
		$j("#tabs").tabs({event:"mouseover"}).tabs('rotate', 10000, true);
	});
	//Invoking the supersized function on the div with id - supersize. It is the div that contains the large background image
	$j("div#supersize").supersize();
});
