// william's little slideshow thing
// acknowledgements to Mike Arice of mikeomatic.net for the basis of this crossfade effect

// in milliseconds
var wait = 5000;

var iv = 0;
function timerFade() {
	if(iv == 3) iv = 0;
	iv++;
	crossFade(iv,1);
}

var initBox = 'box1';
var currBox = initBox;
var intervalID;

function startTimer(){
	intervalID = setInterval('timerFade()',wait);
}

function crossFade(box,caller){
	var newBox = 'box' + box;
	
	var oldTriangle = 'triangle' + currBox.substring(3,4);
	var triangle = 'triangle' + box;
	if(newBox != currBox){
		$(oldTriangle).style.display = "none";
		$(triangle).style.display = "inline";

		// whether we're calling from a mouseover or a timer
		var dur;
		if(caller == 0){
			dur = '0'
		}else{
			dur = '0.5';
		}
		
		Effect.Fade(currBox, { duration:dur, from:1.0, to:0.0 });
		Effect.Appear(newBox, { duration:dur, from:0.0, to:1.0 });

		currBox = newBox;
		
		// restarts the timer so as to avoid any overly fast transitions
		clearInterval(intervalID);
		i = currBox.substring(3,4);
		startTimer();
		
	}
}
