$(function(){
	transitions = new function(){
			
		var imageCount;
		var current = -1;
		
		
		this.construct = function(images, rotationObj){
			imageCount = images;
			rPos = rotationObj;
			this.changeImage();
		}
		
		this.changeImage = function(){
			if(current == -1){
				current = current + 1;
				$("#" + rPos + " img.img_" + current).fadeIn(2000, function(){
				   $("#" + rPos).animate({left:0}, 2000, function(){
					   transitions.changeImage();
					});
			   });
			} else if((current + 1) <= imageCount){
				$("#" + rPos + " img.img_" + current).fadeOut(2000);
				current = current + 1;
				$("#" + rPos + " img.img_" + current).fadeIn(2000, function(){
				   $("#" + rPos).animate({left:0}, 2000, function(){
					   transitions.changeImage();
					});
			   });
			} else {
				$("#" + rPos + " img.img_" + current).fadeOut(2000);
				current = 0;
				$("#" + rPos + " img.img_0").fadeIn(2000, function(){
					$("#" + rPos).animate({left:0}, 2000, function(){
						transitions.changeImage();
					});
			   });
			}
		}
		
	}
	
});

