(function($) {
	$(document).ready(function()
	{
		var bgSwitcher = {
			init:function()
			{
				//---Constructor params
				bgSwitcher._timeToSwitch = 6000;
				bgSwitcher._nTotalItem = 11;
				bgSwitcher._nCurrentItem = 1;
				bgSwitcher._nNextItem = 0;
				bgSwitcher._timer = null;
				//---Init calls
				bgSwitcher.play();
			},
			play:function()
			{
				bgSwitcher._timer = setInterval(bgSwitcher.displayNextItem,bgSwitcher._timeToSwitch);
			},
			displayNextItem:function()
			{
				bgSwitcher.setNextItem();
				bgSwitcher.displayItem();
			},
			setNextItem:function()
			{
				bgSwitcher._nNextItem = bgSwitcher._nCurrentItem + 1;
				//Check if above max...
				if (bgSwitcher._nNextItem > bgSwitcher._nTotalItem) {
					//Reset to first item
					bgSwitcher._nNextItem = 1;
				}
			},
			displayItem:function()
			{
				//Define bg items
				var bgContainer = $('#bgContainer div');
				var nextSlide = bgContainer.eq(bgSwitcher._nNextItem-1);
				var currentSlide = bgContainer.eq(bgSwitcher._nCurrentItem-1);
				//Fade
				nextSlide.fadeIn(2000);
				currentSlide.fadeOut(2000);
				//Update current item
				bgSwitcher._nCurrentItem = bgSwitcher._nNextItem;
			}
		};
		bgSwitcher.init();
	});
})(jQuery);
