$(document).ready(function() {
  $('#scroller').moodular({
    dispTimeout: 6000,
    speed: 800
  });
  
  $("#sampleDropper").click(function(){
    $("#dropDownContainer").animate({
      height: "toggle"
    }, 1000)
  });

  playing_now_radio();

  $.getJSON("http://www.amazingtunes.com/tune_of_the_day.json?callback=?", function(json){
    $(".tuneOfTheDay .artist").prepend("<a href='" + json.creator.location.html + "'>" + json.creator.name + "</a>");
    $(".tuneOfTheDay .tune").prepend("<a href='" + json.location.html + "'>" + json.title + "</a>");
    $(".tuneOfTheDay .innerContent").prepend("<img src='" + json.image + "' />");
  });

  $.getJSON("http://www.amazingtunes.com/chart.json?callback=?", function(json){
    var entry = json.entries[0];

    $(".chart .artist").prepend("<a href='" + entry.tune.artist.locations.html + "'>" + entry.tune.artist.display_name + "</a>");
    $(".chart .tune").prepend("<a href='" + entry.tune.locations.html + "'>" + entry.tune.title + "</a>");
    $(".chart .innerContent").prepend("<img src='" + entry.tune.image + "' />");
  });
});

function playing_now_radio(){
  $.getJSON("http://www.amazingtunes.com/radio/now_playing.json?callback=?", function(json){
    $("#listenContainer .artist").empty().prepend("<a href='" + json.creator.location.html + "'>" + json.creator.name + "</a>");
    $("#listenContainer .tune").empty().prepend("<a href='" + json.location.html + "'>" + json.title + "</a>");

    $("#listenContainer .artist a").textTruncate();
    $("#listenContainer .tune a").textTruncate();
  });
}

window.setInterval("playing_now_radio()", 15000);

