
var currentHomeFeature;                          // number of the current slide being displayed
var totalHomeFeatures;                          // total number of slides

function changeHomeFeature( selectedHomeFeature ) {
	
	currentHomeFeature = selectedHomeFeature;
	showHomeFeature();
	
}

function initHomeFeature() {

	// remove the last element from the array (it was added to control the trailing comma problem)
	homeFeatureObject.homeFeatureItems.pop();

	// populate the main content list
	var listHTMLcode = "";
	var homeFeature_itemList = document.getElementById('homeFeature_itemList');
	for( i = 0; i < homeFeatureObject.homeFeatureItems.length; i++ ) {
		listHTMLcode += '<li><a href="' + homeFeatureObject.homeFeatureItems[i].homeFeatureLink + '" onmouseover="changeHomeFeature(' + i + ')">' + homeFeatureObject.homeFeatureItems[i].homeFeatureTitle + '</a></li>';
	}
	homeFeature_itemList.innerHTML = listHTMLcode;	
	
	// initialize the slideshow with a random feature
	totalHomeFeatures = homeFeatureObject.homeFeatureItems.length;
	currentHomeFeature = Math.floor( Math.random() * totalHomeFeatures );
	showHomeFeature();
	
}

function showHomeFeature() {
	// supply the pageNav elements with the correct HTML
	var homeFeature_textArea = document.getElementById('homeFeature_text');
	var homeFeature_imageArea = document.getElementById('homeFeature_image');
	
	homeFeature_textArea.innerHTML = '<h2>' + homeFeatureObject.homeFeatureItems[currentHomeFeature].homeFeatureTitle + '</h2><p>' + homeFeatureObject.homeFeatureItems[currentHomeFeature].homeFeatureText + '</p><p><a href="' + homeFeatureObject.homeFeatureItems[currentHomeFeature].homeFeatureLink +'">more info</a></p>';
	homeFeature_imageArea.style.background = 'url(' + homeFeatureObject.homeFeatureItems[currentHomeFeature].homeFeatureImage + ') no-repeat #ffffff';
	
}

