var AUDIO_MAN = new Object();
AUDIO_MAN['n'] = 0;
AUDIO_MAN['last_obj'] = null;


function setupAudio(obj,url)
{
	obj.id = 'audio-' + AUDIO_MAN['n'];
	obj.url = url;
	obj.onmousedown=manAudio;
	obj.onmouseover=hoverAudio;
	obj.onmouseout=hoverAudio;

	AUDIO_MAN['n']++;
}


function hoverAudio(e)
{
	if( !this.src.match(/stop/) )
	{
		if( this.src.match(/_on/) )
			this.src = PLAYER_PATH + '/play.gif';
		else
			this.src = PLAYER_PATH + '/play_on.gif';
	}
	else
	{
		if( this.src.match(/_on/) )
			this.src = PLAYER_PATH + '/stop.gif';
		else
			this.src = PLAYER_PATH + '/stop_on.gif';
	}
}


function manAudio(e)
{
	var obj = this;
	if ( self.SONG_TO_START )
	{
		obj = document.getElementById(SONG_TO_START);
		SONG_TO_START = '';
	}
	if( AUDIO_MAN['last_obj'] != null )
	{
		document['audioman'].am_stop();
		AUDIO_MAN['last_obj'].src = PLAYER_PATH + '/play_on.gif';
	}
	if(AUDIO_MAN['last_obj'] == null || obj.id != AUDIO_MAN['last_obj'].id)
	{
		document['audioman'].am_loadSound(obj.url, true);
		document['audioman'].am_start();
		obj.src = PLAYER_PATH + '/stop.gif';
		if( AUDIO_MAN['last_obj'] != null )
		{
			AUDIO_MAN['last_obj'].src = PLAYER_PATH + '/play.gif';
		}
		AUDIO_MAN['last_obj'] = obj;
	}
	else
	{
		AUDIO_MAN['last_obj'] = null;
	}
}

