mui.plusReady(function() {
	var btnArr = [];
	
	$('.selectfiles').each(function(num) {
		btnArr.push($(this).attr('id'));
	})
	
	$.each(btnArr, function(i, n) {
		var self = this.toString();
		var that = document.getElementById(this);
					var uploader = new plupload.Uploader({
						runtimes: 'html5,flash,silverlight,html4',
						browse_button: self,
						//multi_selection: false,
						//	container: document.getElementById('container'),
						flash_swf_url: '../lib/plupload-2.1.2/js/Moxie.swf',
						silverlight_xap_url: '../lib/plupload-2.1.2/js/Moxie.xap',
						url: 'http://oss.aliyuncs.com',
						dir:'appraises',

						filters: {
							mime_types: [ //只允许上传图片和zip,rar文件
								{
									title: "Image files",
									extensions: "jpg,gif,png,bmp"
								},
								{
									title: "Zip files",
									extensions: "zip,rar"
								}
							],
							max_file_size: '10mb', //最大只能上传10mb的文件
							prevent_duplicates: true //不允许选取重复文件
						},

						init: {
							PostInit: function() {
								document.getElementsByClassName('ossfile')[i].innerHTML = '';
								//			document.getElementById('postfiles').onclick = function() {
								//				set_upload_param(uploader, '', false);
								//				return false;
								//			};
								uploader.bind('FilesAdded', function() {
									set_upload_param(uploader, '', false,'appraises');
									return false;
								});
							},

							FilesAdded: function(up, files) {
								plupload.each(files, function(file) {
									document.getElementsByClassName('ossfile')[i].innerHTML += '<div class="files_out" id="'+ file.id +'"><b></b>' +
										'<div class="progress"><div class="progress-bar" style="width: 60px"></div></div>' +
										'</div>';
								});
							},

							BeforeUpload: function(up, file) {
								check_object_radio();
								set_upload_param(up, file.name, true);
							},

							UploadProgress: function(up, file) {
								var d = document.getElementById(file.id);
								d.getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
								var prog = d.getElementsByTagName('div')[0];
								var progBar = prog.getElementsByTagName('div')[0]
								progBar.style.width = 2 * file.percent + 'px';
								progBar.setAttribute('aria-valuenow', file.percent);
							},

							FileUploaded: function(up, file, info) {
								if(info.status == 200) {
									document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<img data-src="' + get_uploaded_object_name(file.name) + '" src="' +  hyhImgUrl(get_uploaded_object_name(file.name)) + '" />';
								} else {
									document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = info.response;
								}
								//console.log(JSON.stringify(up))
								//console.log(JSON.stringify(file))
								//console.log(JSON.stringify(info))
								//console.log(file.name);
								//console.log((hyhImgUrl(get_uploaded_object_name(file.name))));
							},

							Error: function(up, err) {
								if(err.code == -600) {
									mui.alert("\n选择的文件太大了");
								} else if(err.code == -601) {
									mui.alert("\n选择的文件后缀不对");
								} else if(err.code == -602) {
									mui.alert("\n这个文件已经上传过一遍了");
								} else {
									mui.alert("\nError xml:" + err.response);
								}
							}
						}
					});

					uploader.init();
			
			
})
	}); 

	