document.observe('dom:loaded', function ()
{
	$('player').show(); // update('Kies je favoriete radiozender door op het logo te klikken.');

	function loadRadio (station)
	{
		new Ajax.Updater('player', 'radiozender.php',
		{
			method	: 'get',
			parameters	:
			{
				radio	: station
			},
			onCreate	: function ()
			{
				$('player').update('<img src="images/loader.gif" style="margin: 30px" />');
			}
		});

		$$('#radioStations a:not([href=#' + station + '])').invoke('fade', { to : 0.3, duration : 1 });
		$$('#radioStations a[href=#' + station + ']')[0].appear({ duration : 1 });
	}

	$$('#radioStations a').invoke('observe', 'click', function (event)
	{
		var link = event.findElement('a');
		link.blur();
		loadRadio(link.readAttribute('href').replace('#', ''));
	});

	if (window.location.hash)
	{
		loadRadio(window.location.hash.replace('#', ''));
	}
});
