var S3Uploader=new Class({Implements:[Events,Options],options:{iframeUrl:"http://upload.whiskeymedia.com.s3.amazonaws.com/xhr_upload.html",iframeJs:null,iframeCss:null,multiple:false},initialize:function(b){this.setOptions(b);var a=this;this.iframe=new IFrame({src:this.options.iframeUrl+"?"+(new Date().getTime()),"class":"s3-upload",styles:{width:121,height:122},events:{load:function(){a.iframe.contentWindow.postMessage(JSON.stringify({js:a.options.iframeJs?a.fullUrl(a.options.iframeJs)+"?ts="+(new Date().getTime()):false,css:a.options.iframeCss?a.fullUrl(a.options.iframeCss)+"?ts="+(new Date().getTime()):false,accept:a.options.accept,multiple:a.options.multiple,sessionid:Cookie.read("sessionid"),fields:JSON.stringify({policy:"eyJleHBpcmF0aW9uIjoiMjAyMC0wMS0wMVQwMDowMDowMFoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJ1cGxvYWQud2hpc2tleW1lZGlhLmNvbSJ9LFsic3RhcnRzLXdpdGgiLCIka2V5IiwidXBsb2Fkcy8iXSx7ImFjbCI6InByaXZhdGUifSxbInN0YXJ0cy13aXRoIiwiJENvbnRlbnQtVHlwZSIsIiJdLFsiY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTAwMDAwMDAwMDBdXX0=",AWSAccessKeyId:"AKIAIIA7XPBNTZEXVRJQ",acl:"private",signature:"Ph1gvxMj5hHkWDXK5n/hltfxM6A=","Content-Type":"image/jpeg"})}),a.iframe.src)}}});this.boundDisplayMessage=this.displayMessage.bind(this);if(window.addEventListener){window.addEventListener("message",this.boundDisplayMessage,false)}else{if(window.attachEvent){window.attachEvent("onmessage",this.boundDisplayMessage)}}window.onbeforeunload=function(){if(this.uploading){return"You are still uploading a file. Leaving the page will stop the upload.\nAre you sure you want to leave?"}}.bind(this)},destroy:function(){if(window.removeEventListener){window.removeEventListener("message",this.boundDisplayMessage,false)}else{if(window.detachEvent){window.detachEvent("onmessage",this.boundDisplayMessage)}}},fullUrl:function(a){return a.charAt(0)=="/"?document.location.protocol+"//"+document.location.host+a:a},displayMessage:function(b){if(typeof b.data!="string"||b.origin.split("://")[1]!=this.options.iframeUrl.split("://")[1].split("/")[0]){return}var c=JSON.parse(b.data),a=this;switch(c.fn){case"start":this.uploading=true;break;case"done":this.uploading=false;break;default:break}this.fireEvent(c.fn,[c.key,c.args])}});
