/**
 * Used by the homepage to rotate the Case Studies Thumbnails
 * and associated text.  Clicking an img or txt links to the chosen case study page.
 */

//-----------------------------------------------------------------------------
// Assemble the HTML for the thumbnails
//-----------------------------------------------------------------------------
function buildTags()
{
	// If we've gone past the end of our arrays, reset the index to 0.
	if ( index >= iCaseStudyCount )
	{
		index = 0;
	}
	
	// Build the HTML to display the appropriate thumbnail and text
	var	strHTML  = '<a href="' + urlArray[index] + '">';
		strHTML += '<img id="ThumbImg" src="' + thumbArray[index].src + '" width="190" height="137" />';
		strHTML += '</a><br />';
		strHTML += txtArray[index];
		strHTML += '<div class="ThumbTxt">';
	
	// Add the "1234" links below the thumb
	for ( i = 0; i < iCaseStudyCount; i++ )
	{
		strHTML += '<a href="' + urlArray[i] + '"';
		
		// Make the number that refers to the currently displayed case study thumbnail, bold
		if ( i == index )
		{
			strHTML += ' id="BoldThumbLink"';
		}
		
		strHTML += ' class="ThumbLinks">' + ( i + 1 ) + '</a>&nbsp;&nbsp;';
	}
	
	strHTML += '</div>';
	
	// Increment the arrays' index.
	index++;
	
	return strHTML;
}

//-----------------------------------------------------------------------------
// Swap out the current img/txt for the next
//-----------------------------------------------------------------------------
function rotate()
{
	// Update the html
	document.getElementById( "Thumbs" ).innerHTML = buildTags();
}

// Calls the rotate() function every 20 seconds
var rotationTimer = window.setInterval( "rotate()", 20000 );
