var fout = '#sli1'; /* needed for first time script runs */
var fin; 
var arrowPos;
var timeout;

function toggle(fin, arrowPos){
	if (fin != fout) {        /* doesn't run first time through the script */
		clearTimeout(timeout);
		$(fout).fadeOut('slow');
		$(fin).fadeIn('slow');
		$('#arrow').css('left', arrowPos);
		fout = fin;
		timeout = setTimeout('toggleTimed()', 10000);
	}
}

$(document).ready(function() {
	$('#sli2').hide();
	$('#sli3').hide();
	$('#sli4').hide();
	$('#sli5').hide();
	
	timeout = setTimeout('toggleTimed()', 10000);
});

function toggleTimed() {
	if (fout == '#sli1') {
		clearTimeout(timeout);
		fin = '#sli2';
		$(fout).fadeOut('slow');
		$(fin).fadeIn('slow');
		$('#arrow').css('left', '96px'); /* sets absolute position of arrow image, passed through to arrowPos */
		fout = fin; /* sets starting deal as fade out deal */
		timeout = setTimeout('toggleTimed()', 10000);
	}
	else if (fout == '#sli2') {
		clearTimeout(timeout);
		fin = '#sli3';
		$(fout).fadeOut('slow');
		$(fin).fadeIn('slow');
		$('#arrow').css('left', '174px');
		fout = fin;
		timeout = setTimeout('toggleTimed()', 10000);
	}
	else if (fout == '#sli3') {
		clearTimeout(timeout);
		fin = '#sli4';
		$(fout).fadeOut('slow');
		$(fin).fadeIn('slow');
		$('#arrow').css('left', '250px');
		fout = fin;
		timeout = setTimeout('toggleTimed()', 10000);
	}
	else if (fout == '#sli4') {
		clearTimeout(timeout);
		fin = '#sli5';
		$(fout).fadeOut('slow');
		$(fin).fadeIn('slow');
		$('#arrow').css('left', '328px');
		fout = fin;
		timeout = setTimeout('toggleTimed()', 10000);
	}
	else if (fout == '#sli5') {
		clearTimeout(timeout);
		fin = '#sli1';
		$(fout).fadeOut('slow');
		$(fin).fadeIn('slow');
		$('#arrow').css('left', '18px');
		fout = fin;
		timeout = setTimeout('toggleTimed()', 10000);
	}
}
