// --------------------------
// Update current song
// --------------------------
$(document).ready(function() {
	$("#previous").hide().load("nowplaying.html?randval="+ Math.random());	
	$("#current").hide().load("nowplaying.html?randval="+ Math.random(), function () {
		$(this).fadeIn(2000);	
	});
	$("#history").hide().load("upcoming.html?randval="+ Math.random(), function() {
		$(this).fadeIn(2000);	
	});

	var interval = setInterval(function () {
		$("#previous").hide().load("nowplaying.html?randval="+ Math.random());
		var prevSong = $("#current").text();
		var newSong = $("#previous").text();
		
		if (prevSong != newSong) {
			$("#current").hide().load("nowplaying.html?randval="+ Math.random(), function() {
				$(this).fadeIn(2000)
				$("#history").hide().load("upcoming.html?randval="+ Math.random(), function() {
					$(this).fadeIn(2000);	
				});
		})
		} else {
			//do nothing!!!	
		}
	}, 10000);	
});
