var imageList = new Array();
var imageCounter = 0;

/**
* Changes the image called 'mainImage' on the page to the next or previous element in the array 'imageList'
* if the array bounds are exceeded it will wrap
* @param direction is either a positive or negative integer indicating direction of movement
*/
function changeImage(direction) {
    imageCounter+=direction;
    if (imageCounter < 0) {
	imageCounter = imageList.length - 1;
    }
    if (imageCounter > imageList.length - 1) {
	imageCounter = 0;
    }
    document.mainImage.src = imageList[imageCounter];
    
    /* Elements specific to Jappy and Miachika Pages */
    if (imageList[imageCounter] == "images/residential/jappy-2.jpg") {
	document.subImage.src = "images/residential/jappy-2a.jpg";
	document.subImage.style.display="block";
	document.getElementById('leftPanelFootNote').innerHTML="<span class=smallPrint>After</span>";
	document.getElementById('rightPanelFootNote').innerHTML="<span class=smallPrint>Before</span>";
    } else if (imageList[imageCounter] == "images/residential/miachika-2.jpg") {
	document.subImage.src = "images/residential/miachika-2a.jpg";
	document.subImage.style.display="block";
    } else {
	document.subImage.style.display="none";
	/*document.subImage.src = "";*/
	document.getElementById('leftPanelFootNote').innerHTML="";
	document.getElementById('rightPanelFootNote').innerHTML="";
    }
}

/*
* Adds an image to the 'imageList' array
* takes any number of arguments
*/
function addImage() {
    for (var i=0; i < arguments.length; i++) {
	imageList.push(arguments[i]);
    }
}

/**
* Clears the imageList array and sets the array entry point to 0
*/
function initImgList() {
    imageList = new Array();
    imageCounter = 0;
}


