jQuery('document').ready(function($) {
	var currentImg = 1;
	var timing = 3000;
	
	// create the image rotator
    setInterval(function() {
    	var oCurPhoto = $('#top div.current');
    	var oNxtPhoto = oCurPhoto.next();
		if (oNxtPhoto.length == 0) oNxtPhoto = $('#top div:first');
		
		if(currentImg == 1) {
			transitionTypeOne();
		} else {
			transitionTypeTwo();
		}
		
		function transitionTypeOne() {
			oCurPhoto.removeClass('current').addClass('previous');
			oNxtPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 },1000,function() {
				oCurPhoto.removeClass('previous');
			});
			
		}
			
		function transitionTypeTwo() {
			oCurPhoto.removeClass('current').addClass('previous').animate({'margin-left':'-844px'},1000,"easeOutQuart");
			oNxtPhoto.css('margin-left','844px').addClass('current').animate({'margin-left':0},1000,"easeOutQuart",function() {
				oCurPhoto.removeClass('previous').css('margin-left',0);
			});
		}
		
    	currentImg++;
    	if(currentImg == 5) {currentImg = 1;}
    	
    }, timing);
    
});
