var slideCache = new Array(100);
var divid;
var imageid;
var displaysecs;
var lcurpos = 0;
var lendpos = 0;

function addFiles(individ,inimageid,inimageFiles,indisplaySecs, runslideshow){
	imageFiles = inimageFiles;
	imageid = inimageid;
	divid = individ;
	displaysecs = indisplaySecs;
	var imageSeparator = imageFiles.indexOf(";");
	var nextImage = imageFiles.substring(0,imageSeparator);
	for (var iloop = 0; imageFiles.length > 0; iloop++){
		slideCache[iloop] = new Image;
		slideCache[iloop].src = imageFiles.substring(0,imageSeparator);
		imageFiles = imageFiles.substring(imageSeparator+1,imageFiles.length);
	}
	lendpos = iloop;
	blendimage(0,100);
	changeOpac(0);
	if (runslideshow) setTimeout("RunSlideShow()",displaysecs*1000);
}

function changeOpac(opacity, id){
	var object = document.getElementById(imageid).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function blendimage(id, millisec){
	var speed = Math.round(millisec / 10);
	var timer = 0;
	document.getElementById(divid).style.background = document.getElementById(imageid).style.backgroundImage;
	changeOpac(0);
	document.getElementById(imageid).style.background = "url(" + slideCache[id].src + ")";
	for(i = 0; i <= 100; i++){
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
		timer++;
	}
}

function RunSlideShow(){
	lcurpos++;
	if (lcurpos == lendpos) lcurpos = 0;
	changeOpac(0);
	blendimage(lcurpos,100);
	setTimeout("RunSlideShow()",displaysecs*1000);
}

function nextimage(inid, inimage){
	lcurpos = inimage;
	blendimage(lcurpos, 100);
	atags = document.getElementById('top_thing').getElementsByTagName('a');
	for(var i=0;i<atags.length;i++){
		atags[i].className = '';
	}
	document.getElementById(inid).className = 'selected';
}

function fmailhider(lhost,lil,lact) {
	if (lact=='')lact = lil + "@" + lhost;
	document.write('<a href=' + 'mail' + 'to:' + lil + '@' + lhost+ '>' + lact + '</a>');
}
