function randomPlay ( myArray ) {
var i = myArray.length;
if ( i == 0 ) return false;
while ( --i ) {
var j = Math.floor( Math.random() * ( i + 1 ) );
var tempi = myArray[i];
var tempj = myArray[j];
myArray[i] = tempj;
myArray[j] = tempi;
}
return myArray;
};
$(document).ready(function () { 
  $("a[href$=.flv]").flowplayer("/includes/templates/template_default/flash/flowplayer-3.1.5.swf", {
    // fullscreen button not needed here
    controls: {
        fullscreen: true,
        height: 30
    },
    clip: {
      autoPlay: false,
      autoBuffering: true,
      // optional: when playback starts close the first audio playback
      onBeforeBegin: function() {
      $f("player").close();
      }
  }
  }).each(function() { $f(this).load();  });

  $("a[href$=.mp3]").flowplayer("/includes/templates/template_default/flash/flowplayer-3.1.5.swf", {
    // fullscreen button not needed here
    plugins: {
      audio: { 
        url: '/includes/templates/template_default/flash/flowplayer.audio-3.1.2.swf' 
      }, 
      controls: {
        time: false,
        scrubber: false,
        fullscreen: false,
        height: 30
      }
    },
    clip: {
      autoPlay: true,
      // optional: when playback starts close the first audio playback
      onBeforeBegin: function() {
      $f("player").close();
      }
    },
    playlist: randomPlay([
        { url: '/pub/MP3/Soul_Thang_60.mp3'},
	{ url: '/pub/MP3/Beethoven_Piano_Sonata_30_(Opus_109_1st_movement).mp3'},	
	{ url: '/pub/MP3/Chinese_Garden.mp3'},	
	{ url: '/pub/MP3/Embraced_30.mp3'},
	{ url: '/pub/MP3/Kalimba_60.mp3' }
  ])
  }).each(function() { $f(this).load();  });

});

