glow.ready(function() {

	var step = 1;
	//var numberOfImages = 11;
	//var imageId = 'home';		
		
		var background = glow.dom.get('.slideshow-bg');
		var foreground = glow.dom.get('img.slideshow-pic');		
		var thisFrame = 1;
		var thisFrame2 = 3;
		
		function anim() {		
			if (step < numberOfImages) {
				step++;
			} else {
				step=1;
			}
			
			var nextImage = 'images/'+imageId+(step)+'.gif';
			
			previousFrame = thisFrame;
			
			thisFrame = (thisFrame == 0) ? 1 : 0;
			
			glow.dom.get('#frame'+thisFrame).attr('src', nextImage);
			glow.anim.fadeIn('#frame'+thisFrame, 0.2);
			glow.anim.fadeOut('#frame'+previousFrame, 0.2);
			setTimeout(anim, 5000);			
		}
		
		function anim2() {		
			if (step < numberOfImages) {
				step++;
			} else {
				step=1;
			}
			
			var nextImage = 'images/'+imageId+(step)+'.gif';
			
			previousFrame = thisFrame2;
			
			thisFrame2 = (thisFrame2 == 2) ? 3 : 2;
			
			glow.dom.get('#frame'+thisFrame2).attr('src', nextImage);
			glow.anim.fadeIn('#frame'+thisFrame2, 0.2);
			glow.anim.fadeOut('#frame'+previousFrame, 0.2);
			setTimeout(anim2, 5000);			
		}
	
	glow.anim.fadeOut('#frame0', 0.1);
	glow.anim.fadeOut('#frame2', 0.1);
	
	setTimeout(anim, 5000);
	setTimeout(anim2, 5000);
	

});