

(function() {
var jQuery;
if (window.jQuery === undefined) {
  // Site does not have any jQuery installed, so include our own
  var scriptTag = document.createElement('script');
  scriptTag.setAttribute('type', 'text/javascript');
  scriptTag.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js');
  scriptTag.onload = scriptLoadHandler;
  // Script load for IE
  scriptTag.onreadystatechange = function() {
    if (this.readyState == 'complete' || this.readyState == 'loaded') {
      scriptLoadHandler();
    }
  };
  // Try to find the head, otherwise default to the documentElement
  (document.getElementsByTagName('head')[0] || document.documentElement).appendChild(scriptTag);
} else {
  jQuery = window.jQuery;
  init();
}
function scriptLoadHandler() {
  // Restore $ and window.jQuery to their previous values and store the
  // new jQuery in our local jQuery variable
  jQuery = window.jQuery.noConflict(true);
  init(); 
}
function init() { 
  var gaAccount = 'UA-8279366-2';
  if (window._gaq === undefined) {
    window._gaq = window._gaq || [];    
    jQuery.ajax({
      url: 'http://google-analytics.com/ga.js', 
      dataType: 'script',
      cache: true
    });
  }
  jQuery(document).ready(function($) {
    _gaq.push(
      ['_setAccount', gaAccount],
      ['_trackEvent', 'Science360 Radio', 'Radio Widget - Load']
    );      
    $('<style>', {type: 'text/css'}).text('#radio-widget{background-color:#000000;background-image:url(http://freeenergymedia.com/shared/PLAYER/player/clickToPlay.png);width:221px;height:137px;font-family:Helvetica,sans-serif;font-size:11px;font-weight:bold;position:relative;}radio-widget .now-playing{color:#ffffff;position:absolute;top:55px;left:0;padding:0 25px;}#radio-widget .run-time{color:#ffffff;font-weight:normal;text-align:right;position:absolute;top:95px;right:0;padding:0 15px;}').appendTo('head');
    
    $('#radio-widget').click(function(e) {
      _gaq.push(
        ['_setAccount', gaAccount],
        ['_trackEvent', 'Science360 Radio', 'Radio Widget - Play']
      );      
      var popup = window.open('http://www.freeenergymedia.com/shared/PLAYER/player/player.html', 'RadioPopup', 'height=348,width=381,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0');
      if (window.focus) {
        popup.focus();
      }
    }).mouseover(function(e) {
      $(this).css('cursor', 'pointer');
    }).mouseleave(function(e) {
      $(this).css('cursor', 'default');
    });
  });
}
})();
