						// Adjust this variable to set slide timing.
var slideDelay = 10000;	// 5000 milliseconds => 5 seconds for each slide.

var slideNum = 0;		// This will keep track of which image we are showing.
var timer;	 			// This is our timer variable.
var numSlides = 0;		// This will get set by the init function.

// This is the table array that describes each state of the slideshow.
var slidesArray = new Array("ssDisplaysPar",				"ssDisplaysDesc",				"monitor-family.png",		"A wide range of  standard and high definition display options",											"http://www.rosenaviation.com/index.php?categoryid=8",			"Bulkhead displays ",
							"ssCabinManagementSystemsPar",  "ssCabinManagementSystemsDesc", "PCU_2.png", 			"Integrated cabin systems sized for your aircraft application",																"http://www.rosenaviation.com/index.php?categoryid=101",			"Ultra-CMS",
							"ssMappingsystemsPar",			"ssMappingsystemsDesc",			"lx.png",			"Moving map, cabin briefing and flight information systems for fixed wing or rotorcraft applications",																"http://www.rosenaviation.com/index.php?categoryid=33	",			"LX map system",
							"ssSourcesPar",					"ssSourcesDesc",				"blu-ray.png",			"Ruggedized high definition and standard format DVD players",											"http://www.rosenaviation.com/index.php?categoryid=9",			" Blu-ray DVD player  ",
							"ssDistributionPar",			"ssDistributionDesc",			"distribution1.png",			"Audio and video amplification products",															"http://www.rosenaviation.com/index.php?categoryid=98",			"Audio and video distribution amplifiers ",
							
							"ssAccessoriesPar",				"ssAccessoriesDesc",			"hp.png",		"A variety of system enhancements, including wireless remote controls and system controllers ",	"http://www.rosenaviation.com/index.php?categoryid=36",			"Wireless Headphones" );


var slideIMGs = new Array();


// Puts the initial state of the slideshow.
function initSlideshow()
{
	if((slidesArray.length % 6) != 0)
	{
		alert("ERROR: slidesArray[] has an incorrect number of elements!");
	}
	else
	{
		var i;
		var hasError = false;
		numSlides = (slidesArray.length / 6);
		
		// Make sure the document has the specified DIV ids!
		for( i = 0; i < numSlides; i++ )
		{
			if( document.getElementById(slidesArray[i * 6]) == null )
			{
				alert("ERROR: One or more DIV IDs are invalid!");
				hasError = true;
				break;
			}
			
			if( document.getElementById("ssMainIMG") == null )
			{
				alert("ERROR: The slideshow image doesn't exist.");
				hasError = true;
			}
			else if( document.getElementById("ssIMGCaption") == null )
			{
				alert("ERROR: The image caption doesn't exist.");
				hasError = true;
			}
		}
		
		if(!hasError)
		{
			// Reset them.
			for(i=0; i < numSlides;i++)
			{
				setDescription(i, false);
			}
			
			// Preload the images.
			var preImage = new Image();
			for(i=0; i < numSlides; i++)
			{
				preImage.src = slidesArray[(i * 6) + 2];
			}
			
			// The changeImage function starts by incrementing the slide
			// number. This will start the show at slide 0.
			slideNum = -1;

			changeImage();
		}
	}
}


// Updates the page to show current slideshow elements.
function changeImage()
{
	var currentPar;
	var previousPar;
	var img;

	if(numSlides != 0)
	{
		// Update counter.
		slideNum = (slideNum + 1);

		// Reset the counter when it gets past the last item in the array.
		if( slideNum == numSlides )
			slideNum = 0;

		// Clear the previously activated paragraph.
		if( slideNum == 0 )
		{
			// If this is the first item in the array then the previous item
			// must have been the last item in the array.
			setDescription((numSlides - 1), false);
		}
		else
			setDescription(slideNum - 1, false);
		
		// Activate the next paragraph.
		setDescription(slideNum, true);

		// Set the (preloaded) image.
		img = document.getElementById('ssMainIMG');
		if( img != null )
		{
			img.src = slidesArray[(slideNum*6) + 2];
			img.className = "ssIMG";
			
			document.getElementById("ssIMGCaption").innerHTML = slidesArray[(slideNum * 6) + 5];
		}

		// Reset the timer.	
		timer=setTimeout("changeImage()",slideDelay);
	}
}


// Sets the innerHTML state of the specified DIV.
function setDescription(index, isSelected)
{
	if( isSelected )
	{
		document.getElementById(slidesArray[index * 6]).className = "ssParActive";
		document.getElementById(slidesArray[(index * 6) + 1]).innerHTML = slidesArray[(index * 6) + 3];
	}
	else
	{
		document.getElementById(slidesArray[index * 6]).className = "ssParInactive";
		document.getElementById(slidesArray[(index * 6) + 1]).innerHTML = "";
	}
}


// Sends the browser to the currently shown slideshow URL.
function gotoSlideURL(item)
{
	if( (item == slidesArray[slideNum * 6]) || (item == "ssIMGCaption") || (item == "ssMainIMG") )
	{
		// Go to the current slide.
		window.location = slidesArray[(slideNum * 6) + 4];
	}

}