Emv.AudioPlayer = function(divid, url)
{
	this.id = divid;
	this.initUrl = url;
	this.name     = this.id + "_name";
	// Default flashplayer domain.
    // Can be set via FlashplayerControlObject.setDomain()
    this.fpDomain = "http://flashplayer.kino.de/";

    this.fpFolder = "";

    // Default flashplayer swf file.
    // Can be set via FlashplayerControlObject.setSWF()
    this.swf = "audioplayer.swf";
    this.width = 335;
    this.height = 26;
    this.flashVersion= "10.0.0";
    this.autoPlay = true;
    
    /**
     * draws the player to the html elemt with given id
     * all content within this element will be lost
     */
    this.draw = function()
	{
		// Configure the flash variables.
        var flashvars = {};
        flashvars.audioSrc  = this.initUrl;
        flashvars.divid     = this.id;
        flashvars.autoPlaySound	  = this.autoPlay;

        // Configure the flash parameters.
        var params = {};
        params.menu              = "false";
        params.allowfullscreen   = "true";
        params.allowscriptaccess = "always";

        // Configure the flash attributes.
        var attributes = {};
        attributes.id    = this.id;
        attributes.name  = this.name;
        attributes.align = "middle";

        // Create the flash object/embed element
        // Use swfobject class.

        swfobject.embedSWF(
            this.fpDomain + this.fpFolder + this.swf,
            this.id,
            this.width,
            this.height,
            this.flashVersion,
            this.fpDomain + "install/expressInstall.swf",
            flashvars, params, attributes);
	};
    
    this.setAutoPlay = function(ap)
    {
    	this.autoPlay = ap;
    };
    
    /**
     * setting the domain where the audioplayer is located
     * @param String domain - default flashplayer.kino.de
     */
    this.setDomain = function (domain)
    {
    	this.fpDomain = domain;
    };
    
    /**
     * setting the subfolder where the player is located
     * @param string | default empty - just used for testing purposes
     */
    this.setFolder = function (fold)
    {
    	this.fpFolder = fold;
    };
    
    /**
     * returns player id pseudo interface to store in the registry
     * @return Number
     */
    this.getId = function()
    {
    	return this.id;
    };
	
    /**
     * calls audioplayer an initializes loading this soundfile
     * @param string url |  mp3 full qualified filename
     */
	this.loadMp3 = function(url)
	{
		this.getMovie().loadMp3(url);	
	};
	
	/**
	 * used for intern calls - returns flashmovie
	 */
	this.getMovie = function() 
    {
        if (navigator.appName.indexOf("Microsoft") != -1) 
        {
            return window[this.name];
        }
        else 
        {
            return document[this.name];
        }
    };
};
