var sImg;
function changeOpacity(theImg,theCt){
if(theImg == null){
	theImg = sImg;
	theCt = oCt;
}
//alert(theImg)
	if(theImg.style.filters != null){
			theImg.style.filters.alpha.opacity = theCt;
			theImg.style.zIndex="2";
			//document.getElementById("cap").style.filters.alpha.opacity = theCt;
		}else if(theImg.style.opacity != null){
			theImg.style.opacity=theCt/100
			theImg.style.zIndex="2";
			//document.getElementById("cap").style.opacity=theCt/100
		}else if(theImg.style.MozOpacity != null){
			theImg.style.MozOpacity=theCt/100
			theImg.style.zIndex="2";
			//document.getElementById("cap").style.MozOpacity=theCt/100
		}else if(theImg.style.KhtmlOpacity != null){
			theImg.style.KhtmlOpacity=theCt/100
			theImg.style.zIndex="2";
			//document.getElementById("cap").style.KhtmlOpacity=theCt/100
		}
}

function getImages(){	
	setTimeout("loadImages()",1000);
}

function showSpec(m){
	var theObj = document.getElementById("ali");
	if(theObj != null){
		if(m == 1){
			theObj.style.visibility="visible";
		}else{
			theObj.style.visibility="hidden";
		}
	}
}

function loadImages(){	
	sImg = document.getElementById("viewer");
	changeOpacity(document.getElementById('obs'),80)	
	for(var i=0;i<len;i++){	
		theImgs[i] = new Image(sImgs[i][1],sImgs[i][2]);	
		theImgs[i].src = dir+sImgs[i][0];
		document.getElementById("b"+(i+1)).style.visibility="visible";		
	}
	//var imgCt = 0;
	document.getElementById("ldImgs").style.visibility="hidden";
	showImg(document.getElementById("b1"),imgCt)
	document.getElementById("viewer").style.visibility="visible";
	document.getElementById("close").style.visibility="visible";
	document.getElementById("ss").style.visibility="visible";
	//sImg.src=theImgs[0].src;
	//sImg.style.marginTop=((600-sImgs[n][2])/2)+20+"px";
}



function lightBtn(obj){
if(obj.id.indexOf("ss")>=0){
if(stopSS){
	var theObj=document.getElementById("ss");
	theObj.style.background="#FF9";	
	}
}else{
	for(var i=0;i<len;i++){		
		var theObj=document.getElementById("b"+(i+1));
		if(theObj==obj || lastSel == "b"+(i+1)){
			if(lastSel == "b"+(i+1)){
				theObj.style.background="#6FD";
			}else{
				theObj.style.background="#FF9";
			}
		}else{
				theObj.style.background="#FD6";			
		}
	}
}
}
var ssTmr;
var stopSS = true
function slideShow(){
	if(stopSS){
	var theObj=document.getElementById("ss");
	theObj.style.background="#6FD";	
	stopSS=false;
	nextImg()
	}

}

function dimBtn(obj){
if(obj.id.indexOf("ss")>=0){
	if(stopSS){obj.style.background="#FD6";}
}else{
	if(lastSel != obj.id){obj.style.background="#FD6";}
	}	
}

var imgCt = 0
function nextImg(){

	imgCt++
	if(imgCt == len){imgCt=0;}
	showImg(document.getElementById("b"+(imgCt+1)),imgCt)
	if(!stopSS){
		ssTmr = setTimeout("nextImg()",6000)
	}else{
		clearTimeout(ssTmr)
	}
	
}

var lastSel = "";
function showImg(obj,n){	
	if(stopSS){
		clearTimeout(ssTmr)
		var theObj=document.getElementById("ss");
		theObj.style.background="#FD6";	
	}
	obj.style.background="#6FD";
	if(lastSel != ""){
		var theObj=document.getElementById(lastSel);
		theObj.style.background="#FD6";
	}
	lastSel = obj.id
	sImg.src = theImgs[n].src;//newImg;
	if(!stopSS){
	changeOpacity(sImg,0)
	reduceOpacity(sImg)
	}
	sImg.style.width=sImgs[n][1]+"px";
	sImg.style.height=sImgs[n][2]+"px";
//alert(sImgs[n][2])
	sImg.style.marginTop=((480-sImgs[n][2])/2)+20+"px";
		sImg.style.marginLeft="0px";
	if(document.getElementById('captions')){
		document.getElementById('captions').innerHTML=sImgs[n][3];
	}
	imgCt = n;
	
}
var oCt = 0;
var oTmr;
function reduceOpacity(){
	oCt++
	//if(oCt==1){alert(sImg);}
	changeOpacity(sImg,oCt)
	if(oCt<100){
		
		oTmr = setTimeout("reduceOpacity()",15)
	}else{
		oCt = 0
		clearTimeout(oTmr)
		
	}
}

