    /**
     * @class MediaPlayer encapsulates the access to 
     * plugin functions of diffrent media players (windows media and flash)
     * @param {int} width Width of the mediaplayer plugin.
     * @param {int} height Height of the mediaplayer plugin.
     * @param {String} plugin  Plugintype . Possible values are:
     * 			- 'wmp' for Windows Media Player
     * 			- 'swf' for FlashPlayer 
     * @param {String} Url of the initial media
 
     * 
     */
		
    function MediaPlayer(width,height,plugin,mediaurl,rendertarget){

     
      this.plugin = plugin;
	  this.mediaurl = mediaurl;
	  this.height = height;
	  this.width = width;
    
	/**
	 * start playback
	 */
	
      this.play = function(){
      
        if(this.plugin=="wmp"){
        
          document.getElementById("mediaplayer").controls.Play();
        
        }else if(this.plugin=="swf"){
		 
		 	document.getElementById("mediaplayer").sendEvent("playpause");
        
        }
      
      }
      
	  /**
	   * pause mediaplayer
	   */
	  
      this.pause = function(){
      
        if(this.plugin=="wmp"){
        
          document.getElementById("mediaplayer").controls.Pause();
        
        }else if(this.plugin=="qtp"){
        
          document.getElementById("mediaplayer").Stop();
        
        }
      
      }
      

	
	/**
	 *  get the type of used mediaplayer plugin
	 *  @return type of mediaplayer plugin [wmp/qtp]
	 */
	
	 this.getPluginType = function(){
	 	
		return this.plugin;
		
	 }
	
	 /**
	 *  get the current playback position of the media
	 *  @return The current position of the media in [seconds]
	 */
	
      this.getTime = function(){
        
        var sec;    
        
        if(this.plugin=="wmp"){
       
          sec = document.getElementById("mediaplayer").controls.currentPosition;
        
        }else if(this.plugin=="qtp"){
        
          var mediaFrames = document.getElementById("mediaplayer").GetTime();
          
          sec = mediaFrames / document.getElementById("mediaplayer").GetTimeScale();
        
        }
      
        return sec;
        
      }
    
	
	/**
	 * set the URL of media to be played by the mediaplayer
	 * 
	 * @param {String} url
	 */
	
	this.setMediaURL = function (url){
		
		if(this.plugin=="wmp"){
        
          document.getElementById("mediaplayer").URL = url;
        
        }else if(this.plugin=="swf"){
         
         	document.getElementById("mediaplayer").loadFile( {file:url});
 
        }
		
	}
	
	
	
	/**
	 * set the URL of media to be played by the mediaplayer
	 * 
	 * @param {String} url
	 */
	
	this.reinitialize = function (width,height,plugin,url){
		
		this.plugin = plugin;
		this.mediaurl = url;
		this.width = width;
		this.height = height;
 
        }
		
	
	
	
	
	/**
	 * render the player into the webpage
	 */
	
	this.renderPlayer =  function(){

		var pluginHtml;
		
		if(this.plugin=="wmp"){
		
			pluginHtml="<object id=\"mediaplayer\" width="+this.width+" height="+this.height+" classid=\"clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6\" type=\"application/x-oleobject\" align=\"middle\"> \
    							<param name=\"URL\" value=\""+this.mediaurl+"\"> \
    							<param name=\"autoStart\" value=\"true\"> \
								<param name=\"showcontrols\" value=\"1\">\
    					</object>";
	
	
			
	
		}else if(this.plugin=="swf"){
	
							
			pluginHtml = "<object id=\"mediaplayer\" width=\""+this.width+"\" height=\""+this.height+"\"\
   							 data=\"" + swfPath + "\"\
    						 type=\"application/x-shockwave-flash\">\
  							 <param name=\"movie\" value=\"" + swfPath + "\">\
							 <param name=\"flashvars\" value=\"&file=" + this.mediaurl + "&autostart=true&enablejs=true&frontcolor=0x000033&backcolor=0x808080&lightcolor=0xAAAAAA&usefullscreen=false\"\
						 </object>";
							
							
			} 
		
			document.getElementById(rendertarget).innerHTML = pluginHtml;
			
		}
    }	

