Swiff.Uploader=new Class({Extends:Swiff,Implements:Events,options:{path:"Swiff.Uploader.swf",target:null,zIndex:9999,height:30,width:100,callBacks:null,params:{wMode:"opaque",menu:"false",allowScriptAccess:"always"},typeFilter:null,multiple:!0,queued:!0,verbose:!1,url:null,method:null,data:null,mergeData:!0,fieldName:null,fileSizeMin:1,fileSizeMax:null,allowDuplicates:!1,timeLimit:Browser.Platform.linux?0:30,buttonImage:null,policyFile:null,fileListMax:0,fileListSizeMax:0,instantStart:!1,appendCookieData:!1,
fileClass:null},initialize:function(a){this.addEvent("load",this.initializeSwiff,!0).addEvent("select",this.processFiles,!0).addEvent("complete",this.update,!0).addEvent("fileRemove",function(a){this.fileList.erase(a)}.bind(this),!0);this.setOptions(a);this.options.callBacks&&Hash.each(this.options.callBacks,function(a,b){this.addEvent(b,a)},this);this.options.callBacks={fireCallback:this.fireCallback.bind(this)};a=this.options.path;a.contains("?")||(a+="?noCache="+$time());this.options.container=
this.box=(new Element("span",{"class":"swiff-uploader-box"})).inject($(this.options.container)||document.body);if(this.target=$(this.options.target)){var b=window.getScroll();this.box.setStyles({position:"absolute",visibility:"visible",zIndex:this.options.zIndex,overflow:"hidden",height:1,width:1,top:b.y,left:b.x});this.parent(a,{params:{wMode:"transparent"},height:"100%",width:"100%"});this.target.addEvent("mouseenter",function(){this.box.setStyle("visibility","visible");this.reposition()}.bind(this));
this.addEvents({buttonEnter:this.targetRelay.bind(this,["mouseenter"]),buttonLeave:this.targetRelay.bind(this,["mouseleave"]),buttonDown:this.targetRelay.bind(this,["mousedown"]),buttonDisable:this.targetRelay.bind(this,["disable"])});this.reposition();window.addEvent("resize",this.reposition.bind(this,[]))}else this.parent(a);this.inject(this.box);this.fileList=[];this.size=this.uploading=this.bytesLoaded=this.percentLoaded=0;9>Browser.Plugins.Flash.version?this.fireEvent("fail",["flash"]):this.verifyLoad.delay(1E3,
this)},verifyLoad:function(){this.loaded||(this.object.parentNode?"none"==this.object.style.display?this.fireEvent("fail",["hidden"]):this.object.offsetWidth||this.fireEvent("fail",["empty"]):this.fireEvent("fail",["disabled"]))},fireCallback:function(a,b){if("file"==a.substr(0,4)){1<b.length&&this.update(b[1]);var f=b[0],e=this.findFile(f.id);this.fireEvent(a,e||f,5);if(e){var d=a.replace(/^file([A-Z])/,function(a,b){return b.toLowerCase()});e.update(f).fireEvent(d,[f],10)}}else this.fireEvent(a,
b,5)},update:function(a){$extend(this,a);this.fireEvent("queue",[this],10);return this},findFile:function(a){for(var b=0;b<this.fileList.length;b++)if(this.fileList[b].id==a)return this.fileList[b];return null},initializeSwiff:function(){this.remote("initialize",{width:this.options.width,height:this.options.height,typeFilter:this.options.typeFilter,multiple:this.options.multiple,queued:this.options.queued,url:this.options.url,method:this.options.method,data:this.options.data,mergeData:this.options.mergeData,
fieldName:this.options.fieldName,verbose:this.options.verbose,fileSizeMin:this.options.fileSizeMin,fileSizeMax:this.options.fileSizeMax,allowDuplicates:this.options.allowDuplicates,timeLimit:this.options.timeLimit,buttonImage:this.options.buttonImage,policyFile:this.options.policyFile});this.loaded=!0;this.appendCookieData()},targetRelay:function(a){this.target&&this.target.fireEvent(a)},reposition:function(a){a=a||this.target&&this.target.isDisplay()?this.target.getCoordinates(this.box.getOffsetParent()):
{top:window.getScrollTop(),left:0,width:1,height:1,visibility:"hidden"};try{this.box.setStyles(a)}catch(b){}this.fireEvent("reposition",[a,this.box,this.target])},setOptions:function(a){a&&(a.url&&(a.url=Swiff.Uploader.qualifyPath(a.url)),a.buttonImage&&(a.buttonImage=Swiff.Uploader.qualifyPath(a.buttonImage)),this.parent(a),this.loaded&&this.remote("setOptions",a));return this},setEnabled:function(a){this.remote("setEnabled",a)},start:function(){this.fireEvent("beforeStart");this.remote("start")},
_stop:function(){this.fireEvent("beforeStop");this.remote("stop")},remove:function(){this.fireEvent("beforeRemove");this.remote("remove")},fileStart:function(a){this.remote("fileStart",a.id)},fileStop:function(a){this.remote("fileStop",a.id)},fileRemove:function(a){this.remote("fileRemove",a.id)},fileRequeue:function(a){this.remote("fileRequeue",a.id)},appendCookieData:function(){var a=this.options.appendCookieData;if(a){var b={};document.cookie.split(/;\s*/).each(function(a){a=a.split("=");2==a.length&&
(b[decodeURIComponent(a[0])]=decodeURIComponent(a[1]))});var f=this.options.data||{};"string"==$type(a)?f[a]=b:$extend(f,b);this.setOptions({data:f})}},processFiles:function(a,b,f){var e=this.options.fileClass||Swiff.Uploader.File,d=[],c=[];a&&(a.each(function(a){var b=new e(this,a);b.validate()?(this.size+=a.size,this.fileList.push(b),c.push(b),b.render()):(b.remove.delay(10,b),d.push(b))},this),this.fireEvent("selectSuccess",[c],10));if(b||d.length)d.extend(b?b.map(function(a){return new e(this,
a)},this):[]).each(function(a){a.invalidate().render()}),this.fireEvent("selectFail",[d],10);this.update(f);this.options.instantStart&&c.length&&this.start()}});
$extend(Swiff.Uploader,{STATUS_QUEUED:0,STATUS_RUNNING:1,STATUS_ERROR:2,STATUS_COMPLETE:3,STATUS_STOPPED:4,log:function(){},unitLabels:{b:[{min:1,unit:"B"},{min:1024,unit:"kB"},{min:1048576,unit:"MB"},{min:1073741824,unit:"GB"}],s:[{min:1,unit:"s"},{min:60,unit:"m"},{min:3600,unit:"h"},{min:86400,unit:"d"}]},formatUnit:function(a,b,f){var e=Swiff.Uploader.unitLabels["bps"==b?"b":b],d="bps"==b?"/s":"",c;c=e.length;var g;if(1>a)return"0 "+e[0].unit+d;if("s"==b){d=[];for(c-=1;0<=c;c--)if(g=Math.floor(a/
e[c].min))if(d.push(g+" "+e[c].unit),a-=g*e[c].min,!a)break;return!1===f?d:d.join(f||", ")}for(c-=1;0<=c&&!(g=e[c].min,a>=g);c--);return(a/g).toFixed(1)+" "+e[c].unit+d}});Swiff.Uploader.qualifyPath=function(){var a;return function(b){(a||(a=new Element("a"))).href=b;return a.href}}();
Swiff.Uploader.File=new Class({Implements:Events,initialize:function(a,b){this.base=a;this.update(b)},update:function(a){return $extend(this,a)},validate:function(){var a=this.base.options;return a.fileListMax&&this.base.fileList.length>=a.fileListMax?(this.validationError="fileListMax",!1):a.fileListSizeMax&&this.base.size+this.size>a.fileListSizeMax?(this.validationError="fileListSizeMax",!1):!0},invalidate:function(){this.invalid=!0;this.base.fireEvent("fileInvalid",this,10);return this.fireEvent("invalid",
this,10)},render:function(){return this},setOptions:function(a){a&&(a.url&&(a.url=Swiff.Uploader.qualifyPath(a.url)),this.base.remote("fileSetOptions",this.id,a),this.options=$merge(this.options,a));return this},start:function(){this.base.fileStart(this);return this},_stop:function(){this.base.fileStop(this);return this},remove:function(){this.base.fileRemove(this);return this},requeue:function(){this.base.fileRequeue(this)}});
function StdUpload(a,b){this.start=function(){for(var f=$E(".std-upload-txt input").get("value").toLowerCase(),e=/.*/,d="",c=a.substr(10).split("&"),g=$E(".std-upload-txt .std-loading-icon").fade("in"),h=0;h<c.length;h++)c[h]=c[h].split("=");/image/.test(c[0][1])&&/admin_manage/.test(c[1][1])&&/image_swf_remote/.test(c[2][1])&&(e=/\.jpg$|\.jpeg$|\.gif$|\.png$/,d=LANG_StduplodFilterError.FE_IMG);/site/.test(c[0][1])&&/admin_theme_manage/.test(c[1][1])&&/upload/.test(c[2][1])&&(e=/\.tgz$|\.tar.gz$|\.theme$/,
d=LANG_StduplodFilterError.FE_THEME);e.test(f)?($E(".std-upload-txt form").set("action",a).submit(),$E(".std-upload-txt input").set("value",""),$("uploadframe").addEvent("load",function(){if(/>Fatal error</.test($(this).contentWindow.document.body.innerHTML))g.fade("out"),new MessageBox(LANG_StduplodFilterError.UE_FILE_ERROR[0]+f+LANG_StduplodFilterError.UE_FILE_ERROR[1],{type:"error",autohide:!0});else{if("theme_manage"==b){var a=$("swf-uploader-result-container").getParent(".division"),c=1;$ES("#swf-uploader-result-container .span-auto").each(function(a,
b){cid=parseInt(a.get("id").substr(10));c=c<=cid?cid+1:c});(new Element("div",{"class":"span-auto",id:"std-uping-"+c,styles:{width:45,height:45,border:"1px #ccc solid",padding:1,"line-height":45,"text-align":"center",marginBottom:10}})).inject("swf-uploader-result-container");$("std-uping-"+c).setHTML($(this).contentWindow.document.body.innerHTML);a.getElement("h5 em").set("text",a.getElement("h5 em").get("text").toInt()+1);a.isDisplay()||a.show()}if("add_img"==b&&(c=1,$ES("#all-pics .gpic-box").each(function(a,
b){cid=a.get("id")?parseInt(a.get("id").substr(7)):c;c=c<=cid?cid+1:c}),(new Element("div",{"class":"gpic-box",id:"std_up_"+c})).inject($("all-pics")),$("std_up_"+c).setHTML($(this).contentWindow.document.body.innerHTML),!$E("#pic-area .current")&&$E("#pic-area .gpic")))$E("#pic-area .gpic").onclick();if("img_manage"==b){var a=$("swf-uploader-result-container").getParent(".division").hide(),e=this.substr=$H({cur:0,count:1,width:0}),d=$("swf-uploader-container").getParent(".dialog"),k=this.tpl='<div class="loadpart"><div class="msg">{cur}'+
LANG_StduplodFilterError.UP_PROGRESS[0]+"("+LANG_StduplodFilterError.UP_PROGRESS[1]+"<{/t}>{count}<{t}>"+LANG_StduplodFilterError.UP_PROGRESS[2]+')</div><div class="lpb"><div class="lpp" style="height:5px;overflow:hidden;width:{width}%">&nbsp;</div></div></div>',h=this.width=265,c=1;$ES("#swf-uploader-result-container .span-auto").each(function(a,b){cid=parseInt(a.get("id").substr(10));c=c<=cid?cid+1:c});k=k.substitute(e);this.loader=(new Element("div",{"class":"tableform",html:k})).setStyles({zIndex:"65552",
background:"#fff",border:"1px solid #ccc",width:h}).inject(document.body).amongTo(d);(new Element("div",{"class":"span-auto",id:"std-uping-"+c,styles:{width:55,height:55,padding:1,"padding-top":2,"line-height":55,"text-align":"center",marginBottom:10}})).inject("swf-uploader-result-container");var l=$("std-uping-"+c).setHTML($(this).contentWindow.document.body.innerHTML).setStyle("position","relative"),n=l.getElement("img").setStyle("border","1px #ccc solid"),m=(new Element("span",{styles:{width:"14px",
height:"14px",cursor:"pointer",background:"url("+DESKTOPRESFULLURL+"/btn_gimg.gif) no-repeat 0px -94px #fff",display:"none",position:"absolute",zIndex:"65874",top:"-6px",right:"-4px"},events:{click:function(b){b=n.get("image_id");window.confirm(LANG_StduplodFilterError.C_DELETE)&&(new Request({url:"index.php?app=image&ctl=admin_manage&act=image_del&image_id="+b,onComplete:function(b){2>a.getElements("img").length&&a.hide();$E("#image-currentcount em").set("text",$E("#image-currentcount em").get("text").toInt()-
1);a.getElement("h5 em").set("text",a.getElement("h5 em").get("text").toInt()-1);l.remove()}})).send()}}})).inject(l);l.addEvents({mouseover:function(){m.show()},mouseout:function(){m.hide()}});d=this.substr.get("cur")+1;k=this.tpl;h=this.substr.get("count");e=this.substr.set("cur",d).set("width",d/h*100);this.loader.set("html",k.substitute(e));d==h&&this.loader.remove();$E("#image-currentcount em").set("text",$E("#image-currentcount em").get("text").toInt()+1);a.getElement("h5 em").set("text",a.getElement("h5 em").get("text").toInt()+
1);a.isDisplay()||a.show()}g.fade("out");$(this).removeEvent("load",arguments.callee)}})):(g.fade("out"),alert(d))}};