/* Javascript file for Lithics.html */
/* by CharlesIT			*/
/* slideshow of selected images	*/

var imagespeed= 20; 
var topopacity= 100; 
var baseopacity= 1; 
var browserdetect= new Object();
var imgobj= new Object();
var highlighting = new Object();
function slowhigh(obectInp)
	{ 
	cleartimer();
	imgobj=obectInp;
	browserdetect=obectInp.filters? "ie" : typeof obectInp.style.MozOpacity=="string"? "mozilla" : ""; 
	instantset(baseopacity);
	highlighting= setInterval("gradualfade(imgobj);", imagespeed);
	}
function slowlow(obectInp)
	{ 
	cleartimer();
	imgobj=obectInp;
	instantset(topopacity);
	highlighting= setInterval("gradualdim(imgobj);", imagespeed);
	} 
function instantset(degree)
	{
	if (browserdetect=="mozilla")
		{ imgobj.style.MozOpacity=degree/100; }
	else if (browserdetect=="ie")
		{ imgobj.filters.alpha.opacity=degree; }
	}

function cleartimer(){
	if (window.highlighting) 
		{ clearInterval(highlighting); }
	}

function gradualfade(gurnard)
	{
	if (browserdetect=="mozilla" && gurnard.style.MozOpacity<1)
		{ gurnard.style.MozOpacity=Math.min(parseFloat(gurnard.style.MozOpacity)+0.02, 0.99); }
	else if (browserdetect=="ie" && gurnard.filters.alpha.opacity<100)
		{ gurnard.filters.alpha.opacity+= 2; }
	else if (window.highlighting)
		{ cleartimer(); }
	}

function gradualdim(gurnard)
	{
	if (browserdetect=="mozilla" && gurnard.style.MozOpacity > 0.02)
		{ gurnard.style.MozOpacity=Math.max(parseFloat(gurnard.style.MozOpacity)-0.02, 0.02); }
	else if (browserdetect=="ie" && gurnard.filters.alpha.opacity > 2)
		{ gurnard.filters.alpha.opacity-= 2; }
	else if (window.highlighting)
		{ cleartimer(); }
	} 

var pictures = new Array(); 	
	pictures[1] = new Image();  
	pictures[2] = new Image(); 
	pictures[3] = new Image(); 
	pictures[4] = new Image();
	pictures[5] = new Image(); 

function loadPics() 
	{ 
	pictures[1].src = 'pics/OP-8.jpg'; 
	pictures[2].src = 'pics/OP-7.jpg'
	pictures[3].src = 'pics/OP-6.jpg'; 
	pictures[4].src = 'pics/OP-4.jpg';
	pictures[5].src = 'pics/OP-5.jpg'; 
//	pictures[6].src = 'pics/OP-1.jpg'; 
	} 

var numberpics= 5;
var indexpic= 1; 
function changePic() 
	{ 
	var tapir= document.getElementById("bgpic"); 
	tapir.src= pictures[indexpic].src; 
	tapir.style.visibility="visible"; 
	slowhigh(tapir); 
	setTimeout(function(){ slowlow(tapir); }, 7000); 
	setTimeout(function(){ tapir.style.visibility="hidden"; }, 8500); 
	indexpic++; if(indexpic > numberpics) { indexpic= 1; } 
	} 

function starte() 
	{ 
	loadPics(); 
	changePic(); 
	setInterval(function(){ changePic(); }, 15000); 
	} 

