var mediaplayer = {

    activePlayerDivId : null,
    
    play : function( js_components, thePlace, theFile, width, height, allowfullscreen ) {
        var go = true;
        var playerJsId = "js_" + thePlace;
        var s = new SWFObject( js_components + "/jw_flv_mediaplayer/mediaplayer.swf", playerJsId, width, height, "7" );
        s.addParam( "allowfullscreen", allowfullscreen );
        s.addVariable( "file", theFile );
        s.addVariable("width", width );
        s.addVariable("height", height );
        s.addVariable("javascriptid", playerJsId );
        s.addVariable("enablejs","true");
        if (go) { s.addVariable("autostart","true"); }
        var playLink = document.getElementById( "pb_" + thePlace );
        if ( playLink ) {
            //playLink.style.display = "none";
        }
        var playerDiv = document.getElementById( thePlace );
        playerDiv.style.display = "block"
        s.write( thePlace );
    },

    createPlayer : function (js_components, thePlace, theFile, theImage, width, height, allowfullscreen) {
        var go = false;
        var s = new SWFObject( js_components + "/jw_flv_mediaplayer/mediaplayer.swf", "js_" + thePlace, width, height, "7" );
        s.addVariable("file",theFile);
        s.addParam("allowfullscreen", allowfullscreen);
        s.addVariable("width", width);
        s.addVariable("height", height);
        s.addVariable("image",theImage);
        s.addVariable("javascriptid", "js_" + thePlace );
        s.addVariable("enablejs","true");
        if (go) { s.addVariable("autostart","true"); }
        s.write( thePlace );
    },
    
    sendEvent : function (swf,typ,prm) { 
      mediaplayer.thisMovie(swf).sendEvent(typ,prm); 
    },
    
    thisMovie : function (swf) {
      if(navigator.appName.indexOf("Microsoft") != -1) {
        return window[swf];
      } 
      else {
        return document[swf];
      }
    },
    
    getUpdate : function(typ,pr1,pr2,swf) {    
        var swfDivId = swf.substring(3);
        if (typ == 'state' && pr1==2 ) {
            if( this.activePlayerDivId && this.activePlayerDivId != swfDivId ) {
                mediaplayer.sendEvent( "js_" + this.activePlayerDivId, 'stop', null );
                var playLink = document.getElementById( "pb_" + this.activePlayerDivId );
                if ( playLink ) {
                    playLink.style.display = "block";
                    var activePlayerDiv = document.getElementById( this.activePlayerDivId );
                    if ( activePlayerDiv ) {
                        activePlayerDiv.innerHTML = "";
                        activePlayerDiv.style.display = "none";
                    }
                }                
            }
            this.activePlayerDivId = swf.substring( 3 );
        }
    }
    
};

function getUpdate(typ,pr1,pr2,swf) {
     mediaplayer.getUpdate(typ, pr1, pr2, swf);
}
