
function DoAlert(a) {
	alert(a);
}
curTop10 = 1;
var curTopPlay = 0;
function Top10Zoom(i,id,t,a) {
	if (curTopPlay == curTop10) return false;
	if (curTop10 != i) {
		if (curTop10 > 0) {
			document.getElementById('Top10Zoom'+curTop10).style.display='none';
		}
		curTop10 = i;
		document.getElementById('Top10Zoom'+i).style.display='';
		document.getElementById('Top10Number').innerHTML='<i>#</i>'+i;
		document.getElementById('Top10Title').innerHTML=t;
		document.getElementById('Top10Artist').innerHTML=a;
		document.getElementById('Top10Link').innerHTML='<a href="http://www.indiedarkroom.com/idr/songs/?id='+id+'" class="xoLink" style="color:#d84040;">Song Page <span style="color:#b6b6b6;">&raquo;</span></a>';
	}
}
function sendRequest(url,msgs) {
	if (window.XMLHttpRequest)
		xmlhttp = new XMLHttpRequest();
	else
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status==200) {
			document.getElementById('MSG').style.display='none';
			msg = xmlhttp.responseText;
			for (var i = 0; i < msgs.length; i++) {
				if (msg == msgs[i][0]) {
					document.getElementById('MSG').style.display='';
					document.getElementById('MSGSpace').style.display='';
					document.getElementById('MSGText').innerHTML = msgs[i][1];
				}
			}
		}
	}
	xmlhttp.open("GET",url,true);
	xmlhttp.send();
}
function Top10Favorite(s) {

	location.href="http://www.indiedarkroom.com/idr/createaccount?redirect=idr%2Fsongs%3Ffav%3D1%26id%3D"+s;

}
function Top10Share(s,share,t) {

	location.href="http://www.indiedarkroom.com/idr/createaccount?redirect=idr%2Fsongs%3Fshare%3D"+share+"%26id%3D"+s;

}
var playertemplate = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="1" height="1" id="{PLAYERNAME}" align="middle">';
playertemplate += '<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" /><param name="movie" value="http://www.indiedarkroom.com/flash/smallplay.swf" />';
playertemplate += '<param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><param name="wmode" value="transparent" /><param name="flashvars" value="{FLASHVARS}">';
playertemplate += '<embed src="http://www.indiedarkroom.com/flash/smallplay.swf" quality="high" bgcolor="#ffffff" width="1" height="1" name="{PLAYERNAME}" align="middle" allowScriptAccess="sameDomain" wmode="transparent" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" flashvars="{FLASHVARS}" />';
playertemplate += '</object>';
function RadioQuit() {
	if (navigator.appName.indexOf("Microsoft") != -1)
		window['SmallPlayer'+curTopPlay].RadioQuit();
	else
		document['SmallPlayer'+curTopPlay].RadioQuit();
}
function setVolume(v) {
	if (curTopPlay == 0) return false;
	if (navigator.appName.indexOf("Microsoft") != -1)
		window['SmallPlayer'+curTopPlay].setVolume(v/100);
	else
		document['SmallPlayer'+curTopPlay].setVolume(v/100);
}

function playTopSong(i,s) {
	if (curTopPlay > 0) {
		//RadioQuit();
		document.getElementById('SmallPlay'+curTopPlay).innerHTML = '';
		document.getElementById('Top10PlayBtn'+curTopPlay).src = 'http://www.indiedarkroom.com/images/images/top10_play.png';
	}
	if (curTopPlay != i) {
		var flashvars = 'song=' + s + '&volume=' + top.VolumeSlider.getValue();
		var playerhtml = playertemplate.replace(/{FLASHVARS}/g,flashvars).replace(/{PLAYERNAME}/g,'SmallPlayer'+i);
		curTopPlay = i;
		document.getElementById('Top10PlayBtn'+curTopPlay).src = 'http://www.indiedarkroom.com/images/images/top10_pause.png';
		document.getElementById('SmallPlay'+curTopPlay).innerHTML = playerhtml;
		PauseRadio();
	}
	else {
		ResumeRadio();
		curTopPlay = 0;
	}
}
function songFinished() {
	//RadioQuit();
	document.getElementById('SmallPlay'+curTopPlay).innerHTML = '';
	document.getElementById('Top10PlayBtn'+curTopPlay).src = 'http://www.indiedarkroom.com/images/images/top10_play.png';
	ResumeRadio();
	curTopPlay = 0;
}
function PauseRadio() {
	if (top.getRadioStatus()==1)
		top.RadioPause();
}
function ResumeRadio() {
	if (top.getRadioStatus()==1)
		top.RadioPlay();
}
function PauseLocalPlayers() {
	for (var i = 1; i <= 10; i++) {
		document.getElementById('SmallPlay'+i).innerHTML = '';
		document.getElementById('Top10PlayBtn'+i).src = 'http://www.indiedarkroom.com/images/images/top10_play.png';
	}
	curTopPlay = 0;
}

