(function(j){function i(c,d){d=d||{};if(d.onSubmit){if(d.onSubmit.call(c)==false){return}}var e=j(c);if(d.url){e.attr("action",d.url)}var f="easyui_frame_"+(new Date().getTime());var p=j("<iframe id="+f+" name="+f+"></iframe>").attr("src",window.ActiveXObject?"javascript:false":"about:blank").css({position:"absolute",top:-1000,left:-1000});var a=e.attr("target"),b=e.attr("action");e.attr("target",f);try{p.appendTo("body");p.bind("load",r);e[0].submit()}finally{e.attr("action",b);a?e.attr("target",a):e.removeAttr("target")}var q=10;function r(){p.unbind();var o=j("#"+f).contents().find("body");var t=o.html();if(t==""){if(--q){setTimeout(r,100);return}return}var n=o.find(">textarea");if(n.length){t=n.val()}else{var m=o.find(">pre");if(m.length){t=m.html()}}if(d.success){d.success(t)}setTimeout(function(){p.unbind();p.remove()},100)}}function k(e,f){if(!j.data(e,"form")){j.data(e,"form",{options:j.extend({},j.fn.form.defaults)})}var n=j.data(e,"form").options;if(typeof f=="string"){var a={};if(n.onBeforeLoad.call(e,a)==false){return}j.ajax({url:f,data:a,dataType:"json",success:function(m){b(m)},error:function(){n.onLoadError.apply(e,arguments)}})}else{b(f)}function b(t){var u=j(e);for(var w in t){var m=t[w];var x=c(w,m);if(!x.length){var v=u.find('input[numberboxName="'+w+'"]');if(v.length){v.numberbox("setValue",m)}else{j('input[name="'+w+'"]',u).val(m);j('textarea[name="'+w+'"]',u).val(m);j('select[name="'+w+'"]',u).val(m)}}d(w,m)}n.onLoadSuccess.call(e,t);h(e)}function c(r,m){var t=j(e);var s=j('input[name="'+r+'"][type=radio], input[name="'+r+'"][type=checkbox]',t);j.fn.prop?s.prop("checked",false):s.attr("checked",false);s.each(function(){var o=j(this);console.log(r+":"+o.val()+","+m);if(o.val()==String(m)){j.fn.prop?o.prop("checked",true):o.attr("checked",true)}});return s}function d(z,v){var w=j(e);var m=["combobox","combotree","combogrid","datetimebox","datebox","combo"];var u=w.find('[comboName="'+z+'"]');if(u.length){for(var x=0;x<m.length;x++){var y=m[x];if(u.hasClass(y+"-f")){if(u[y]("options").multiple){u[y]("setValues",v)}else{u[y]("setValue",v)}return}}}}}function l(a){j("input,select,textarea",a).each(function(){var b=this.type,d=this.tagName.toLowerCase();if(b=="text"||b=="hidden"||b=="password"||d=="textarea"){this.value=""}else{if(b=="file"){var c=j(this);c.after(c.clone().val(""));c.remove()}else{if(b=="checkbox"||b=="radio"){this.checked=false}else{if(d=="select"){this.selectedIndex=-1}}}}});if(j.fn.combo){j(".combo-f",a).combo("clear")}if(j.fn.combobox){j(".combobox-f",a).combobox("clear")}if(j.fn.combotree){j(".combotree-f",a).combotree("clear")}if(j.fn.combogrid){j(".combogrid-f",a).combogrid("clear")}h(a)}function g(c){var a=j.data(c,"form").options;var b=j(c);b.unbind(".form").bind("submit.form",function(){setTimeout(function(){i(c,a)},0);return false})}function h(a){if(j.fn.validatebox){var c=j(".validatebox-text",a);if(c.length){c.validatebox("validate");c.trigger("focus");c.trigger("blur");var b=j(".validatebox-invalid:first",a).focus();return b.length==0}}return true}j.fn.form=function(a,b){if(typeof a=="string"){return j.fn.form.methods[a](this,b)}a=a||{};return this.each(function(){if(!j.data(this,"form")){j.data(this,"form",{options:j.extend({},j.fn.form.defaults,a)})}g(this)})};j.fn.form.methods={submit:function(a,b){return a.each(function(){i(this,j.extend({},j.fn.form.defaults,b||{}))})},load:function(a,b){return a.each(function(){k(this,b)})},clear:function(a){return a.each(function(){l(this)})},validate:function(a){return h(a[0])}};j.fn.form.defaults={url:null,onSubmit:function(){return j(this).form("validate")},success:function(a){},onBeforeLoad:function(a){},onLoadSuccess:function(a){},onLoadError:function(){}}})(jQuery);