jQuery(document).ready(function ($) {
  $('.listen-now').click(function(){
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open('/player.htm', '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=340,height=340');");
  });
  
  $('#now-playing-name').map(function(){
    var el = $(this);
    
    var update = function(){

//alert("/cidg_fm.xml?" + new Date().toString());
	  $.ajax({
		type: "GET",
		url: "/cidg_fm.xml",
		dataType: "xml",
         cache: false,
		success: function(xml) {
		  xml = $(xml);
		  var artist = xml.find('Artist').text();
		  var song = xml.find('SongTitle').text();
		  if(artist && song) {
		  el.html(song + ' by ' + artist);
		  }else{
		  el.html(song);
		  }
		}
	  });
	  
	  setTimeout(update,30000);
    }
    
    update();
    
  });
});
