$(function(){

loadNowPlaying();
//setTimeout(function() { loadPrevPlaying(); }, 10000);

$('button').button();
$('.listenbuttontop, .listenbutton').button({ icons: { primary: "ui-icon-play" } });
$('.listenextbutton').button({ icons: { primary: "ui-icon-extlink" } });

// SET ROUND CORNERS

$('#singlecontent div, #content div[class="shadow"], #rightcontent div').addClass('ui-corner-all');
if ($.browser.msie) {
//$('#singlecontent div, #content div[class="shadow"], #rightcontent div').boxShadow(0, 0, 5, "#000");
}


});

function setCookie(c_name,value,exdays)
 {
 var exdate=new Date();
 exdate.setDate(exdate.getDate() + exdays);
 var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
 document.cookie=c_name + "=" + c_value;
 }
 
 function encode_utf8( s )
{
  return unescape( encodeURIComponent( s ) );
}

function loadNowPlaying() {
	$.get("./includes/playlist.php", { show: 'current' }, function(data){
		if(data != $('#nowplaying').text()) {
		$('#nowplaying').hide('slide', { direction: 'up' }, 500, function() {
		$('#nowplaying').html(data);
		$('#nowplaying').show('slide', { direction: 'down' }, 500);
		
		setCookie('playingnow',encode_utf8(data),1);
		
		});
		}
	var reload = setTimeout(function() { loadPrevPlaying() }, 10000);		
	});

}

function loadPrevPlaying() {
	$.get("./includes/playlist.php", { show: 'previous' }, function(data){
		if(data != $('#nowplaying').text()) {
		$('#nowplaying').hide('slide', { direction: 'up' }, 500, function() {
		$('#nowplaying').html(data);
		$('#nowplaying').show('slide', { direction: 'down' }, 500);
		});
		}
	var reload = setTimeout(function() { loadNowPlaying() }, 5000);		
	});

}

function openPlayer() {

//window.open('http://www.live365.com/cgi-bin/mini.cgi?membername=westernsaloon&clientType&playlist&odatrack&odapos&tm=1190296855203', null, 'width=770,height=265,status=yes,toolbar=no,menubar=no,location=no');
window.open('http://www.live365.com/cgi-bin/mini.cgi?membername=westernsaloon&clientType=&playlist=&odatrack=&odapos=&tm=1190296855203');

}
