// JavaScript Document
function wiggle(wigSpeed, wigHt, topP, e) {
    var $elem = $(e),wigS=wigSpeed, wigH=wigHt;    
    $elem.animate({
        top: topP
    }, wigS, function() {
        $elem.animate({
            top: wigHt
        }, wigS, function() {
            wiggle(wigS, wigH, topP, e);
        });
    });
}

function createMoreDust() {
		createDust();
	}
	
	function createDust() {
		$('.stage-dustcloud-1').delay(100).animate({bottom:'25px', left:'-75px',opacity: .35},2000,'easeInOutBounce',function(){
			$(this).animate({bottom:'50px', left:'-250px',opacity: 0},3000,'easeInOutBounce', function(){
				$(this).css({bottom:'0px', left:'0px',opacity: 0});
			});
		});
		$('.stage-dustcloud-2').delay(800).animate({bottom:'15px', left:'-95px',opacity: .25},2000,'easeInOutBounce',function(){
			$(this).animate({bottom:'50px', left:'-250px',opacity: 0},3000,'easeInOutBounce', function(){
				$(this).css({bottom:'0px', left:'0px',opacity: 0});
			});
		});
		$('.stage-dustcloud-3').delay(400).animate({bottom:'30px', left:'-95px',opacity: .45},2000,'easeInOutBounce',function(){
			$(this).animate({bottom:'50px', left:'-240px',opacity: 0},3000,'easeInOutBounce', function(){
				$(this).css({bottom:'0px', left:'0px',opacity: 0});
			});
		});
		$('.stage-dustcloud-4').delay(700).animate({bottom:'45px', left:'-100px',opacity: .30},2000,'easeInOutBounce',function(){
			$(this).animate({bottom:'50px', left:'-220px',opacity: 0},3000,'easeInOutBounce', function(){
				$(this).css({bottom:'0px', left:'0px',opacity: 0});
			});
		});
		
		$('.stage-dustcloud-5').delay(100).animate({bottom:'20px', right:'155px',opacity: .55},2000,'easeInOutBounce',function(){
			$(this).animate({bottom:'50px', right:'215px',opacity: 0},3000,'easeInOutBounce', function(){
				$(this).css({bottom:'0px', right:'100px',opacity: 0});
			});
		});
		$('.stage-dustcloud-6').delay(800).animate({bottom:'15px', right:'135px',opacity: .35},2000,'easeInOutBounce',function(){
			$(this).animate({bottom:'50px', right:'275px',opacity: 0},3000,'easeInOutBounce', function(){
				$(this).css({bottom:'0px', right:'100px',opacity: 0});
			});
		});
		$('.stage-dustcloud-7').delay(400).animate({bottom:'25px', right:'165px',opacity: .45},2000,'easeInOutBounce',function(){
			$(this).animate({bottom:'50px', right:'235px',opacity: 0},3000,'easeInOutBounce', function(){
				$(this).css({bottom:'0px', right:'100px',opacity: 0});
			});
		});
		$('.stage-dustcloud-8').delay(700).animate({bottom:'35px', right:'140px',opacity: .65},2000,'easeInOutBounce',function(){
			$(this).animate({bottom:'50px', right:'220px',opacity: 0},3000,'easeInOutBounce', function(){
				$(this).css({bottom:'0px', right:'100px',opacity: 0});
			});
		});
		//setTimeout('createMoreDust()', 5000);
	}
	
function loopStage(e) {
	if (e == true) {
	$('#stage-01a').simplyScroll({
		className: 'stage-scrolling-01a',
		speed: 5,
		autoMode: 'loop',
		pauseOnHover: false
	});
	$('#stage-01b').simplyScroll({
		className: 'stage-scrolling-01b',
		speed: 5,
		autoMode: 'loop',
		pauseOnHover: false
	});
	$('#stage-02tree').simplyScroll({
		className: 'stage-scrolling-02tree',
		speed: 4,
		autoMode: 'loop',
		pauseOnHover: false
	});
	$('#stage-02a').simplyScroll({
		className: 'stage-scrolling-02a',
		speed: 4,
		autoMode: 'loop',
		pauseOnHover: false
	});
	$('#stage-02b').simplyScroll({
		className: 'stage-scrolling-02b',
		speed: 4,
		autoMode: 'loop',
		pauseOnHover: false
	});
	$('#stage-03').simplyScroll({
		className: 'stage-scrolling-03',
		speed: 3,
		autoMode: 'loop',
		pauseOnHover: false
	});
	$('#stage-04').simplyScroll({
		className: 'stage-scrolling-04',
		speed: 2,
		autoMode: 'loop',
		pauseOnHover: false
	});
	$('#stage-04trees').simplyScroll({
		className: 'stage-scrolling-04trees',
		speed: 1,
		autoMode: 'loop',
		pauseOnHover: false
	});	
	$('#stage-04hills').simplyScroll({
		className: 'stage-scrolling-04hills',
		speed: 1,
		autoMode: 'loop',
		pauseOnHover: false
	});
	}
}
