function stop_it(which_one)
{
	clearInterval(which_one);
}

function go_fade()
{
	my_interval = setInterval ('fade_it()', 2 );
}

function fade_it()
{
		which_one = document.getElementById('to_fade').value;
		actual_number = parseInt(which_one);
		next_number = actual_number + 1 > document.getElementById('how_many').value? 1 : actual_number + 1;
		itsop = document.getElementById('sub' + which_one).style.opacity;
		itsop = parseFloat(itsop);
		itsop -= 0.01;
		document.getElementById('sub' + which_one).style.opacity = itsop;
		document.getElementById('sub' + which_one).style.filter = 'alpha(opacity=' + itsop*100 + ')';
		if ((parseInt(document.getElementById('sub' + which_one).style.opacity * 100))/100 == 0)
		{
			stop_it(my_interval);
			document.getElementById('sub' + which_one).style.display = 'none';
			document.getElementById('sub' + next_number).style.display = 'block';
			document.getElementById('to_fade').value = next_number;
			my_interval2 = setInterval ('show_it()', 5 );
		}
}
function show_it()
{
		which_one = document.getElementById('to_fade').value;
		itsop = document.getElementById('sub' + which_one).style.opacity;
		itsop = parseFloat(itsop);
		itsop += 0.01;
		document.getElementById('sub' + which_one).style.opacity = itsop;
		document.getElementById('sub' + which_one).style.filter = 'alpha(opacity=' + itsop*100 + ')';
		if ((parseInt(document.getElementById('sub' + which_one).style.opacity * 100))/100 == 1)
		{
			stop_it(my_interval2);
		}
}

setInterval('go_fade()', 10000 );
