var settings={refresh:59000,progress_bar_fade:1000,entry_resize_speed:150,entry_fade_out:150,entry_fade_in:450};$(document).ready(function(){initBillboard();$('.progress-bar').fadeIn(settings.progress_bar_fade,updateTracks);});function updateTracks(){$.getJSON('/json/tracks',function(data){if(data){$.each(data.tracks,function(i,track){var li='';if(track){li+='<img alt="'+track.artist+' '+track.name+'" class="artwork" src="/track/artwork/'+track.id+'" />';li+='<span class="artist">'+track.artist+'</span>';li+='<span class="track">'+track.name+'</span>';li+='<a class="vote button" href="/track/vote/'+track.id+'" target="_blank">&nbsp;</a>';li+='<a class="buy button" href="/track/buy/'+track.id+'" target="_blank">&nbsp;</a>';}
else{li+='<span class="artist">&mdash;</span>';li+='<span class="track">-</span>';}
li+='<div class="tweets"></div>';$('.entry:eq('+i+') .entry-content').animate({opacity:1},i*settings.entry_fade_out,function(){$(this).parent().css('height',34).data('trackid',track?track.id:0);$(this).animate({opacity:0},settings.entry_fade_out,function(){$(this).html(li).animate({opacity:1},settings.entry_fade_in);});});});}
$('.progress-bar-status').fadeOut(settings.progress_bar_fade,function(){$(this).css({width:0}).show().animate({width:960},settings.refresh,'linear',updateTracks);});});}
function initBillboard(){$('.entry').mouseenter(function(){$(this).stop(true).animate({height:'68'},settings.entry_resize_speed,function(){$(this).css({overflow:'visible'});});$(this).find('.artwork').stop(true).animate({height:68,width:68},settings.entry_resize_speed);$(this).find('.artist, .track').stop(true).animate({left:119},settings.entry_resize_speed);$(this).find('.tweets').stop(true).animate({left:119,opacity:1},settings.entry_resize_speed);var entry=$(this);var tweets=$(this).find('.tweets');if($(this).data('trackid')>0&&tweets.html().length==0){$(this).oneTime(300,function(){$.getJSON('/json/tweets/'+$(this).data('trackid'),function(data){var th='';$.each(data.tweets,function(i,tweet){var div='<div class="tweet">';div+='<a href="http://twitter.com/'+tweet.from_user+'/status/'+tweet.id+'" target="_blank"><img alt="'+tweet.from_user+'" src="'+tweet.profile_image_url+'" /></a>';div+='<div class="popup">';div+='<div class="popup-top"></div>';div+='<div class="popup-content">';div+='<img class="float-left" alt="'+tweet.from_user+'" src="'+tweet.profile_image_url+'" />';div+='<div class="text">';div+='<h3>'+tweet.from_user+'</h3>';div+='<small>'+tweet.tweeted_ago+' via Twitter</small>';div+='</div>';div+='</div>';div+='<div class="popup-bottom"></div>';div+='</div>';div+='</div>';th+=div;});tweets.html(th);if(entry.height()==68){tweets.hide().fadeIn(settings.entry_fade_in);}});});}}).mouseleave(function(){$(this).stopTime();$(this).stop(true).animate({height:'34'},settings.entry_resize_speed);$(this).find('.artwork').stop(true).animate({height:34,width:34},settings.entry_resize_speed);$(this).find('.artist, .track').stop(true).animate({left:85},settings.entry_resize_speed);$(this).find('.tweets').stop(true).animate({left:85,opacity:0},settings.entry_resize_speed);});}
