// flash mp3 Player object
var soundPlayer = {

     init:function(options)
     {
	    // passable options
	    soundPlayer.options = {                                  
		    "filepath"          : "",                              // path to MP3 file - must be mp3 file!!!! 
		    "playerpath"        : "/sounds/",                      // path to mpe player
		    "hidden"            : false,						   // true or false if the player visable
		    "backcolor"         : "",							   // background color
		    "forecolor"         : "ffffff",						   // foreground color (buttons)
		    "width"             : "25",	                           // width of player
		    "height"			: "10",					           // height of player
		    "repeat"            : "no",							   // repeat mp3?
		    "volume"            : "50",							   // mp3 volume (0-100)
		    "autoplay"          : "false",						   // play immediately on page load?
		    "showdownload"      : "false",						   // show download button in player
		    "container"         : "body"                           //holds the mp3 player -  must be defined!!!!
	    };
	    
	    //passed options with the passed one 
	    if (options) 
	    {
		    jQuery.extend(soundPlayer.options, options);
	    }
	    
	    //check for valid sound extantion and valid container name
	    if (soundPlayer.options.filepath.indexOf(".mp3") == - 1 ) {alert('the file is not a mp3 file'); return false}
	    if (jQuery('#' + soundPlayer.options.container).length == 0 )  {alert('could not find container'); return false}
        
        //hide the container if hidden option true
        if(soundPlayer.options.hidden)
        {
            soundPlayer.options.width = 1;
            soundPlayer.options.height = 1;
            soundPlayer.options.autoplay = true;
            //jQuery('#' + soundPlayer.options.container).hide();
        }
        
        //prepare the swf code
        soundPlayer.player = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		soundPlayer.player += 'width="' + soundPlayer.options.width + '" height="'+soundPlayer.options.height+'" ';
		soundPlayer.player += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">';
		soundPlayer.player += '<param name="movie" value="' + soundPlayer.options.playerpath + 'singlemp3player.swf?';
		soundPlayer.player += 'showDownload=' + soundPlayer.options.showdownload + '&file=' + soundPlayer.options.filepath + '&autoStart=' + soundPlayer.options.autoplay;
		soundPlayer.player += '&backColor=' + soundPlayer.options.backcolor + '&frontColor=' + soundPlayer.options.forecolor;
		soundPlayer.player += '&repeatPlay=' + soundPlayer.options.repeat + '&songVolume=' + soundPlayer.options.volume + '" />';
		soundPlayer.player += '<param name="wmode" value="transparent" />';
		soundPlayer.player += '<embed wmode="transparent" width="' + soundPlayer.options.width + '" height="'+ soundPlayer.options.height+'" ';
		soundPlayer.player += 'src="' + soundPlayer.options.playerpath + 'singlemp3player.swf?'
		soundPlayer.player += 'showDownload=' + soundPlayer.options.showdownload + '&file=' + soundPlayer.options.filepath + '&autoStart=' + soundPlayer.options.autoplay;
		soundPlayer.player += '&backColor=' + soundPlayer.options.backcolor + '&frontColor=' + soundPlayer.options.forecolor;
		soundPlayer.player += '&repeatPlay=' + soundPlayer.options.repeat + '&songVolume=' + soundPlayer.options.volume + '" ';
		soundPlayer.player += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		soundPlayer.player += '</object>'; 
	    
     },
     
     //play the flash player
     play:function()
     {
		jQuery('#' + soundPlayer.options.container).html(soundPlayer.player);
     }
}