var current_frame = images_count = 0;
var lame_slider;

document.observe('dom:loaded', function()
{
	// loop thru all images and hide them
	if($("slider") != null)
	{
		lame_slider = $('slider').getElementsByTagName('li');
		for(i=0;i<lame_slider.length;i++)
			if(i!=0) lame_slider[i].style.display = 'none';
		images_count = lame_slider.length -1;
		var go = new PeriodicalExecuter(start_slideshow,4);
	}
});




function slide(direction)
{
	// hide current image
	Effect.Fade(lame_slider[current_frame],{duration: 1.8});
	if(direction == 'fw')
		if (current_frame == images_count) { current_frame = 0; } else { current_frame++; }
	else
		if (current_frame == 0) { current_frame = images_count; } else { current_frame--; }
	// and show next or previous
	Effect.Appear(lame_slider[current_frame],{duration: 1.8});
}


function start_slideshow() 
{	
	var pe = new PeriodicalExecuter(slide('fw'),4);
}