/* US Digital Partners / written for MRSI */

var counter = 0;		// Used for image calculations

var imageSrc=new Array();				// Array of image locations for the images
imageSrc[0] = "images/slide_product_development.jpg";
imageSrc[1] = "images/slide_shopperinsights.jpg";
imageSrc[2] = "images/slide_hispanic_research.jpg";

var pic1 = new Image(0,0);
var pic2 = new Image(0,0);
var pic3 = new Image(0,0);

pic1.src = "images/slide_product_development.jpg";
pic2.src = "images/slide_shopperinsights.jpg";
pic3.src = "images/slide_hispanic_research.jpg";

var imageUrl=new Array();				// Array of URLs for the images
imageUrl[0] = "/our-solutions/product-development-research.aspx";
imageUrl[1] = "/our-solutions/consumer-insights-research.aspx";
imageUrl[2] = "/our-solutions/enfoque-hispanic-research.aspx";

var imageAlt=new Array();				// Array of ALTs for the images
imageAlt[0] = "Product Development - With over 35 years of experience, MRSI can help you understand your market and identify opportunities, develop new products and manage those products for sustained growth. Plus, we make the process easier by providing not only the research tools, but also the guidance necessary to get you actionable answers from beginning to end.";
imageAlt[1] = "Shopper Insights - Improve brand or store performance with research insights from MRSI that help you better understand and influence consumer shopping behavior";
imageAlt[2] = "Hispanic Research - With a population of over 45 million and buying power close to $1 trillion, you can't afford to miss the Hispanic market. But how do you truly connect with Hispanics? MRSI's ENFOQUE� and our in-house Hispanic research team can help you Discover your Hispanic audience, Explore how best to reach them and Grow your business among this important group.";

var autorotate = true;		// Auto rotate images
var delay = 8000;			// Time delay for the image rotation

function usdpAutorotate() {	// Change large image on a delay if autorotate is true
	if (autorotate) {
		rotate = setInterval("fadeImages('auto')",delay);
	}
}


	


function fadeImages(rotateDirection, index) {
	// Removes the selected class on the nav
	$('.toc:eq(' + counter + ')').removeClass("selected");
	
	// Control rotation
	if (rotateDirection == "next") {
		clearInterval(rotate);
		counter++;
		if (counter >= imageSrc.length) {
			counter = 0;
		}
	} else if (rotateDirection == "prev") {
		clearInterval(rotate);
		counter--;
		if (counter < 0) {
			counter = imageSrc.length - 1;
		}
	} else if (rotateDirection == "auto") {
		counter++;
		if (counter >= imageSrc.length) {
			counter = 0;
		}
	} else if (rotateDirection == "index") {
		clearInterval(rotate);
		counter = index;
	}
	
	// Fade out large image, change image, then fade back in
	$("#bigImage").fadeOut("medium", function () { 	
		
		$("#bigImage").attr("src", imageSrc[counter]);
		$("#bigImage").attr("alt", imageAlt[counter]);
		$("a#imageLink").attr("href", imageUrl[counter]);
		
		$("#bigImage").fadeIn("medium"); 
		
	});
	
	
	
	// Adds the selected class on the nav
	$('.toc:eq(' + counter + ')').addClass("selected");
}

function usdpRotateNext() {	// Change large image on a delay if autorotate is true
	fadeImages("next");
}

function usdpRotatePrev() {	// Change large image on a delay if autorotate is true
	fadeImages("prev");
}

function usdpRotateIndex(navIndex) {	// Change large image on a delay if autorotate is true
	fadeImages("index", navIndex);
}
