/**
 * @author Steve
 */


$(document).ready(function() {
	var i_cab 			=	0;
	var bg_cab			=	1;
	var i_gr			=	0;
	var bg_gr			=	1;
	var i_ret 			=	0;
	var bg_ret			=	1;
	var i_wed 			=	0;
	var bg_wed			=	1;
	var numImages	=	5;
	
		function runCabins() {
			i_cab++;
			bg_cab++;
			if (i_cab == (numImages + 1)) { i_cab = i_cab - numImages; }
			if (bg_cab == (numImages +1 )) { bg_cab = bg_cab - numImages; }
			bgImg_cab	=	'url(/images/frontrotate/cabins/' + bg_cab + '.gif)';
			img_cab		=	'<img id="gallery_cabins" src="/images/frontrotate/cabins/' + i_cab + '.gif"/>';
			$('#gallery_cabins')
				.fadeOut(4000,
					function() {
						$(this)
							.parent()
							.css("backgroundImage",bgImg_cab)
							.html(img_cab);
						runCabins();
					});			
		}
		
		function runGrounds() {
			i_gr++;
			bg_gr++;
			if (i_gr == (numImages + 1)) { i_gr = i_gr - numImages; }
			if (bg_gr == (numImages +1 )) { bg_gr = bg_gr - numImages; }
			bgImg_gr	=	'url(/images/frontrotate/grounds/' + bg_gr + '.gif)';
			img_gr		=	'<img id="gallery_grounds" src="/images/frontrotate/grounds/' + i_gr + '.gif"/>';
			$('#gallery_grounds')
				.fadeOut(4000,
					function() {
						$(this)
							.parent()
							.css("backgroundImage",bgImg_gr)
							.html(img_gr);
						runGrounds();
					});			
		}
		
		function runRetreats() {
			i_ret++;
			bg_ret++;
			if (i_ret == (numImages + 1)) { i_ret = i_ret - numImages; }
			if (bg_ret == (numImages +1 )) { bg_ret = bg_ret - numImages; }
			bgImg_ret	=	'url(/images/frontrotate/retreats/' + bg_ret + '.gif)';
			img_ret		=	'<img id="gallery_retreats" src="/images/frontrotate/retreats/' + i_ret + '.gif"/>';
			$('#gallery_retreats')
				.fadeOut(4000,
					function() {
						$(this)
							.parent()
							.css("backgroundImage",bgImg_ret)
							.html(img_ret);
						runRetreats();
					});			
		}
		
		function runWeddings() {
			i_wed++;
			bg_wed++;
			if (i_wed == (numImages + 1)) { i_wed = i_wed - numImages; }
			if (bg_wed == (numImages +1 )) { bg_wed = bg_wed - numImages; }
			bgImg_wed	=	'url(/images/frontrotate/weddings/' + bg_wed + '.gif)';
			img_wed		=	'<img id="gallery_weddings" src="/images/frontrotate/weddings/' + i_wed + '.gif"/>';
			$('#gallery_weddings')
				.fadeOut(4000,
					function() {
						$(this)
							.parent()
							.css("backgroundImage",bgImg_wed)
							.html(img_wed);
						runWeddings();
					});			
		}

$('#gallery_cabins').hide();
$('#gallery_grounds').hide();
$('#gallery_retreats').hide();
$('#gallery_weddings').hide(); 

runCabins();

runGrounds();

runRetreats();
runWeddings();


});





