var type = "IE";	//Variable used to hold the browser name
BrowserSniffer();

function BrowserSniffer() {
	if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";		//Opera
	else if (document.all) type="IE";								//Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="NN";								//Netscape Communicator 4
	else if (!document.all && document.getElementById) type="MO";					//Mozila e.g. Netscape 6 upwards
	else type = "IE";		//I assume it will not get here
}

function ShowLayer(id, action){
	if (type=="IE") eval("document.all." + id + ".style.visibility='" + action + "'");
	if (type=="NN") eval("document." + id + ".visibility='" + action + "'");
	if (type=="MO" || type=="OP")
	eval("document.getElementById('" + id + "').style.visibility='" + action + "'");
}

function changeImage(id){
	document.getElementById('mainimage').src='files/alt1_'+ thumbnails[((thumbIndex*3)+parseInt(id))];
}
 
function changeThumbs(delta){
	thumbIndex = thumbIndex+delta;
	if(((thumbIndex)*3)<thumbnails.length){
		ShowLayer('thumb0', 'visible');
		document.getElementById('thumb0').src='files/alt2_'+thumbnails[(thumbIndex)*3];
	}
	else{
		ShowLayer('thumb0', 'hidden');
	}
	if(((thumbIndex)*3)+1<thumbnails.length){
		ShowLayer('thumb1', 'visible');
		document.getElementById('thumb1').src='files/alt2_'+thumbnails[((thumbIndex)*3)+1];
	}
	else{
		ShowLayer('thumb1', 'hidden');
	}
	if(((thumbIndex)*3)+2<thumbnails.length){
		ShowLayer('thumb2', 'visible');
		document.getElementById('thumb2').src='files/alt2_'+thumbnails[((thumbIndex)*3)+2];
	}
	else{
		ShowLayer('thumb2', 'hidden');
	}
	
	//
	if(thumbIndex>0){
		ShowLayer('thumbpagingleft', 'visible');
	}
	else{
		ShowLayer('thumbpagingleft', 'hidden');
	}
	if(((thumbIndex*3)+3)>=thumbnails.length){
		ShowLayer('thumbpagingright', 'hidden');
	}
	else{
		ShowLayer('thumbpagingright', 'visible');
	}
	
}