if(typeof amptracker == 'undefined') { var amptracker = {}; } amptracker.NowPlaying = new function() { var BASE_URL = 'http://npfree.amptracker.com/nowplaying/'; var CONTAINER_ID = 'amptracker_NowPlaying'; this.currentRating = 0; this.currentRatingLabel = ''; this.revertTimerId = null; var head = window.document.getElementsByTagName('head')[0]; var script = null; function addStylesheet() { var stylesheet = window.document.createElement('link'); stylesheet.rel = 'stylesheet'; stylesheet.type = 'text/css'; stylesheet.href = BASE_URL + 'nowplaying.css'; stylesheet.media = 'all'; head.appendChild(stylesheet); } function sendRequest(uri) { script = window.document.createElement('script'); script.type = 'text/javascript'; script.src = BASE_URL + uri + '&seed=' + new Date().getTime(); head.appendChild(script); } function updateContent() { sendRequest('update.php?username=trip&image=http%3A%2F%2Fpeaceoutradio.com%2FPS.jpg&listenLink=http%3A%2F%2Fcommunity.loudcity.com%2Fstations%2Fpeace-out-radio%2Ftune_in&amazonId=atributtolouispr&'); } this.update = function(content) { if(content) { var container = window.document.getElementById(CONTAINER_ID); container.innerHTML = content; container.style.display = 'block'; } if(script) { head.removeChild(script); } } this.setCurrentRating = function(rating) { this.currentRating = rating; } this.setCurrentRatingLabel = function(ratingLabel) { this.currentRatingLabel = ratingLabel; } this.ratingMouseOver = function(rating) { if(this.revertTimerId) window.clearTimeout(this.revertTimerId); this.revertTimerId = null; for(var i = 1; i <= 5; i++) { window.document.getElementById('amptracker_NowPlaying_rating_' + i).src = i <= rating ? 'http://npfree.amptracker.com/images/staron.gif' : 'http://npfree.amptracker.com/images/staroff.gif'; } window.document.getElementById('amptracker_NowPlaying_ratingLabel'). innerHTML = 'Rate this: ' + rating; } this.ratingMouseOut = function() { var currentRating = this.currentRating; var currentRatingLabel = this.currentRatingLabel; var revert = function() { for(var i = 1; i <= 5; i++) { var starImg = currentRating > i - 0.75 ? (currentRating > i - 0.25 ? 'staron.gif' : 'starhalf.gif') : 'staroff.gif'; window.document.getElementById('amptracker_NowPlaying_rating_' + i).src = 'http://npfree.amptracker.com/images/' + starImg; } window.document.getElementById('amptracker_NowPlaying_ratingLabel').innerHTML = currentRatingLabel; } this.revertTimerId = window.setTimeout(revert, 100); } this.ratingClick = function(rating) { for(var i = 1; i <= 5; i++) { var ratingImg = window.document.getElementById('amptracker_NowPlaying_rating_' + i); ratingImg.onmouseover = null; ratingImg.onmouseout = null; ratingImg.onclick = null; } sendRequest('update.php?username=trip&image=http%3A%2F%2Fpeaceoutradio.com%2FPS.jpg&listenLink=http%3A%2F%2Fcommunity.loudcity.com%2Fstations%2Fpeace-out-radio%2Ftune_in&amazonId=atributtolouispr&&rating=' + rating); } addStylesheet(); document.write('
'); updateContent(); window.setInterval(updateContent, 60000); }