$(document).ready(function() {	$(".websound").click(function() {		window.open( $(this).attr('href'),"radio-m-listen","status=0,toolbar=0,location=0,menubar=0,width=250,height=200" );		return false;	});
	$('a[rel|=external]').each( function( intIndex ){ $( this ).attr("target","_blank"); });
});

function do_web_listen(file) {	$('#playerfield').empty().append('<div>');
	$('#playerfield div').flash({
		src: '/css/mju.swf',
		width: 150,
		height: 150,
		wLiveConnect:true,
		wmode:'transparent',
		allowScriptAccess:'sameDomain',
		flashvars: { playlist: '/playlist'+file+'.mpl', auto_run: 1, repeat: 0, shuffle: 0, anti_cache: 1}
	},{ version: 8 });

}

function Reread_nowplaying() {	$.getJSON('/backend.php',{'action':'get_np'},function(data) {
		$('#nowplaying_artist').html(data.nowplaying_artist);
		$('#nowplaying_title').html(data.nowplaying_title);
		$('#nextplaying_artist').html(data.nextplaying_artist);
		$('#nextplaying_title').html(data.nextplaying_title);
		setTimeout('Reread_nowplaying()',data.readtimeout*1000);
	});
}

function StarSubmit(v) {	_gaq.push(['_trackEvent','Song Rated','Song Rated',undefined,$('#songid').val()]);	$.getJSON('/backend.php',{'action':'rate','songid':$('#songid').val(),'vote':v},function(data) {		$('#messagebox h2').eq(0).html('Оценка композиции');		$('#messagebox p').eq(0).html(data.msg);		$('#messagebox').overlay().load();
	});
}

function RequestSong() {	_gaq.push(['_trackEvent','Song Requested','Song Requested',undefined,$('#songid').val()]);
	$.getJSON('/backend.php',{'action':'request','songid':$('#songid').val()},function(data) {;
		$('#messagebox h2').eq(0).html('Заказ композиции');
		$('#messagebox p').eq(0).html(data.msg);
		$('#messagebox').overlay().load();
	});
}

function InitStars(sel,vtip) {
	$(sel).rating({
		callback: function(value){
			StarSubmit(value);
		},
		focus: function(value, link){
			var tip = $(vtip);
			tip[0].data = tip[0].data || tip.html();
			tip.html(link.title || 'value: '+value);
		},
		blur: function(value, link){
			var tip = $(vtip);
			$(vtip).html(tip[0].data || '');
		}
	});
}

