function ajaxFileUpload(){jQuery("#loading").ajaxStart(function(){jQuery(this).show()}).ajaxComplete(function(){jQuery(this).hide();IsUploadFiles()});jQuery.ajaxFileUpload({url:"index.php?&act=procFileIframeUpload",secureuri:false,fileElementId:"Filedata",dataType:"html",data:{mid:current_mid,editor_sequence:"1",uploadTargetSrl:jQuery("#ff input[name=document_srl]").val(),manual_insert:"true"},success:function(f,d,c){var h=document.getElementById("ff");var g=document.getElementById(f);if(g.contentWindow){var b=document.getElementById(f).contentWindow.uploaded_fileinfo.source_filename;var k=document.getElementById(f).contentWindow.uploaded_fileinfo.uploaded_filename;var e=document.getElementById(f).contentWindow.uploaded_fileinfo.upload_target_srl;var j=document.getElementById(f).contentWindow.uploaded_fileinfo.file_srl;var a=document.getElementById(f).contentWindow.uploaded_fileinfo.sid}else{if(g.contentDocument){var b=document.getElementById(f).contentDocument.uploaded_fileinfo.source_filename;var k=document.getElementById(f).contentDocument.uploaded_fileinfo.uploaded_filename;var e=document.getElementById(f).contentDocument.uploaded_fileinfo.upload_target_srl;var j=document.getElementById(f).contentDocument.uploaded_fileinfo.file_srl;var a=document.getElementById(f).contentDocument.uploaded_fileinfo.sid}}h.document_srl.value=e;ext=(match=k.match(/\.([a-z0-9]+)$/i))?match[1]||"":"";ext=ext.toLowerCase();if(allowedFileTypes!="*.*"&&jQuery.inArray("*."+ext,allowedFileTypes.split(";"))<0){alert("File is not an allowed file type.");return false}if(jQuery.inArray(ext,"gif jpg jpeg png".split(" "))>-1){type="img"}else{if(jQuery.inArray(ext,"mp3 wma wav ogg aac flac".split(" "))>-1){type="music"}else{if(jQuery.inArray(ext,"avi mov mp4 mkv ogv webm".split(" "))>-1){type="media"}else{type="etc"}}}if(k!=""){if(type=="img"){var i='<li id="file_'+j+'" class="success"><button type="button" style="background-image:url('+k+')" data-file="'+k+'" data-type="'+type+'" onclick="jQuery(this).parent().toggleClass(\'select\')" title="'+b+'"><b>✔</b></button><a class="delete_file" href="#" onclick="delete_file('+j+');return false;"><b>X</b></a><a class="insert_file" href="#" onclick="insert_file('+j+');return false"><i class="fa fa-arrow-up"></i></a></li>'}else{var i='<li id="file_'+j+'" class="success type2 '+type+'"><small>'+b+'</small><button type="button" data-file="'+k+'" data-type="'+type+'" data-dnld="?module=file&act=procFileDownload&file_srl='+j+"&sid="+a+'" onclick="jQuery(this).parent().toggleClass(\'select\')"><b>✔</b></button><a class="delete_file" href="#" onclick="delete_file('+j+');return false"><b>X</b></a><a class="insert_file" href="#" onclick="insert_file('+j+');return false"><i class="fa fa-arrow-up"></i></a></li>'}jQuery("#loading").before(i)}else{jQuery("#loading").before('<li class="error">Error</li>')}if(typeof(d.error)!="undefined"){if(d.error!=""){alert(d.error)}else{alert(d.msg)}}},error:function(b,a,c){alert(c)}})}function delete_file(a,b){if(!b){var f=window.confirm(lang_confirm_delete)}if(f||b){var c=a;var e=new Array();e.editor_sequence=1;e.file_srls=a;var d=new Array("error","message");exec_xml("file","procFileDelete",e,function(){jQuery("#file_"+c).remove();IsUploadFiles()})}else{return false}}function IsUploadFiles(){if(jQuery("#files .success").length){jQuery("#mUpload .info").addClass("is_img")}else{jQuery("#mUpload .info").removeClass("is_img");jQuery("#mEditorSelect").removeClass("on")}}jQuery(function(a){a("#FiledataWrp").on("change","#Filedata",function(){ajaxFileUpload()})});