

window.onDomReady(function(){ 
	$('artist').focus();

})


function getArtists()
{
	var artist = $('artist').value;

	if (artist.length > 1)
	{
		$('loader').style.display='inline';
		$('suggestions').innerHTML = '';
		$('suggestions').style.display = 'none';
		var getArtist = new Ajax('ajax.php', {postBody: 'artist=' + artist, onComplete: artistComplete});
		getArtist.request();
	}
	return false;
}
function doSearch(artist)
{
	$('artist').value = artist;
	getArtists();
}
function artistComplete(txt)
{
	$('artists').innerHTML = txt;
	$('loader').style.display='none';
	var accordionTogglers = document.getElementsByClassName('aitem');


	var accordionContents = document.getElementsByClassName('acontent');
	new Fx.Accordion(accordionTogglers, accordionContents);
	
	$('suggestions').innerHTML = '';
	$('suggestions').style.display = 'none';
}

function getSuggestions()
{
	var word = $('artist').value;
	if (word.length > 0)
	{
		var getSuggestion = new Ajax('suggestions.php', {postBody: 'word=' + word, onComplete: suggestionsComplete});
		getSuggestion.request();		
	}
	else
	{
		$('suggestions').innerHTML = '';
		$('suggestions').style.display = 'none';
	}
}

function suggestionsComplete(txt)
{
	if (txt != '')
	{
		$('suggestions').innerHTML = 	"<div id='suggestheader'>suggestions</div>" + txt;
		$('suggestions').style.display = 'block';
	}
	else
	{
		$('suggestions').innerHTML = '';
		$('suggestions').style.display = 'none';			
	}

}