var a = 0, finished = false;			
moveSlide = function(target,speed,first){
	var firstOne = $(target+':first')
	var currentID = firstOne.attr('id');		
	// Let's figure out wether or not we can continue the recursion			
	if ((finished == false) || (finished == true && first != currentID)) {
		firstOne.animate({marginTop: '-200px'}, speed, 'linear', function(){
			$(this).css('marginTop','0px');
			$(target).parent().append(this);
		});
	} 
}



$(document).ready(function(){
	  //Build Bubble Machines with the Bubble Engine ------------------------
	  SoapBubbleMachineNumber1 = $('fn').BubbleEngine({
	    particleSizeMin:            10,
	    particleSizeMax:            50,
	    particleSourceX:            $(window).width()/2 - 30,
	    particleSourceY:            40,
	    particleAnimationDuration:  100,
	    particleDirection:          'center',
	    particleAnimationDuration:  0,
	    particleAnimationVariance:  300,
	    particleScatteringX:        1,
	    particleScatteringY:        1,
	    imgSource:                  'http://jjsalem.com.s118249.gridserver.com/images/sparkle.png',
	    gravity:                    -100
	  });
        
    // Animation stuff    
		leftFirst = $('.left');
		leftFirst2 = $('.left-2');
		rightFirst = $('.right');
		rightFirst2 = $('.right-2');
		centerFirst = $('.center-box');
		setTimeout(function() {	
			leftFirst.show(600 + Math.floor(Math.random()*2400));
		}, Math.floor(Math.random()*1400));	
							
		setTimeout(function() {	
			leftFirst2.show(600 + Math.floor(Math.random()*2400));
		}, Math.floor(Math.random()*1400));	

		setTimeout(function() {	
			centerFirst.show(600 + Math.floor(Math.random()*2400));
		}, Math.floor(Math.random()*300));	
					
		setTimeout(function() {	
			rightFirst.show(600 + Math.floor(Math.random()*2400));
		}, Math.floor(Math.random()*1400));	
		
		setTimeout(function() {	
			rightFirst2.show(600 + Math.floor(Math.random()*2400));
		}, Math.floor(Math.random()*1400));	
		
		setTimeout(function() {	
			SoapBubbleMachineNumber1.addBubbles(15);
		}, 3000);	
});
