var cmd = "getList('editor_picks','tab_1');";
var current_featured = -1;
var cnt_featured;
var featured_a;
var interval_holder;

window.onload = function() {
	runJS();
	iniIndex('editor_picks','tab_1');
	createPlaylist();
}

function iniIndex(cat,tab)
{
	setTab(tab);
	$('status').style.display = 'block';
	new Ajax.Request
	(
		'library/logic/func.php', 
		{ 
			onSuccess: function(r) {
				$('status').style.display = 'none';
				var artist_info = eval('(' + r.responseText + ')');
				$('ms').innerHTML = artist_info.data[0].ms;
				$('user_box').innerHTML = artist_info.data[0].user_box;
				$('podcast_box').innerHTML = artist_info.data[0].podcast_box;
				$('data_html').innerHTML = artist_info.data[0].list;
			},
			method: 'post', 
			parameters:'func=iniIndex&cat='+cat+'&page=0',  
			asynchronous:true
		}
	);
}

function getList(cat,tab)
{
	cmd = "getList('"+cat+"', '"+tab+"')";
	setTab(tab);
	var page = parseInt(current_page) - 1;
	$('status').style.display = 'block';
	new Ajax.Request
	(
		'library/logic/func.php', 
		{ 
			onSuccess: function(r) {
				$('status').style.display = 'none';
				var artist_info = eval('(' + r.responseText + ')');
				$('ms').innerHTML = artist_info.data[0].ms;
				$('data_html').innerHTML = artist_info.data[0].list;
			},
			method: 'post', 
			parameters:'func=getList&cat='+cat+'&page='+page,  
			asynchronous:true
		}
	);
}

function getFeatured()
{
	/*++current_featured;
	if (current_featured > cnt_featured-1) {
		current_featured = 0;	
	}*/
	current_featured = Math.floor(Math.random()*cnt_featured)
	$('featured_image').src = featured_a.artists[current_featured].photo;	
	$('featured_image').alt = featured_a.artists[current_featured].name;
	$('featured_title').innerHTML = featured_a.artists[current_featured].name;	
	$('featured_link').href = 'artist.php?id='+featured_a.artists[current_featured].id;
	artist_id = featured_a.artists[current_featured].id;
	getTop3Tracks();
}