var count, back, img;
var max = 4;
var time = 4;
function nextImage() {
	count = (count >= max) ? 1 : count+1;
	var loader = new Image();
	loader.onload = function() {
		if (count%2 == 1) {
			back = $(imgDivs).eq(1);
		} else {
			back = $(imgDivs).eq(0);
		}
		img  = $(back).find('img');
		if ($(img).is(":visible")) {
			//change back, fadeout front
			back.css({
				'background-image': 'url(' + this.src + ')'
			});
			img.fadeOut(1500,function() {
				setTimeout(nextImage,time*1000);
			});
		} else {
			//change img, fadein
			img.attr('src',this.src);
			img.fadeIn(1500,function() {
				setTimeout(nextImage,time*1000);
			});
		}
	}
	loader.src = '/images/home-ss/' + count + '.jpg';
}

$(document).ready(function () {
	count = 2;
	imgDivs 	= $('.logo-images .image');
	setTimeout(nextImage,time*1000);
});
