// Rotate images

// Pre-load the images
function imageLoader() {
	// Pre-load the main content images
	for (i=0; i < contentImgArray.length; i++) {
		var myImg = new Image();
		myImg.src = "images/" + contentImgArray[i][0];
	}
	// Pre-load the navigation images
	imgArray = new Array('create_good_on.gif', 'buy_coffee_on.gif', 'get_involved_on.gif', 'shopping_cart_on.gif', 'my_account_on.gif', 'youtube_on.jpg', 'myspace_on.jpg', 'facebook_on.jpg', 'contact_us_on.gif', 'about_us_on.gif');
	for (i=0; i < imgArray.length; i++) {
		var myImg = new Image();
		myImg.src = "images/" + imgArray[i];
	}
}

function swapContentImage() {
	var setImgOn = false;
	var imageOn = document.images[contentImgArray[currentImg][1]].src;
	if (imageOn.indexOf("_on") > 0) {
		setImgOn = true;
		btn_swap(contentImgArray[currentImg][1], 'out');
	}

	if ((currentImg + 1) > (contentImgArray.length - 1)) {
		currentImg = 0;
	} else {
		currentImg = currentImg + 1;
	}
	document.getElementById("main_content_image_src").alt = contentImgArray[currentImg][2];
	document.getElementById("main_content_image_src").src = "images/" + contentImgArray[currentImg][0];
	document.getElementById("main_content_img_link").onmouseover = function(){btn_swap(contentImgArray[currentImg][1], 'over');};
	document.getElementById("main_content_img_link").onmouseout = function(){btn_swap(contentImgArray[currentImg][1], 'out');};
	document.getElementById("main_content_img_link").href = contentImgArray[currentImg][3];
	if (setImgOn == true) {
		btn_swap(contentImgArray[currentImg][1], 'over');
	}
	//setTimeout(fadeIn, 100);
	fadeIn();
}

function setContentParams() {
	document.getElementById("main_content_image_src").alt = contentImgArray[currentImg][2];
	document.getElementById("main_content_img_link").onmouseover = function(){btn_swap(contentImgArray[currentImg][1], 'over');};
	document.getElementById("main_content_img_link").onmouseout = function(){btn_swap(contentImgArray[currentImg][1], 'out');};
	document.getElementById("main_content_img_link").href = contentImgArray[currentImg][3];
	imageLoader();

	// Wait a while, then start the fade out
	setTimeout(fadeOut, 25000);
	// Make sure the current opacity is 100
	currentOpac('main_content_image', 100, 100);
}

function fadeOut() {
	// Fade the main content image to 0 in 1000 msec
	currentOpac('main_content_image', 0, 1000);
	// Swap the images after 1000 msec (when the fade is complete)
	setTimeout(swapContentImage, 1000);
}
function fadeIn() {
	// Fade the main content image to 100 in 1000 msec
	currentOpac('main_content_image', 100, 1000);
	// Wait a while, then start the next fade out
	setTimeout(fadeOut, 25000);	
}
