function hide_block(block)
{
	if ($(block).getStyle('display') != 'none') new Effect.SwitchOff(block);
}

function show_block(block)
{
	if ($(block).getStyle('display') == 'none')	new Effect.BlindDown(block);					
}

function err(t)
{
	alert('Error ' + t.status + ' -- ' + t.statusText);
}

var collection;
var index = 0;

document.observe('dom:loaded',function()
{
	$$('a.foto').each(function(el)
	{
		el.writeAttribute('rel','lightbox');
	});
	
	collection = $$('img.PL_item');
	if(collection.length > 1)
	{
		collection.each(function(el)
		{
			el.setStyle('display: none');
		});
		new PeriodicalExecuter(__rotate,4);
		collection.first().setStyle('display: inline');
	}
});

document.observe('dom:loaded',function()
{
    $('fannclose').observe('click',function(ev)
    {
	ev.stop();
	new Ajax.Request(application_root+'ajax/fannclose',
	{
	   onComplete: function()
	   {
	       $('fannounce').hide();
	   }
	});
    });
});

function __rotate()
{
	new Effect.Fade(collection[index], { duration: 1 } );
	if(index == collection.length - 1) index = 0; else index++;
	new Effect.Appear(collection[index], { duration: 1 } );
}
