			jQuery(document).ready(function() {
               var adminajax = fmparam.adminajax;		
				jQuery('#wp_file_manager_front').elfinder({
					url : fmparam.ajaxurl,				
					uploadMaxChunkSize : fmparam.uploadMaxChunkSize,		
					lang: fmparam.lang,					
					defaultView : fmparam.view,				
					dateFormat : fmparam.dateformat,					
					customData:{_wpnonce: fmparam.nonce,allowed_roles: fmparam.allowed_roles, access_folder: fmparam.access_folder, writte: fmparam.write, readd: fmparam.read, hide_files: fmparam.hide_files,lock_extensions: fmparam.lock_extensions, allowed_operations: fmparam.allowed_operations, ban_user_ids: fmparam.ban_user_ids },
					
					/* Start */
					handlers : {						     
						   /* Upload */
								upload: function(event, instance) {									
                  if(fmparam.allow_upload_notifications == 'yes') {
									var filepaths = [];
									var fileNames = [];
									var uploadedFiles = event.data.added;
									for (i in uploadedFiles) {
										var file = uploadedFiles[i];										
										 filepaths.push(file.url);
										 fileNames.push(file.name);
									}	
									if(filepaths != '') {
										var data = {
												'action': 'mk_file_folder_manager_uc',
												'uploadedby' : fmparam.userID,
												'uploadefiles' : filepaths,
												'uploadedFilesNames' : fileNames
									      };											
												jQuery.post(adminajax, data, function(response) {
												});
                      }	
                    }							
								},
								
							
								 /* Download */
								 download: function(event, elfinderInstance) {	
                  if(fmparam.allow_download_notifications == 'yes') {
											var downloadFiles = [];								
											var downloadfiles = event.data.files;
											for (i in downloadfiles) {
												var filenames = downloadfiles[i].name;
												downloadFiles.push(filenames);
											}	
											if(downloadFiles != '') {
															var data = {
															'action': 'mk_file_folder_manager_dc',
															'downloadedby' : fmparam.userID,
															'downloadedFiles': downloadFiles
														};										
														jQuery.post(adminajax, data, function(response) {
														});
													}	
                    }								
								}	
								
														
							},
											
					/* END */
				    commandsOptions: {
					edit : {
					
					mimes : [],
					
					editors : [{
					
					mimes : ['text/plain', 'text/html', 'text/javascript', 'text/css', 'text/x-php', 'application/x-php'],
					
					load : function(textarea) {
					
					 var mimeType = this.file.mime;
							  return CodeMirror.fromTextArea(textarea, {
								mode: mimeType,
								indentUnit: 4,
								lineNumbers: true,								
								theme: fmparam.code_editor_theme,								
								viewportMargin: Infinity,
								lineWrapping: true
							  });
					},
					
					close : function(textarea, instance) {
					this.myCodeMirror = null;
					},				
					
					save: function(textarea, editor) {
							  jQuery(textarea).val(editor.getValue());
                                /* Start */
                     if(fmparam.allow_edit_notifications == 'yes') {
							         var data = {
													'action': 'mk_file_folder_manager_fn',
													'editedby' : fmparam.userID,
													'file': this.file.name,
												};										
												jQuery.post(adminajax, data, function(response) {
												});
                     }				
							  /* End */		
							}
					
					} ]
					} 
					
					}
					
					}).elfinder('instance');
					// mac fix				
             if(navigator.userAgent.indexOf('Mac OS X') != -1) {
                jQuery("body").addClass("mac");
              } else {
                jQuery("body").addClass("windows");
              }
			});