//Image Rotator Requires jquery

// Set Image Rotation speed (in seconds)
var speed = 5;

// list images below
var images = new Array();
if (productID == "1150") { // images for product id 1150 - Sensations Lotions
	images[0] = "/Products/images/scentsations-lotions-apple-cinnamon.jpg";
	images[1] = "/Products/images/scentsations-lotions-birch-mint.jpg";
	images[2] = "/Products/images/scentsations-lotions-black-cherry.jpg";
	images[3] = "/Products/images/scentsations-lotions-black-currant.jpg";
	images[4] = "/Products/images/scentsations-lotions-citrus-green-tea.jpg";
	images[5] = "/Products/images/scentsations-lotions-cranberry.jpg";
	images[6] = "/Products/images/scentsations-lotions-cucumber-aloe.jpg";
	images[7] = "/Products/images/scentsations-lotions-honeysuckle-pink-grapefruit.jpg";
	images[8] = "/Products/images/scentsations-lotions-lavender-jojoba.jpg";
	images[9] = "/Products/images/scentsations-lotions-mango-coconut.jpg";
	images[10] = "/Products/images/scentsations-lotions-melon-jasmine.jpg";
	images[11] = "/Products/images/scentsations-lotions-peach-ginseng.jpg";
	images[12] = "/Products/images/scentsations-lotions-pear-dandelion.jpg";
	images[13] = "/Products/images/scentsations-lotions-tangerine-lemongrass.jpg";
	images[14] = "/Products/images/scentsations-lotions-vanilla-shimmer.jpg";
	images[15] = "/Products/images/scentsations-lotions-wildflower-chamomile.jpg";
} else if (productID == "1151") { // images for product id 1150 - Sensations Washes
	images[0] = "/Products/images/scentsations-washes-apple-cinnamon.jpg";
	images[1] = "/Products/images/scentsations-washes-birch-mint.jpg";
	images[2] = "/Products/images/scentsations-washes-black-cherry-nut.jpg";
	images[3] = "/Products/images/scentsations-washes-black-currant-fig.jpg";
	images[4] = "/Products/images/scentsations-washes-citrus-green-tea.jpg";
	images[5] = "/Products/images/scentsations-washes-cranberry.jpg";
	images[6] = "/Products/images/scentsations-washes-cucumber-aloe.jpg";
	images[7] = "/Products/images/scentsations-washes-honeysuckle-pink-grapefruit.jpg";
	images[8] = "/Products/images/scentsations-washes-lavender-jojoba.jpg";
	images[9] = "/Products/images/scentsations-washes-mango-coconut.jpg";
	images[10] = "/Products/images/scentsations-washes-melon-jasmine.jpg";
	images[11] = "/Products/images/scentsations-washes-peach-ginseng.jpg";
	images[12] = "/Products/images/scentsations-washes-pear-dandelion.jpg";
	images[13] = "/Products/images/scentsations-washes-tangerine-lemongrass.jpg";
	images[14] = "/Products/images/scentsations-washes-vanilla.jpg";
	images[15] = "/Products/images/scentsations-washes-wildflower-chamomile.jpg";
} else if (productID == "1142") { // images for product id 1142 - Files & Buffers
	images[0] = "/Products/images/files-buffers-hot-shot-file.jpg";
	images[1] = "/Products/images/files-buffers-blizzard-board-angle.jpg";
	images[2] = "/Products/images/files-buffers-outblock-pad-file-angle.jpg";
	images[3] = "/Products/images/files-buffers-kanga-file-angle.jpg";
	images[4] = "/Products/images/files-buffers-boomerang-pad-file-angle.jpg";
	images[5] = "/Products/images/files-buffers-koala-buffer-angle.jpg";
	images[6] = "/Products/images/files-buffers-girlfriend-buffer.jpg";
	images[7] = "/Products/images/files-buffers-glossing-buffer.jpg";
	images[8] = "/Products/images/files-buffers-glossing-block.jpg";
}

var i = 0;
var j = i + 1;
var strImg = '';
var hover = false;

function rotateImages() {
	$("#product-img" + i).fadeOut("slow");
	$("#product-img" + j).fadeIn("slow");
	if (hover == false) {
		$("#" + i).css("font-weight", "normal");
		$("#" + i).css("background-image", "none");
		$("#" + j).css("font-weight", "bold");
		$("#" + j).css("background-image", "url(/Products/images/red-arrow-rotator.gif)");
	}
	if (i < images.length - 1) {
		i++;
	} else {
		i = 0;
	}
	if (i < images.length - 1) {
		j = i + 1;
	} else {
		j = 0;
	}
	setTimeout("rotateImages()",speed * 1000);
}

function loadImages() {
	for (x = 0; x < images.length; x++) {
		strImg += '<img id="product-img' + x + '" src="' + images[x] + '" height="160" width="160" style="display:none;" />';
	}
	strImg += '<img id="product-img-hover" src="' + images[0] + '" height="160" width="160" style="display:none;" />';
}


$(document).ready(function(){

	loadImages();
	$("div#imageContainer").html(strImg);
	
	$("#product-img0").css("display", "");
	$("#0").css("font-weight", "bold");
	$("#0").css("background-image", "url(/Products/images/red-arrow-rotator.gif)");

	
	setTimeout("rotateImages()",speed * 1000);
	
	$("span.flavors").hover(
		function () { // mouseover
			hover = true;
			$("#product-img-hover").attr("src",images[this.id]);
			$("#product-img-hover").css("display", "");
			$("#" + i).css("font-weight", "normal");
			$("#" + i).css("background-image", "none");
			$(this).css("font-weight", "bold");
			$(this).css("background-image", "url(/Products/images/red-arrow-rotator.gif)");
      	}, 
      	function () { // mouseout
			for (x = 0; x < images.length; x++) {
				$("#product-img" + x).css("display", "none");
			}
			i = parseInt(this.id);
			if (i < images.length - 1) {
				j = i + 1;
			} else {
				j = 0;
			}
			$("#product-img" + i).css("display", "");
			$("#product-img-hover").css("display", "none");
			hover = false;
      	}
    );
	
});
