jQuery.fn.jmp3 = function(passedOptions){
	var playerpath = "/uploads/serebrennikov/scripts/mediaplayer/";
	var options = {
		"filepath": "/uploads/serebrennikov/files/audio/file_mp3/",
		"backcolor": "000000",
		"forecolor": "3d78b3",
		"width": "206",
		"repeat": "no",
		"volume": "100",
		"autoplay": "true",
		"showdownload": "true",
		"showfilename": "true"
	};
	if (passedOptions) {
		jQuery.extend(options, passedOptions);
	}
	return this.each(function(){
		//var filename = options.filepath + jQuery(this).html();
		var filename = options.filepath + jQuery(this).attr("ref");
		var validfilename = filename.indexOf(".mp3");
		if (validfilename == -1) { return false; }
		var mp3html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
		mp3html += 'width="' + options.width + '" height="20" ';
		mp3html += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">';
		mp3html += '<param name="movie" value="' + playerpath + 'singlemp3player.swf?';
		mp3html += 'showDownload=' + options.showdownload + '&file=' + filename + '&autoStart=' + options.autoplay;
		mp3html += '&backColor=' + options.backcolor + '&frontColor=' + options.forecolor;
		mp3html += '&repeatPlay=' + options.repeat + '&songVolume=' + options.volume + '" />';
		mp3html += '<param name="wmode" value="transparent" />';
		mp3html += '<embed wmode="transparent" width="' + options.width + '" height="20" ';
		mp3html += 'src="' + playerpath + 'singlemp3player.swf?'
		mp3html += 'showDownload=' + options.showdownload + '&file=' + filename + '&autoStart=' + options.autoplay;
		mp3html += '&backColor=' + options.backcolor + '&frontColor=' + options.forecolor;
		mp3html += '&repeatPlay=' + options.repeat + '&songVolume=' + options.volume + '" ';
		mp3html += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		mp3html += '</object>';
		jQuery(this).html("");
		jQuery(this).prepend(mp3html+"&nbsp;");
		if(jQuery.browser.msie){ this.outerHTML = this.outerHTML; }
	});
};
jQuery.fn.jmplay = function(){
	return this.each(function(){
    jQuery(this).unbind("click");
    jQuery(this).click(function(){
      file = jQuery(this).attr("ref");
      name = jQuery(this).attr("alt");
      playAudio(file, name);
      return false;
    });
	});
};
jQuery.fn.jmplist = function(){
	return this.each(function(){
    jQuery(this).unbind("click");
    jQuery(this).click(function(){
      file = jQuery(this).attr("ref");
      name = jQuery(this).attr("alt");
      jQuery(this).remove();
      playAudio(file, name);
      return false;
    });
	});
};

