

/*
 Assigns media control behavior to anchor tags that use a specific class name.
 The links control the Flash media player.
 Current class names supported are: stopClip, pauseClip, playClip
  requires the Flash JS integration kit is installed
 */
var MediaPlayer={
 // uid:new Date().getTime(),
  uid:"",
  flashProxy:null,
  createFlashProxy:function() {
    this.flashProxy = new FlashProxy(this.uid, '/images/flash/JavaScriptFlashGateway.swf'); },
  getUid:function() { return this.uid; },
  setUid:function(id) { this.uid = id; },

  playClip:function(url) { this.flashProxy.call('playByUrl', url); },
  playClipId:function(id) { this.flashProxy.call('playById', id); },
  stopClip:function() {  this.flashProxy.call('stopClip'); return false;},
  pauseClip:function() { this.flashProxy.call('pauseClip'); return false;},
  attachMediaEvents:function() {
  var oThis = this;
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href")) {
     // Attach functions to anchor tags.
       var className = anchor.className;

       if (className.indexOf("stopClip") > -1) {
          anchor.onclick = function() {
            //MediaPlayer.stopClip();
            oThis.stopClip();
            return false;
          }
       } else if (className.indexOf("pauseClip") > -1) {
         anchor.onclick = function () {
           //MediaPlayer.pauseClip();
           oThis.pauseClip();
           return false;
         }
       } else if (className.indexOf("playClip") > -1) {
          anchor.onclick = function () {
            //MediaPlayer.playClip(this.href);
            oThis.playClip(this.href);
            return false;
          }
       }
    }
  }
  }

}
MediaPlayer.setUid(new Date().getTime());
MediaPlayer.createFlashProxy();
