﻿(function($){var i,j,k=window,l={};$.upload=$.extend(l,{start:function(b,c){var d=$(':file',b).filter(function(){return $(this).val().length!=0});if(!d[0])return true;j=$('<div id="progressContainer"><table id="progress" style="width:100%"><tr><th colspan="2" align="left" class="title">Uploading File</th></tr><tr><td colspan="2" class="bar"><div style="border:#70736A solid 1px;background:#FFFFFF;position:relative;height:1.6em;"><div id="progressBar" style="position:absolute;top:0;left:0;width:0;background:#D3DABB;height:1.6em;"></div><div id="progressPercentDone" style="position:absolute;top:0;left:0;width:100%;line-height:1.6em;text-align:center;color:#70736A;">0.00%</div></div></td></tr><tr><th align="right">Current File:</th><td id="progressCurrentFileName" /></tr><tr><th align="right">Time Left:</th><td id="progressTimeLeft" /></tr><tr><th align="right">Upload Left:</th><td id="progressUploadLeft" /></tr><tr><th align="right">Transfer Rate:</th><td id="progressTransferRate" /></tr><tr><th /><td><b><a href="javascript:$.upload.cancel();">Cancel</a></b></td></tr></table></div>');mediabox.open(j,{modal:true,style:{width:350}});var e=+new Date(),f=b.attr('action').split(/[?&]/),g=f.shift(),h;f=$.makeArray(f).filter(function(a){return a.indexOf('UploadID=')!=0});f.push('UploadID='+e);b.attr('action',g+'?'+f.join('&'));i=setTimeout(h=function(){$.ajax({type:'GET',cache:false,url:c,data:{uploadid:e},success:function(a){if(l.update(a))i=setTimeout(h,1000)},error:l.cancel,dataType:'json'})},500);return true},update:function(c){$.each(c,function(a,b){$('#progress'+a,j).text(b)});$('#progressBar',j).css('width',c.PercentDone);if(c.UploadStatus=='Complete'){return false}else if(c.UploadStatus=='Cancelled'){mediabox.close();return false}return true},cancel:function(){if(k.stop)k.stop();else if(k.document&&k.document.execCommand)k.document.execCommand('Stop');clearTimeout(i);mediabox.close()}})})(jQuery);