var listen;
var status;

function plr(row, file) {
		var tr = document.getElementById("tr"+row);
		listen = document.getElementById("listen");
		status = document.getElementById("status");
		status.value = "play";
		var current = document.getElementById("zz"+row);
		if(current) {
		var pl = document.getElementById("pl"+row);
		tr.className='grn';
		$('img#playbutton').attr('src', '/imgs/pl_stop.png');
		if(listen.value && listen.value != row) {
			var prev = document.getElementById("pl"+listen.value);
			var ptr = document.getElementById("tr"+listen.value);
			var ttt = document.getElementById("zz"+listen.value);
			ttt.style.display='inline';
			prev.innerHTML = '';
			ptr.className='';
		}
		current.style.display='none';
		pl.innerHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="100" height="30" id="forkplayer" align="middle"><param name="wmode" value="transparent" /><param name="flashvars" value="mp3link=http://play.audiofork.com:8080'+file+'&loop=0"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="/pl.swf" /><param name="quality" value="high" /><embed src="/pl.swf" flashvars="mp3link=http://play.audiofork.com:8080'+file+'&loop=0" quality="high"  bgcolor="cecece" width="100" height="20" name="forklayer" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
		listen.value = row;
		}
}

function stopall() {}
function pause() { }
function play() { $('img#playbutton').attr('src', '/imgs/pl_stop.png'); }

function playall() {
	var first;
	var status = document.getElementById("status");
	if(status.value=='play') { stopall(); } else {
 	$('img#playbutton').attr('src', '/imgs/pl_stop.png');
	var listen = document.getElementById("listen");
	if(listen.value) {
		 first = listen.value;
	} else { 
		first = $('#firstTrack').next().attr('id');
		first = first.substr(2, first.length);
	}
	if(first) {
	 	plr(first, '/play.php?a=listenLoad%26id='+first);
	}}
}

function stopall() {
 	$('img#playbutton').attr('src', '/imgs/pl_play.png');
	status = document.getElementById("status");
	status.value = "";
	var listen = document.getElementById("listen");
	if(listen.value) {
			var prev = document.getElementById("pl"+listen.value);
			var ttt = document.getElementById("zz"+listen.value);
			ttt.style.display='inline';
			prev.innerHTML = '';
	}
}
function nextTrack() { 
	if(listen) {
	var next;
	var next = $('#tr'+listen.value).next().attr('id');
	if(next) {
		next = next.substr(2, next.length);
	 	plr(next, '/play.php?a=listenLoad%26id='+next);
	}}
}
function prevTrack() {
	if(listen) {
	var prev;
	var prev = $('#tr'+listen.value).prev().attr('id');
	if(prev && prev!='firstTrack') {
		prev = prev.substr(2, prev.length);
		plr(prev, '/play.php?a=listenLoad%26id='+prev);
	}}
}


function checkAll(oForm, cbName, checked)
{
	for (var i=0; i < oForm[cbName].length; i++) oForm[cbName][i].checked = checked;
}


function openPlr(link, id) {
	link = 'http://play.audiofork.com/playlist/' + link;
	window.open(link, id, 'width=400,height=175, location=no, resizable=no, scrollbars=no');
}