var slideshow = {
	totalSlideCount: 3, currSlide: 1, nextSlide: 2, timer: {},
	wait: 8000, animDuration: 1000, lastNavToTime: new Date(),
	init: function() {
		var t = slideshow;
		t.timer.nextAnim = setTimeout('slideshow.fade(1,2)',t.wait);
	},
	fade: function(from, to) {
		var t = slideshow;
		t.timer.fadeIn  = setTimeout(function(){$('#slide_'+from).fadeOut(t.animDuration);},100);
		t.timer.fadeOut = setTimeout(function(){$('#slide_'+to).fadeIn(t.animDuration);},90);
		$('#slide_'+from).css('zIndex', '1');
		$('#slide_'+to).css('zIndex', '2');
		t.currSlide = to;
		t.nextSlide = t.currSlide+1;
		if (t.nextSlide > t.totalSlideCount) t.nextSlide = 1;
		t.timer.nextAnim = setTimeout(function(){t.fade(t.currSlide,t.nextSlide);},t.wait);
	},
	navTo: function(idx) {
		var t = slideshow;
		clearTimeout(t.timer.nextAnim);
		clearTimeout(t.timer.fadeIn);
		clearTimeout(t.timer.fadeOut);
		t.fade(t.currSlide,idx);
	}
}

$(function() { slideshow.init(); });