// Homepage Switch
function homepageSwitch(picURL, position, imgArray) {
	document.getElementById('homepage').style.backgroundImage = 'url('+picURL+')';
	homepageThumbnailBorder(position, imgArray)
	homepageText(position, imgArray);
}

function homepageText(position, imgArray) {
	// Set all other text to display: none;
	for(i = 0; i < imgArray.length; i++) {
		Hide('scroller-text'+i);
	}
	Reverse('scroller-text'+position);
}

function homepageThumbnailBorder(position, imgArray) {
	// Set all other menus to no background
	for(i = 0; i < imgArray.length; i++) {
		document.getElementById('thumbnail'+i).style.borderWidth = "0px";
	}
	// Change border color
	document.getElementById('thumbnail'+position).style.border = "1px solid #F62A9D";
	//document.getElementById('thumbnail'+position).style.paddingTop = "1px";
}

// Left and Right arrow functionality
function homepageScroller(imgArray, direction) {
	var curImage = document.getElementById('homepage').style.backgroundImage;

	for (var i=0; i < imgArray.length; i++) {
		var checkArrayVal = 'url('+imgArray[i]+')';

		if (checkArrayVal === curImage) {
			if (direction == 'forward') {
				picIndex = i + 1;
				// If at the last image, show first
				if (picIndex >= imgArray.length) {
					picIndex = 0;
				}
			} else if (direction == 'back') {
				picIndex = i - 1;
				// If at the first image, show last
				if (picIndex < 0) {
					picIndex = imgArray.length - 1;
				}
			}

			// Display new image
			homepageSwitch(imgArray[picIndex], picIndex, imgArray);

		}
	}
}

function thumbnailHighlight(d, imgArray, type) {
	var curImage = document.getElementById('homepage').style.backgroundImage;

	for (var i=0; i < imgArray.length; i++) {
		var checkArrayVal = 'url('+imgArray[i]+')';
		//alert(checkArrayVal+'\n'+curImage);
		if (checkArrayVal != curImage) {
			if (d == 'thumbnail'+i) {
				if (type == 'off') {
					thumbnailHighlightOff(d);
				}
				if (type == 'on') {
					thumbnailHighlightOn(d);
				}
			}
		}
	}
}

function thumbnailHighlightOn(d) {
	document.getElementById(d).style.borderWidth = '1px';
	document.getElementById(d).style.borderColor = '#f7289c';
	document.getElementById(d).style.width = '43px';
}

function thumbnailHighlightOff(d) {
	document.getElementById(d).style.borderWidth = '0px';
	document.getElementById(d).style.borderColor = '#f7289c';
	document.getElementById(d).style.width = '45px';
}
// END Homepage Switch
