// JavaScript Document

var images2 = $("#thumb-2 .imageHolderb"); // Array of images
var stopRotate2 = 'no'; // "no" for rotation, "yes" for rotation to stop
var flipspeed2 = 3.2; // Number of seconds between flips
var curImage2 = 1; // Image to start displaying - recommend to keep at 1
var numImages2 = images2.size(); // Gets the size of the array of images

if (images2.length > 1) {
	$(document).ready(function() {
		rotateImages2();
		
		images2.each(
			function(index2, domEle) {
				var curIndex2 = index2 + 1;
			}
		);
	});
}

function viewSection2(id) {
	$('#thumb-2 li').removeClass("active");
	$('#image'+id+'b').addClass("active");
	images2.each(function() {
		if($(this).is(":visible"))
		{
			$(this).fadeOut();
		}
	});
	$('#image'+id+'_holderb').fadeIn();
}

function rotateImages2() {

	if (stopRotate2 != 'yes') {
		setTimeout(function() { 
			if (curImage2 < images2.size()) {
				curImage2++;
			} else {
				curImage2 = 1;
			}
			if (stopRotate2 == 'no')
			{
				viewSection2(curImage2);
			}
			rotateImages2();
		}, flipspeed2*1000);
	}
}
