var rTimer;
var url = 'http://www.ozfm.com/ozfm/choz_fm.xml'
function loadCurrentSong()
{
	var params = '?r=' + Math.random();
	var myAjax = new Ajax.Request( url, { method: 'get', parameters: params, onComplete: getSongDetails });
}
function getSongDetails(originalRequest)
{
	var COMING_SOON = 'More Music Coming Soon';
//start test
/**
	var IMG = 'Imaging (Test)';
	var SPT = 'Commercial (Test)';
**/
	var AT2 = 'American Top 20 with Casey Kasem';
	var ATF = 'American Top 40 with Ryan Seacrest';
	var AT4 = 'American Top 40 with Ryan Seacrest';
	var MMU = 'The Much Music Top 30 Radio Countdown';
	var MMM = 'The Much More Music Radio Countdown';
	var ECD = 'The East Coast Countdown';
//end test
	try
	{
		var node = originalRequest.responseXML.documentElement.firstChild;
		var artist, title, category;
		if (node.nodeName == '#text')
		{
			node = node.nextSibling;
		}
		artist = node.attributes.getNamedItem('Artist').value;
		title = node.attributes.getNamedItem('Title').value;
		category = node.attributes.getNamedItem('Category').value;
		if (category.indexOf('ML') == 0)
		{
			$('currentSong').innerHTML = artist + ' - ' + title;
		}
//start test
		else if (category.indexOf('JIG') == 0)
		{
			$('currentSong').innerHTML = artist + ' - ' + title;
		}
		else if (category.indexOf('XMS') == 0)
		{
			$('currentSong').innerHTML = artist + ' - ' + title;
		}
/**
		else if (category.indexOf('IMG') == 0)
		{
			$('currentSong').innerHTML = IMG;
		}
		else if (category.indexOf('SPT') == 0)
		{
			$('currentSong').innerHTML = SPT;
		}
**/
//more test
		else if (category.indexOf('AT2') == 0)
		{
			$('currentSong').innerHTML = AT2;
		}
		else if (category.indexOf('ATF') == 0)
		{
			$('currentSong').innerHTML = ATF;
		}
		else if (category.indexOf('AT4') == 0)
		{
			$('currentSong').innerHTML = AT4;
		}
		else if (category.indexOf('MMU') == 0)
		{
			$('currentSong').innerHTML = MMU;
		}
		else if (category.indexOf('MMM') == 0)
		{
			$('currentSong').innerHTML = MMM;
		}
		else if (category.indexOf('ECD') == 0)
		{
			$('currentSong').innerHTML = ECD;
		}
//end test
		else
		{
			$('currentSong').innerHTML = COMING_SOON;
		}
	}
	catch(e)
	{
		$('currentSong').innerHTML = COMING_SOON;
	}
	finally
	{
		if(rTimer)
		{
			clearTimeout(rTimer);
		}
		rTimer = setTimeout('loadCurrentSong()', 5000);
	}
}
