Function.prototype.bind||(Function.prototype.bind=function(){var a=this,b=[].slice.call(arguments),c=b.shift();return function(){a.apply(c,b.concat([].slice.call(arguments)))}});var ajaxUpload=function(a){function c(a,b){var c=a.offset();b.css({left:c.left,top:c.top})}var b={action:"",done:function(){},fail:function(){}},d=function(c,d){if(this.button="string"==typeof c?a(c):c,this.params=a.extend({},b,d||{}),a("#ajaxUploadIframe").length)this.iframe=a("#ajaxUploadIframe");else{try{iframe=document.createElement('<iframe name="ajaxUploadIframe">')}catch(f){iframe=document.createElement("iframe"),iframe.name="ajaxUploadIframe"}this.iframe=a(iframe).attr({id:"ajaxUploadIframe"}).css("display","none")}this.form=a("<form>",{target:"ajaxUploadIframe",enctype:"multipart/form-data",method:"post",action:this.params.action}).css({"z-index":9999,opacity:0,position:"absolute",cursor:"pointer",overflow:"hidden"}),this.input=a("<input>",{name:this.params.name,type:"file"}).css({height:this.button.outerHeight(),width:this.button.outerWidth()}).appendTo(this.form),this.init()};return d.prototype={init:function(){var b=this,d=a("body");c(this.button,this.form),d.append(this.form),!a("#ajaxUploadIframe").length&&d.append(this.iframe),this.input.change(this.change.bind(this)),this.form.submit(this.submit.bind(this)),this.button.mouseenter(function(){b.input.css({height:b.button.outerHeight(),width:b.button.outerWidth()+10}),c(b.button,b.form)})},change:function(){var b=this.input.val().replace(/^[\w\W]+\.(\w+)$/,"$1").toLowerCase();return b&&a.isArray(this.params.format)&&-1==a.inArray(b,this.params.format)?(alert("\u652f\u6301"+this.params.format.join(", ")),void 0):(this.params.start.call(this),this.form.submit(),void 0)},submit:function(){var b,d,c=this,e=!0;this.iframe.bind("load",function(){if(b=c.iframe.contents().find("body"),c.params.json)try{d=a.parseJSON(b.html())}catch(f){c.params.fail.call(c),e=!1}else d=b.html();e&&c.params.done.call(c,d),setTimeout(function(){b.html("")},1),c.iframe.unbind("load")})}},d}(jQuery);