(function($){	
	$.fn.fullscreenr = function(options) {
		if(options.height === undefined) alert('Please supply the background image height, default values will now be used. These may be very inaccurate.');
		if(options.width === undefined) alert('Please supply the background image width, default values will now be used. These may be very inaccurate.');
		if(options.bgID === undefined) alert('Please supply the background image ID, default #bgimg will now be used.');
		var defaults = { width: 10,  height: 10, bgID: 'bgimg' };
		var options = $.extend({}, defaults, options); 
		$(document).ready(function() { $(options.bgID).fullscreenrResizer(options);	});
		$(window).bind("resize", function() { $(options.bgID).fullscreenrResizer(options); });		
		return this; 		
	};	
	$.fn.fullscreenrResizer = function(options) {
		// Set bg size
		var ratio = options.height / options.width;	
		// Get browser window size
		var browserwidth = $(window).width();
		var browserheight = $(window).height();
		// Scale the image
		if ((browserheight/browserwidth) > ratio){
		    $(this).height(browserheight);
		    $(this).width(browserheight / ratio);
		} else {
		    $(this).width(browserwidth);
		    $(this).height(browserwidth * ratio);
		}
		// Center the image
		$(this).css('left', (browserwidth - $(this).width())/2);
		$(this).css('top', (browserheight - $(this).height())/2);
		return this; 		
	};
})(jQuery);

var FullscreenrOptions = {  width: 1200, height: 800, bgID: '.bgimage' };
jQuery.fn.fullscreenr(FullscreenrOptions);
			
/*
	active = 0;
	i = 0;
	number_of_images = 6; //Actual number of images
	
	ImageNames = new Object();
	ImageNames.length = number_of_images - 1;
	    		
	for (counter = 0; counter < number_of_images; counter++){
	    file_number = counter + 1;
	    filename = ("img/intro" + file_number + ".jpg");
	    ImageNames[counter] = filename;
	}

	var int=self.setInterval("changeImage(1)",5000);
	
	function changeImage(direction) {
	    active += 1;
	    if (active < 0)
	    	active = number_of_images + 1;
	    if (active == number_of_images)
	    	active = 0;
	    if (document.images)
	    	document.myimage.src = ImageNames[active],
	    	
	    i++;         
  	    	if(i>5){ //Number of images minus 1
        		i=0;
  	    	};
  	    	document.getElementById("description").innerHTML = casestudy[i];
	    }
	    
	    var casestudy = new Array();
		var i = 0;
		casestudy[0] = "Brand building through<br /><span>PR</span> <a href='what-we-do-pr.html'>View</a>";
		casestudy[1] = "Brand building through<br /><span>Consultancy</span> <a href='what-we-do-consultancy.html'>View</a>";
		casestudy[2] = "Brand building through<br /><span>Digital</span> <a href='what-we-do-digital.html'>View</a>";
		casestudy[3] = "Brand building through<br /><span>CSR</span> <a href='what-we-do-csr.html'>View</a>";
		casestudy[4] = "Brand building through<br /><span>Print</span> <a href='what-we-do-print.html'>View</a>";
		casestudy[5] = "Brand building through<br /><span>Events</span> <a href='what-we-do-events.html'>View</a>";
*/

		
			
				  		
		
			
	
