var flashArray = new Array();
var firstTime = true;

$(document).ready(function() {

// generate an embed tag for each flash slide item
// increment slides, skip id's for non flash items
      // initialize scrollable together with the autoscroll plugin
    	$("#scroller").scrollable({easing: 'easeOutQuint', speed: 2000, circular: true, mousewheel: false, onSeek: function(event, i) {			
			
			/* no need to make a call to play the first time as the embed includes play: true ;*/
			if(firstTime == true){
				firstTime = false;
			}else{
			 playFlash(i);
			}
		}
		
		/* this part causes autoscroll*/
		}).navigator().autoscroll({
		interval: 5000		
	} );

});


function playFlash(slideID){
// this function tells flash to play the animation once the slide loads
	var slide_id = parseInt(slideID);
	
	for (var i=0; i< flashArray.length; i++){
	
		flash_content = $("#scroller #flashContent"+i)
	
		if(flash_content.size()) {
		
		// detect if the slide is flash content
	
			if(i == slide_id){
			// this slide is the current slide, play it
				flashArray[slide_id].flash(
					function() {
						this.GotoFrame(0);
						this.Play();
					}
				);
				
			}else{
				
			//make sure the other slides are off
				flashArray[i].flash(
					function() {
						this.GotoFrame(0);
						this.StopPlay();
						}
				);
		
			}
		
		}
	}
}
