var nowPlaying={'songs':[],'displayTimers':[],'checkTimer':false}
function displayNowPlaying(key){var siteName=nowPlaying.site;if(nowPlaying.songs.length<2){return false;}
just_played=nowPlaying.songs[key-1]
now_playing=nowPlaying.songs[key]
coming_up=[]
for(i=key+1;i<nowPlaying.songs.length;i++){coming_up.push(nowPlaying.songs[i]);}
if(siteName=='4kq'||siteName=='gold1043'||siteName=='wsfm'){html='<dt>Now Playing</dt>';html+='<dd class="first"><span>'+now_playing.title+' - '+now_playing.artist+'</span></dd>';html+='<dt>Just Played</dt>';html+='<dd class="first"><span>'+just_played.title+' - '+just_played.artist+'</span></dd>';if(coming_up.length>0){html+='<dt>Coming Up</dt>';jQuery.each(coming_up,function(i,song){if(i<3){cls=(i==0?'first':'');html+='<dd class="'+cls+'"><span>'+song.title+' - '+song.artist+'</span></dd>';};});};$("#module_listenLive_flashHeader").hover(function(){$("#module_listenLive_flashHeader #speakerStatic").hide();$("#module_listenLive_flashHeader #speakerAnim").show();},function(){$("#module_listenLive_flashHeader #speakerStatic").show();$("#module_listenLive_flashHeader #speakerAnim").hide();});}else{html='<dt><span>Now Playing:</span></dt>';html+='<dd><span>'+now_playing.title+' - '+now_playing.artist+'</span></dd>';html+='<dt class="sep"><span>Just Played:</span></dt>';html+='<dd class="sep"><span>'+just_played.title+' - '+just_played.artist+'</span></dd>';if(coming_up.length>0){html+='<dt class="sep"><span>Coming Up:</span></dt>';jQuery.each(coming_up,function(i,song){if(i<3){cls=(i==0?'sep':'');html+='<dd class="'+cls+'"><span>'+song.title+' - '+song.artist+'</span></dd>';};});};};$('.now-playing .data').html('<dl>'+html+'</dl><br style="clear: both; font-size: 0; padding: 0; margin: 0; height: 0;">')}
function checkNowPlaying(){$.getJSON('/json/nowplaying/'+nowPlaying.station+'/',function(data){jQuery.each(nowPlaying.displayTimers,function(){clearTimeout(this);});nowPlaying.displayTimers=[];clearTimeout(nowPlaying.checkTimer);nowPlaying.checkTimer=false;nowPlaying.songs=data.songs;jQuery.each(nowPlaying.songs,function(i,song){if(song.offset>0){if(!nowPlaying.checkTimer){displayNowPlaying(i-1);nowPlaying.checkTimer=setTimeout('checkNowPlaying()',(song.offset*1000)+parseInt(Math.random()*20000));}
nowPlaying.displayTimers.push(setTimeout('displayNowPlaying('+i+');',song.offset*1000));}});if(!nowPlaying.checkTimer){displayNowPlaying(nowPlaying.songs.length-1);nowPlaying.checkTimer=setTimeout('checkNowPlaying();',30*1000);}});}