// control display of images on main page
function imageFlipInit() {

	html =  '<a id="leftarrow" class="disabled" ';
	html += 'onclick="flipImage(currentIndex--, imageNames, -1);">&lt;</a>&nbsp;&nbsp;';
	html += '<a id="rightarrow" class="enabled" ';
	html += 'onclick="javascript:flipImage(currentIndex++, imageNames, 1);" ';
	html += 'title="next">&gt;</a>';
	document.getElementById('imgfoot').innerHTML = html;
}

function setArrow(state,id) {

	shift='0';
	title='';
	
	if (id=='rightarrow') {
		title='next';
	}
	
	if (id=='leftarrow') {
		title='previous';
	}	

//	flipFunctionCall='javascript:flipImage(currentIndex, imageNames, '+shift+')';


	if (state==0) {
		document.getElementById(id).className="disabled";
		document.getElementById(id).title="";
	}
	
	if (state==1) {
		document.getElementById(id).className="enabled";
		document.getElementById(id).title=title;		
	}
}


function flipImage(ci, images, shift) {

	if (shift==1) {
		if (ci<(images.length-1)) {	// if we're not on the last image
			document.getElementById('mainimage').src=images[++ci];
			if (ci>=images.length-1) { // if we're now at the end
				setArrow(0,'rightarrow');
			}
			if (ci>0) {			// if we're past the first image
				setArrow(1,'leftarrow');
			}	
		}
	}

	if (shift==-1) {
		if (ci>0) {		// if we're not at the first image
			document.getElementById('mainimage').src=images[--ci];
			if (ci<=0) {  // if we're now at first image
				setArrow(0,'leftarrow');
			}
			if (ci<images.length-1) {  // if we're not at the last image any more
				setArrow(1,'rightarrow');
			}	
		}	
	}	
}

var imageNames = new Array();
imageNames[0] = "images/b.gif";
imageNames[1] = "images/r3pps.gif";
imageNames[2] = "images/ff2.jpg";
imageNames[3] = "images/ff1.jpg";
imageNames[4] = "images/rws1.gif";
imageNames[5] = "images/rws2.gif";
imageNames[6] = "images/circles5.gif";
imageNames[7] = "images/circles2.gif";
imageNames[8] = "images/o_re.gif";
imageNames[9] = "images/o_im.gif";
imageNames[10] = "images/s_re.gif";
imageNames[11] = "images/s_im.gif";
imageNames[12] = "images/tower.jpg";
imageNames[13] = "images/circles6.gif";
currentIndex = 0;
