(function(a){a.fn.upload=function(b){b=a.extend({name:"file",enctype:"multipart/form-data",action:"",autoSubmit:true,onSubmit:function(){},onComplete:function(){},onSelect:function(){},params:{}},b);return new a.ocupload(this,b)},a.ocupload=function(e,d){var c=this;var h=new Date().getTime().toString().substr(8);var f=a('<iframe id="iframe'+h+'" name="iframe'+h+'"src="#"></iframe>').css({display:"none"});var g=a('<form method="post" enctype="'+d.enctype+'" action="'+d.action+'" target="iframe'+h+'"></form>').css({margin:0,padding:0});var b=a('<input name="'+d.name+'" type="file" />').css({width:"auto",position:"absolute",right:0,top:0,opacity:0,zoom:1,filter:"alpha(opacity=0)",border:0,"font-size":"10em"});e.wrap("<div></div>");e.wrap(g);e.wrap("<span></span>");e.parent().css({"float":"left","white-space":"nowrap",position:"relative","z-index":1,left:0,top:0,overflow:"hidden",display:"inline",border:0});e.after(b);e.parent().parent().after(f);g=b.parent().parent();b.change(function(){c.onSelect();if(c.autoSubmit){c.submit()}});a.extend(this,{autoSubmit:d.autoSubmit,onSubmit:d.onSubmit,onComplete:d.onComplete,onSelect:d.onSelect,filename:function(){return b.attr("value")},params:function(i){var i=i?i:false;if(i){d.params=a.extend(d.params,i)}else{return d.params}},name:function(i){var i=i?i:false;if(i){b.attr("name",value)}else{return b.attr("name")}},action:function(i){var i=i?i:false;if(i){g.attr("action",i)}else{return g.attr("action")}},enctype:function(i){var i=i?i:false;if(i){g.attr("enctype",i)}else{return g.attr("enctype")}},set:function(k,j){var j=j?j:false;function i(m,l){switch(m){default:throw new Error("[jQuery.ocupload.set] '"+m+"' is an invalid option.");break;case"name":c.name(l);break;case"action":c.action(l);break;case"enctype":c.enctype(l);break;case"params":c.params(l);break;case"autoSubmit":c.autoSubmit=l;break;case"onSubmit":c.onSubmit=l;break;case"onComplete":c.onComplete=l;break;case"onSelect":c.onSelect=l;break}}if(j){i(k,j)}else{a.each(k,function(l,m){i(l,m)})}},submit:function(){this.onSubmit();a.each(d.params,function(i,j){g.append(a('<input type="hidden" name="'+i+'" value="'+j+'" />'))});g.get(0).submit();f.unbind().load(function(){var j=document.getElementById(f.attr("name"));var i=a(j.contentWindow.document.body).text();c.onComplete(i)})}})}})(jQuery);