// make jquery work with prototype
jQuery.noConflict();

// disable background flicker in IE
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}

// custom jquery
jQuery(document).ready(function($){

  $('#audio')
    .jPlayer({
      ready: function() {
        this.element.jPlayer('setFile', '/audio/bcc_spring_sale.mp3', '/audio/bcc_spring_sale.ogg');
        if(this.element.data('debug')){
          console.log('SRC: ' + $('#audio').jPlayer('getData', 'diag.src'));
          console.log('SWF: ' + $('#audio').jPlayer('getData', 'swf'));
          console.log('USING MP3: ' + $('#audio').jPlayer('getData', 'usingMP3'));
          console.log('CAN PLAY OGG: ' + $('#audio').jPlayer('getData', 'canPlayOGG'));
          console.log('PLAYING: ' + $('#audio').jPlayer('getData', 'diag.isPlaying'));
        }
      },
      swfPath: '/flash',
      oggSupport: true,
      nativeSupport: false,
      volume: 50
    })
    .data('debug', true);

  $('#jplayer_stop_play').toggle(
    function(){
      $(this).toggleClass('playing');
      $('#audio').jPlayer('play');
      if($('#audio').data('debug')){
        console.log('PLAYING: ' + $('#audio').jPlayer('getData', 'diag.isPlaying'));
      }
    },
    function(){
      $(this).toggleClass('playing');
      $('#audio').jPlayer('stop');
      if($('#audio').data('debug')){
        console.log('STOPPED: ' + !$('#audio').jPlayer('getData', 'diag.isPlaying'));
      }
    }
  );
});