function play_story (new_story)
{
	var ele_in;
	var ele_out;
	var idx_in;
	var idx_out;
	
	var old_story;
	
	var container = document.getElementById ('rotator');
			
	total_story = container.total_story;
	old_story = container.active_story;

	if (old_story)
	{
		if ((ele_in = document.getElementById ('story' + new_story)) &&
			(ele_out= document.getElementById ('story' + old_story)))
		{
			fade_out (ele_out.id);
			fade_in (ele_in.id);
			
			idx_in = document.getElementById ('index' + new_story);
			idx_out = document.getElementById ('index' + old_story);

			idx_in.className = "rotator-set";
			idx_out.className = "";
			
		}
	}
	else {

		//alert(ele_in);
		if (ele_in = document.getElementById ('story' + new_story))
		{
			fade_in(ele_in.id);
			
			idx_in = document.getElementById ('index' + new_story);
			idx_in.className = "rotator-set";
			
			if (total_story > 1)
			{
			    story_playing = window.setInterval ("advance_story(1);", 5000);
			    container.playing = story_playing;
			}
		}
	}
	
	container.active_story = new_story;
}

function advance_story (advance)
{
	var container = document.getElementById ('rotator');

	total_story = container.total_story;
	old_story = container.active_story;
	
	old_story += advance;

	if (old_story > total_story)
	{
		old_story = 1;
	}
	if (old_story < 1)
	{
		old_story = total_story;
	}
	
	
	play_story (old_story);
}
	
function play_pause ()
{
	var container = document.getElementById ('rotator');

	if (container.playing != 0)
	{
		clearInterval (container.playing);

		document.getElementById('play_pause').style.display = "none";
		//play_pause.style.display = "none";

		document.getElementById('play_now').style.display = "";
		//play_pause;
		
		container.playing = 0;
	} 
	else
	{
		container.playing = window.setInterval ("advance_story(1);", 5000);

		document.getElementById('play_pause').style.display = "";
		//play_pause.style.display = "";

		document.getElementById('play_now').style.display = "none";
		//play_pause.style.display = "none";
	} 
}
