$(document).observe('dom:loaded', function()
{
	$$('#follow_bar a').shift().observe('click', function() 
	{ 
		new Effect.toggle('follow_content', 'blind', { duration: .5 });
	});

	marquee.parse();
	
	/*$$('.area_item a.toggler').each(function(e)
	{
		$(e).observe('click', function()
		{
			//$$('.item_wrap p').invoke('hide');
			//$(this).previous().select('p').invoke('toggle');
			var p = $(this).previous().select('p').shift();
			new Effect.toggle($(p), 'blind', { duration: 0.3 });
		});
	});*/
	
	if ($$('.verticalEvents .button').length)
	{
		$$('.verticalEvents .button').shift().observe('click', function() 
		{ 
			var margin = parseInt($$('.verticalEvents .ulWrap ul').shift().getStyle("marginTop"));
			new Effect.Morph($$('.verticalEvents .ulWrap ul').shift(), { style: 'margin-top: '+ (margin-30) + 'px', duration: 0.3});
			$$('.verticalEvents .buttonUp').invoke('show');
		});
	}
	
	if ($$('.verticalEvents .buttonUp').length)
	{
		$$('.verticalEvents .buttonUp').shift().observe('click', function() 
		{ 
			var margin = parseInt($$('.verticalEvents .ulWrap ul').shift().getStyle("marginTop"));
			new Effect.Morph($$('.verticalEvents .ulWrap ul').shift(), { style: 'margin-top: '+ (margin+30) + 'px', duration: 0.3});
		});
	}
				
	if (parseInt($$('#animation img').length) > 0)
	{
		setInterval(headerFader, 5000);
	}
});

function headerFader()
{
	var current = parseInt($('animation').readAttribute("rel"));
	var count   = parseInt($$('#animation img').length) - 1;
	var next    = current >= count ? 0 : current+1;
	var duration = 2;

	$('photo_'+next).appear({ duration: duration });
	$('photo_'+current).fade({ duration: duration });
	$('animation').writeAttribute("rel", next);
}

function initPlayer()
{
	var a = new Element('a');
	a.observe('click', function() { launchPlayer(true)} );
	a.simulate('click');
}

function launchPlayer(automated)
{
	window.open(RELATIVE_ROOT + "?page[]=player",'','width=450,height=350,left=200,top=200,resizable=no,location=no,toolbar=0,menubar=0,status=0,directories=0').blur();	
	window.focus();
}
