!function(e){function t(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}e.fn.ajaxSubmit=function(a){function r(t){for(var r=new FormData,n=0;n').attr("value",f.extraData[c]).appendTo(T)[0]);f.iframeTarget||(p.appendTo("body"),v.attachEvent?v.attachEvent("onload",s):v.addEventListener("load",s,!1)),setTimeout(a,15),T.submit()}finally{T.setAttribute("action",o),r?T.setAttribute("target",r):u.removeAttr("target"),e(l).remove()}}function s(a){if(!h.aborted&&!E){try{L=n(v)}catch(r){t("cannot access response document: ",r),a=k}if(a===j&&h)return h.abort("timeout"),void 0;if(a==k&&h)return h.abort("server abort"),void 0;if(L&&L.location.href!=f.iframeSrc||b){v.detachEvent?v.detachEvent("onload",s):v.removeEventListener("load",s,!1);var i,o="success";try{if(b)throw"timeout";var u="xml"==f.dataType||L.XMLDocument||e.isXMLDoc(L);if(t("isXml="+u),!u&&window.opera&&(null==L.body||""==L.body.innerHTML)&&--M)return t("requeing onLoad callback, DOM not available"),setTimeout(s,250),void 0;var l=L.body?L.body:L.documentElement;h.responseText=l?l.innerHTML:null,h.responseXML=L.XMLDocument?L.XMLDocument:L,u&&(f.dataType="xml"),h.getResponseHeader=function(e){var t={"content-type":f.dataType};return t[e]},l&&(h.status=Number(l.getAttribute("status"))||h.status,h.statusText=l.getAttribute("statusText")||h.statusText);var c=(f.dataType||"").toLowerCase(),d=/(json|script|text)/.test(c);if(d||f.textarea){var g=L.getElementsByTagName("textarea")[0];if(g)h.responseText=g.value,h.status=Number(g.getAttribute("status"))||h.status,h.statusText=g.getAttribute("statusText")||h.statusText;else if(d){var x=L.getElementsByTagName("pre")[0],T=L.getElementsByTagName("body")[0];x?h.responseText=x.textContent?x.textContent:x.innerText:T&&(h.responseText=T.textContent?T.textContent:T.innerText)}}else"xml"!=c||h.responseXML||null==h.responseText||(h.responseXML=F(h.responseText));try{A=O(h,c,f)}catch(a){o="parsererror",h.error=i=a||o}}catch(a){t("error caught: ",a),o="error",h.error=i=a||o}h.aborted&&(t("upload aborted"),o=null),h.status&&(o=h.status>=200&&h.status<300||304===h.status?"success":"error"),"success"===o?(f.success&&f.success.call(f.context,A,"success",h),m&&e.event.trigger("ajaxSuccess",[h,f])):o&&(void 0==i&&(i=h.statusText),f.error&&f.error.call(f.context,h,o,i),m&&e.event.trigger("ajaxError",[h,f,i])),m&&e.event.trigger("ajaxComplete",[h,f]),m&&!--e.active&&e.event.trigger("ajaxStop"),f.complete&&f.complete.call(f.context,h,o),E=!0,f.timeout&&clearTimeout(y),setTimeout(function(){f.iframeTarget||p.remove(),h.responseXML=null},100)}}}var l,c,f,m,d,p,v,h,g,x,b,y,T=u[0],S=!!e.fn.prop;if(r)if(S)for(c=0;c'),p.css({position:"absolute",top:"-1000px",left:"-1000px"})),v=p[0],h={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(a){var r="timeout"===a?"timeout":"aborted";t("aborting upload... "+r),this.aborted=1,p.attr("src",f.iframeSrc),h.error=r,f.error&&f.error.call(f.context,h,r,a),m&&e.event.trigger("ajaxError",[h,f,r]),f.complete&&f.complete.call(f.context,h,r)}},m=f.global,m&&!e.active++&&e.event.trigger("ajaxStart"),m&&e.event.trigger("ajaxSend",[h,f]),f.beforeSend&&f.beforeSend.call(f.context,h,f)===!1)return f.global&&e.active--,void 0;if(!h.aborted){g=T.clk,g&&(x=g.name,x&&!g.disabled&&(f.extraData=f.extraData||{},f.extraData[x]=g.value,"image"==g.type&&(f.extraData[x+".x"]=T.clk_x,f.extraData[x+".y"]=T.clk_y)));var j=1,k=2,w=e("meta[name=csrf-token]").attr("content"),D=e("meta[name=csrf-param]").attr("content");D&&w&&(f.extraData=f.extraData||{},f.extraData[D]=w),f.forceSync?o():setTimeout(o,10);var A,L,E,M=50,F=e.parseXML||function(e,t){return window.ActiveXObject?(t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!=t.documentElement.nodeName?t:null},X=e.parseJSON||function(e){return window.eval("("+e+")")},O=function(t,a,r){var n=t.getResponseHeader("content-type")||"",i="xml"===a||!a&&n.indexOf("xml")>=0,o=i?t.responseXML:t.responseText;return i&&"parsererror"===o.documentElement.nodeName&&e.error&&e.error("parsererror"),r&&r.dataFilter&&(o=r.dataFilter(o,a)),"string"==typeof o&&("json"===a||!a&&n.indexOf("json")>=0?o=X(o):("script"===a||!a&&n.indexOf("javascript")>=0)&&e.globalEval(o)),o}}}if(!this.length)return t("ajaxSubmit: skipping submit process - no element selected"),this;var i,o,s,u=this;"function"==typeof a&&(a={success:a}),i=this.attr("method"),o=this.attr("action"),s="string"==typeof o?e.trim(o):"",s=s||window.location.href||"",s&&(s=(s.match(/^([^#]+)/)||[])[1]),a=e.extend(!0,{url:s,success:e.ajaxSettings.success,type:i||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},a);var l={};if(this.trigger("form-pre-serialize",[this,a,l]),l.veto)return t("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(a.beforeSerialize&&a.beforeSerialize(this,a)===!1)return t("ajaxSubmit: submit aborted via beforeSerialize callback"),this;var c=a.traditional;void 0===c&&(c=e.ajaxSettings.traditional);var f,m=this.formToArray(a.semantic);if(a.data&&(a.extraData=a.data,f=e.param(a.data,c)),a.beforeSubmit&&a.beforeSubmit(m,this,a)===!1)return t("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[m,this,a,l]),l.veto)return t("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;var d=e.param(m,c);f&&(d=d?d+"&"+f:f),"GET"==a.type.toUpperCase()?(a.url+=(a.url.indexOf("?")>=0?"&":"?")+d,a.data=null):a.data=d;var p=[];if(a.resetForm&&p.push(function(){u.resetForm()}),a.clearForm&&p.push(function(){u.clearForm(a.includeHidden)}),!a.dataType&&a.target){var v=a.success||function(){};p.push(function(t){var r=a.replaceTarget?"replaceWith":"html";e(a.target)[r](t).each(v,arguments)})}else a.success&&p.push(a.success);a.success=function(e,t,r){for(var n=a.context||a,i=0,o=p.length;o>i;i++)p[i].apply(n,[e,t,r||u,u])};var h=e("input:file:enabled[value]",this),g=h.length>0,x="multipart/form-data",b=u.attr("enctype")==x||u.attr("encoding")==x,y=!!(g&&h.get(0).files&&window.FormData);t("fileAPI :"+y);var T=(g||b)&&!y;return a.iframe!==!1&&(a.iframe||T)?a.closeKeepAlive?e.get(a.closeKeepAlive,function(){n(m)}):n(m):(g||b)&&y?(a.progress=a.progress||e.noop,r(m)):e.ajax(a),this.trigger("form-submit-notify",[this,a]),this},e.fn.ajaxForm=function(a){if(0===this.length){var r={s:this.selector,c:this.context};return!e.isReady&&r.s?(t("DOM not ready, queuing ajaxForm"),e(function(){e(r.s,r.c).ajaxForm(a)}),this):(t("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)")),this)}return this.ajaxFormUnbind().bind("submit.form-plugin",function(t){t.isDefaultPrevented()||(t.preventDefault(),e(this).ajaxSubmit(a))}).bind("click.form-plugin",function(t){var a=t.target,r=e(a);if(!r.is(":submit,input:image")){var n=r.closest(":submit");if(0==n.length)return;a=n[0]}var i=this;if(i.clk=a,"image"==a.type)if(void 0!=t.offsetX)i.clk_x=t.offsetX,i.clk_y=t.offsetY;else if("function"==typeof e.fn.offset){var o=r.offset();i.clk_x=t.pageX-o.left,i.clk_y=t.pageY-o.top}else i.clk_x=t.pageX-a.offsetLeft,i.clk_y=t.pageY-a.offsetTop;setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)})},e.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")},e.fn.formToArray=function(t){var a=[];if(0===this.length)return a;var r=this[0],n=t?r.getElementsByTagName("*"):r.elements;if(!n)return a;var i,o,s,u,l,c,f;for(i=0,c=n.length;c>i;i++)if(l=n[i],s=l.name)if(t&&r.clk&&"image"==l.type)l.disabled||r.clk!=l||(a.push({name:s,value:e(l).val(),type:l.type}),a.push({name:s+".x",value:r.clk_x},{name:s+".y",value:r.clk_y}));else if(u=e.fieldValue(l,!0),u&&u.constructor==Array)for(o=0,f=u.length;f>o;o++)a.push({name:s,value:u[o]});else null!==u&&"undefined"!=typeof u&&a.push({name:s,value:u,type:l.type});if(!t&&r.clk){var m=e(r.clk),d=m[0];s=d.name,s&&!d.disabled&&"image"==d.type&&(a.push({name:s,value:m.val()}),a.push({name:s+".x",value:r.clk_x},{name:s+".y",value:r.clk_y}))}return a},e.fn.formSerialize=function(t){return e.param(this.formToArray(t))},e.fn.fieldSerialize=function(t){var a=[];return this.each(function(){var r=this.name;if(r){var n=e.fieldValue(this,t);if(n&&n.constructor==Array)for(var i=0,o=n.length;o>i;i++)a.push({name:r,value:n[i]});else null!==n&&"undefined"!=typeof n&&a.push({name:this.name,value:n})}}),e.param(a)},e.fn.fieldValue=function(t){for(var a=[],r=0,n=this.length;n>r;r++){var i=this[r],o=e.fieldValue(i,t);null===o||"undefined"==typeof o||o.constructor==Array&&!o.length||(o.constructor==Array?e.merge(a,o):a.push(o))}return a},e.fieldValue=function(t,a){var r=t.name,n=t.type,i=t.tagName.toLowerCase();if(void 0===a&&(a=!0),a&&(!r||t.disabled||"reset"==n||"button"==n||("checkbox"==n||"radio"==n)&&!t.checked||("submit"==n||"image"==n)&&t.form&&t.form.clk!=t||"select"==i&&-1==t.selectedIndex))return null;if("select"==i){var o=t.selectedIndex;if(0>o)return null;for(var s=[],u=t.options,l="select-one"==n,c=l?o+1:u.length,f=l?o:0;c>f;f++){var m=u[f];if(m.selected){var d=m.value;if(d||(d=m.attributes&&m.attributes.value&&!m.attributes.value.specified?m.text:m.value),l)return d;s.push(d)}}return s}return e(t).val()},e.fn.clearForm=function(t){return this.each(function(){e("input,select,textarea",this).clearFields(t)})},e.fn.clearFields=e.fn.clearInputs=function(e){var t=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var a=this.type,r=this.tagName.toLowerCase();t.test(a)||"textarea"==r||e&&/hidden/.test(a)?this.value="":"checkbox"==a||"radio"==a?this.checked=!1:"select"==r&&(this.selectedIndex=-1)})},e.fn.resetForm=function(){return this.each(function(){("function"==typeof this.reset||"object"==typeof this.reset&&!this.reset.nodeType)&&this.reset()})},e.fn.enable=function(e){return void 0===e&&(e=!0),this.each(function(){this.disabled=!e})},e.fn.selected=function(t){return void 0===t&&(t=!0),this.each(function(){var a=this.type;if("checkbox"==a||"radio"==a)this.checked=t;else if("option"==this.tagName.toLowerCase()){var r=e(this).parent("select");t&&r[0]&&"select-one"==r[0].type&&r.find("option").selected(!1),this.selected=t}})},e.fn.ajaxSubmit.debug=!1}(jQuery);