var upload_range=1;var total_upload_size;var get_status_speed;var get_status_url;var get_data_loop=true;var seconds=0;var minutes=0;var hours=0;var info_width=0;var info_bytes=0;var info_time_width=500;var info_time_bytes=15;var cedric_hold=true;function checkFileNameFormat(){if(check_file_name_format==false){return false}for(var B=0;B<upload_range;B++){if(document.form_upload.elements["upfile_"+B].value!=""){var A=document.form_upload.elements["upfile_"+B].value;var D=A.lastIndexOf("\\");if(D<1){D=A.lastIndexOf("/")}var E=A.slice(D+1,A.length);var C=/^[\w][\w\.\ \-]{1,64}$/i;if(!C.test(E)){alert("Sorry, uploading files in this format is not allowed. Please ensure your file names follow this format. \n\n1. Entire file cannot exceed 64 characters\n2. Format should be filename.extension or filename\n3. Legal characters are 1-9, a-z, A-Z, '_', '-'\n");return true}}}return false}function checkDisallowFileExtensions(){if(check_disallow_extensions==false){return false}for(var B=0;B<upload_range;B++){if(document.form_upload.elements["upfile_"+B].value!=""){if(document.form_upload.elements["upfile_"+B].value.match(disallow_extensions)){var A=document.form_upload.elements["upfile_"+B].value;var D=A.lastIndexOf("\\");if(D<1){D=A.lastIndexOf("/")}var E=A.slice(D+1,A.length);var C=E.slice(E.indexOf(".")).toLowerCase();alert('Sorry, uploading a file with the extension "'+C+'" is not allowed.');return true}}}return false}function checkAllowFileExtensions(){if(check_allow_extensions==false){return false}for(var B=0;B<upload_range;B++){if(document.form_upload.elements["upfile_"+B].value!=""){if(!document.form_upload.elements["upfile_"+B].value.match(allow_extensions)){var A=document.form_upload.elements["upfile_"+B].value;var D=A.lastIndexOf("\\");if(D<1){D=A.lastIndexOf("/")}var E=A.slice(D+1,A.length);var C=E.slice(E.indexOf(".")).toLowerCase();alert('Sorry, uploading a file with the extension "'+C+'" is not allowed.');return true}}}return false}function checkNullFileCount(){if(check_null_file_count==false){return false}var B=0;for(var A=0;A<upload_range;A++){if(document.form_upload.elements["upfile_"+A].value==""){B++}}if(B==upload_range){alert("Please Choose A File To Upload.");return true}else{return false}}function checkDuplicateFileCount(){if(check_duplicate_file_count==false){return false}var E=false;var A=0;var C="Duplicate Upload Files Detected.\n\n";var H=new Array();for(var D=0;D<upload_range;D++){if(document.form_upload.elements["upfile_"+D].value!=""){var G=document.form_upload.elements["upfile_"+D].value;var F=G.lastIndexOf("\\");if(F<1){F=G.lastIndexOf("/")}var I=G.slice(F+1,G.length);H[D]=I}}var J=H.length;for(var D=0;D<J;D++){for(var B=0;B<J;B++){if(H[D]==H[B]&&H[D]!=null){A++}}if(A>1){C+='Duplicate file "'+H[D]+'" detected in slot '+(D+1)+".\n";E=true}A=0}if(E){alert(C);return true}else{return false}}function uploadFiles(){if(checkFileNameFormat()){return false}if(checkDisallowFileExtensions()){return false}if(checkAllowFileExtensions()){return false}if(checkNullFileCount()){return false}if(checkDuplicateFileCount()){return false}var B=0;for(var A=0;A<upload_range;A++){if(document.form_upload.elements["upfile_"+A].value!=""){B++}}document.getElementById("total_uploads").innerHTML=B;document.form_upload.submit();document.getElementById("upload_button").disabled=true;iniProgressRequest();getElapsedTime();for(var A=0;A<upload_range;A++){document.form_upload.elements["upfile_"+A].disabled=true}}function resetForm(){location.href=self.location}function hideProgressBar(){document.getElementById("progress_bar").style.display="none"}function iniFilePage(){resetProgressBar();for(var A=0;A<upload_range;A++){document.form_upload.elements["upfile_"+A].disabled=false;document.form_upload.elements["upfile_"+A].value=""}document.getElementById("progress_info").innerHTML="";document.getElementById("upload_button").disabled=false;document.getElementById("progress_bar").style.display="none";document.form_upload.reset()}function resetProgressBar(){get_data_loop=true;seconds=0;minutes=0;hours=0;info_width=0;info_bytes=0;cedric_hold=true;document.getElementById("upload_status").style.width="0px";document.getElementById("percent").innerHTML="0%";document.getElementById("uploaded_files").innerHTML=0;document.getElementById("total_uploads").innerHTML="";document.getElementById("current").innerHTML=0;document.getElementById("total_kbytes").innerHTML="";document.getElementById("time").innerHTML=0;document.getElementById("remain").innerHTML=0;document.getElementById("speed").innerHTML=0}function stopUpload(){try{window.stop()}catch(A){try{document.execCommand("Stop")}catch(A){}}}function addUploadSlot(B){if(upload_range<max_upload_slots){if(B==upload_range){var A=document.getElementById("upload_slots");var C=document.createElement("div");C.innerHTML='<input type="file" name="upfile_'+upload_range+'" size="90" onchange="addUploadSlot('+(upload_range+1)+')">';A.appendChild(C);upload_range++}}}function smoothCedricStatus(){if(info_width<progress_bar_width&&!cedric_hold){info_width=info_width+1;document.getElementById("upload_status").style.width=info_width+"px"}if(get_data_loop){self.setTimeout("smoothCedricStatus()",info_time_width)}}function smoothCedricBytes(){if(info_bytes<total_upload_size&&!cedric_hold){info_bytes=info_bytes+1;document.getElementById("current").innerHTML=info_bytes}if(get_data_loop){self.setTimeout("smoothCedricBytes()",info_time_bytes)}}function updateCedricStatus(B,A){cedric_hold=false;info_width=B;info_bytes=A}function getProgressStatus(){var A=document.createElement("SCRIPT");A.type="text/javascript";A.src=get_status_url+"&rnd_id="+Math.random();document.body.appendChild(A);if(get_data_loop){self.setTimeout("getProgressStatus()",get_status_speed)}}function getElapsedTime(){seconds+=1;if(seconds==60){seconds=0;minutes+=1}if(minutes==60){minutes=0;hours+=1}var C=""+((hours<10)?"0":"")+hours;var A=""+((minutes<10)?"0":"")+minutes;var B=""+((seconds<10)?"0":"")+seconds;document.getElementById("time").innerHTML=C+":"+A+":"+B;if(get_data_loop){self.setTimeout("getElapsedTime()",1000)}}function createRequestObject(){var A=false;if(window.XMLHttpRequest){A=new XMLHttpRequest();if(A.overrideMimeType){A.overrideMimeType("text/xml")}}else{if(window.ActiveXObject){try{A=new ActiveXObject("Msxml2.XMLHTTP")}catch(B){try{A=new ActiveXObject("Microsoft.XMLHTTP")}catch(B){}}}}if(!A){document.getElementById("progress_info").innerHTML="Error: Your browser does not support AJAX";return false}else{return A}}function iniProgressRequest(){var A=false;A=createRequestObject();if(A){document.getElementById("progress_info").innerHTML="Initializing Progress Bar ...";A.open("GET",path_to_ini_status_script+"&rnd_id="+Math.random(),true);A.onreadystatechange=function(){iniProgressResponse(A)};A.setRequestHeader("Content-Type","application/x-www-form-urlencoded");A.send(null)}}function iniProgressResponse(B){if(B.readyState==4){if(B.status==200){var A=B.responseXML;if(A.getElementsByTagName("error_status").item(0).firstChild.nodeValue==1){document.getElementById("progress_info").innerHTML=A.getElementsByTagName("error_msg").item(0).firstChild.nodeValue;if(A.getElementsByTagName("stop_upload").item(0).firstChild.nodeValue==1){stopUpload()}}else{get_status_speed=A.getElementsByTagName("get_data_speed").item(0).firstChild.nodeValue;get_data_loop=true;if(document.form_upload.embedded_upload_results&&document.form_upload.embedded_upload_results.value==1){document.getElementById("upload_div").style.display="none"}get_status_url="uploader_status.php?temp_dir_sid="+A.getElementsByTagName("temp_dir_sid").item(0).firstChild.nodeValue+"&start_time="+A.getElementsByTagName("start_time").item(0).firstChild.nodeValue+"&total_upload_size="+A.getElementsByTagName("total_bytes").item(0).firstChild.nodeValue+"&cedric_progress_bar="+A.getElementsByTagName("cedric_progress_bar").item(0).firstChild.nodeValue;document.getElementById("progress_bar").style.display="";document.getElementById("total_kbytes").innerHTML=Math.round(Number(A.getElementsByTagName("total_bytes").item(0).firstChild.nodeValue/1024))+" ";document.getElementById("progress_info").innerHTML="Upload In Progress";getProgressStatus();if(A.getElementsByTagName("cedric_progress_bar").item(0).firstChild.nodeValue==1){total_upload_size=A.getElementsByTagName("total_bytes").item(0).firstChild.nodeValue;smoothCedricBytes();smoothCedricStatus()}}}else{document.getElementById("progress_info").innerHTML="Error: returned status code "+B.status+" "+B.statusText}}};



