var FileProgress=new Class({initialize:function(d,c){var b=c.getElement(".uploader-thumbs");var e=d.id;if(!$(e)){var a=new Element("li",{id:e,"class":"waiting",html:"loading"}).inject(b);this.prog=a}else{this.prog=$(e)}},working:function(c){if(!this.prog.hasClass("working")){this.prog.removeClass("waiting").addClass("working").empty();var d=new Element("div").addClass("working-bar").setStyle("background-position","10px 68px").inject(this.prog);var b=new Element("span").setProperty("id","percent").inject(d);var b=new Element("span").addClass("f-14").setHTML("%").inject(d)}if(c==0){c=10}var a=75-((c/100)*75);a=a.round();var d=this.prog.getElement(".working-bar");d.setStyle("background-position","0px "+a+"px");var b=d.getElement("#percent");b.setHTML(c)},finished:function(b){this.prog.removeClass("working").removeClass("waiting").empty();var a=new Element("img").setProperty("src",b).setStyle("opacity",0).inject(this.prog);new Fx.Tween(a,$extend({property:"opacity"},{duration:"3000",transition:Fx.Transitions.linear})).start(0,1)}});function fileDialogStart(){}function fileQueued(c){try{var a=new FileProgress(c,this.customSettings.progressTarget);if(this.customSettings.count_in_queue==0){window.fireEvent("images_queued")}this.customSettings.count_in_queue++}catch(b){this.debug(b)}}function fileQueueError(b,d,c){try{if(d===SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED){alert("You have attempted to queue too many files.\n"+(c===0?"You have reached the upload limit.":"You may select "+(c>1?"up to "+c+" files.":"one file.")));return}switch(d){case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:$("uploader-error").innerHTML="File is too big.";this.debug("Error Code: File too big, File name: "+b.name+", File size: "+b.size+", Message: "+c);break;case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:$("uploader-error").innerHTML="Cannot upload Zero Byte files.";this.debug("Error Code: Zero byte file, File name: "+b.name+", File size: "+b.size+", Message: "+c);break;case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:$("uploader-error").innerHTML="Invalid File Type.";this.debug("Error Code: Invalid File Type, File name: "+b.name+", File size: "+b.size+", Message: "+c);break;case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:alert("You have selected too many files.  "+(c>1?"You may only add "+c+" more files":"You cannot add any more files."));break;default:if(b!==null){$("uploader-error").innerHTML="Unhandled Error"}this.debug("Error Code: "+d+", File name: "+b.name+", File size: "+b.size+", Message: "+c);break}}catch(a){this.debug(a)}}function fileDialogComplete(a,c){try{this.startUpload()}catch(b){this.debug(b)}}function uploadStart(b){try{this.customSettings.progressTarget.getElement(".uploader-error").innerHTML="Uploading...";window.fireEvent("upload_start")}catch(a){}return true}function uploadProgress(c,f,e){var d=Math.ceil((f/e)*100);var a=new FileProgress(c,this.customSettings.progressTarget);a.working(d);try{}catch(b){this.debug(b)}}function uploadSuccess(d,b){try{response=JSON.decode(b);if(response.success=="true"){this.customSettings.image_ids.include(response.image_id);this.customSettings.count_of_uploads++;var a=new FileProgress(d,this.customSettings.progressTarget);a.finished(response.image_thumb_url)}else{alert(response.error)}}catch(c){this.debug(c)}}function uploadComplete(b){try{if(this.getStats().files_queued===0){window.fireEvent("images_done_uploading",[this.customSettings])}else{this.startUpload()}}catch(a){this.debug(a)}}function uploadError(b,d,c){try{switch(d){case SWFUpload.UPLOAD_ERROR.HTTP_ERROR:$("uploader-error").innerHTML="Upload Error: "+c;this.debug("Error Code: HTTP Error, File name: "+b.name+", Message: "+c);break;case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL:$("uploader-error").innerHTML="Configuration Error";this.debug("Error Code: No backend file, File name: "+b.name+", Message: "+c);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED:$("uploader-error").innerHTML="Upload Failed.";this.debug("Error Code: Upload Failed, File name: "+b.name+", File size: "+b.size+", Message: "+c);break;case SWFUpload.UPLOAD_ERROR.IO_ERROR:$("uploader-error").innerHTML="Server (IO) Error";this.debug("Error Code: IO Error, File name: "+b.name+", Message: "+c);break;case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR:$("uploader-error").innerHTML="Security Error";this.debug("Error Code: Security Error, File name: "+b.name+", Message: "+c);break;case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED:$("uploader-error").innerHTML="Upload limit exceeded.";this.debug("Error Code: Upload Limit Exceeded, File name: "+b.name+", File size: "+b.size+", Message: "+c);break;case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND:$("uploader-error").innerHTML="File not found.";this.debug("Error Code: The file was not found, File name: "+b.name+", File size: "+b.size+", Message: "+c);break;case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED:$("uploader-error").innerHTML="Failed Validation.  Upload skipped.";this.debug("Error Code: File Validation Failed, File name: "+b.name+", File size: "+b.size+", Message: "+c);break;case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED:$("uploader-error").innerHTML="Cancelled";break;case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED:$("uploader-error").innerHTML="Stopped";break;default:$("uploader-error").innerHTML="Unhandled Error: "+error_code;this.debug("Error Code: "+d+", File name: "+b.name+", File size: "+b.size+", Message: "+c);break}}catch(a){this.debug(a)}};