(function(n){"use strict";function r(t){var i=t.data;t.isDefaultPrevented()||(t.preventDefault(),n(this).ajaxSubmit(i))}function u(t){var r=t.target,u=n(r),f,i,e;if(!u.is("[type=submit],[type=image]")){if(f=u.closest("[type=submit]"),0===f.length)return;r=f[0]}i=this;(i.clk=r,"image"==r.type)&&(void 0!==t.offsetX?(i.clk_x=t.offsetX,i.clk_y=t.offsetY):"function"==typeof n.fn.offset?(e=u.offset(),i.clk_x=t.pageX-e.left,i.clk_y=t.pageY-e.top):(i.clk_x=t.pageX-r.offsetLeft,i.clk_y=t.pageY-r.offsetTop));setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}function t(){if(n.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)}}var i={},f;i.fileapi=void 0!==n("<input type='file'/>").get(0).files;i.formdata=void 0!==window.FormData;f=!!n.fn.prop;n.fn.attr2=function(){if(!f)return this.attr.apply(this,arguments);var n=this.prop.apply(this,arguments);return n&&n.jquery||"string"==typeof n?n:this.attr.apply(this,arguments)};n.fn.ajaxSubmit=function(r){function et(t){for(var f,u=n.param(t,r.traditional).split("&"),o=u.length,e=[],i=0;o>i;i++)u[i]=u[i].replace(/\+/g," "),f=u[i].split("="),e.push([decodeURIComponent(f[0]),decodeURIComponent(f[1])]);return e}function ot(t){for(var f,u,o,e=new FormData,i=0;t.length>i;i++)e.append(t[i].name,t[i].value);if(r.extraData)for(f=et(r.extraData),i=0;f.length>i;i++)f[i]&&e.append(f[i][0],f[i][1]);return r.data=null,u=n.extend(!0,{},n.ajaxSettings,r,{contentType:!1,processData:!1,cache:!1,type:h||"POST"}),r.uploadProgress&&(u.xhr=function(){var t=n.ajaxSettings.xhr();return t.upload&&t.upload.addEventListener("progress",function(n){var t=0,i=n.loaded||n.position,u=n.total;n.lengthComputable&&(t=Math.ceil(100*(i/u)));r.uploadProgress(n,i,u,t)},!1),t}),u.data=null,o=u.beforeSend,u.beforeSend=function(n,t){t.data=e;o&&o.call(this,n,t)},n.ajax(u)}function d(i){function ut(n){var i=null;try{n.contentWindow&&(i=n.contentWindow.document)}catch(r){t("cannot get iframe.contentWindow document: "+r)}if(i)return i;try{i=n.contentDocument?n.contentDocument:n.document}catch(r){t("cannot get iframe.contentDocument: "+r);i=n.document}return i}function ft(){function f(){try{var n=ut(a).readyState;t("state = "+n);n&&"uninitialized"==n.toLowerCase()&&setTimeout(f,50)}catch(i){t("Server abort: ",i," (",i.name,")");b(rt);g&&clearTimeout(g);g=void 0}}var o=u.attr2("target"),s=u.attr2("action"),r,i,c;l.setAttribute("target",d);h||l.setAttribute("method","POST");s!=e.url&&l.setAttribute("action",e.url);e.skipEncodingOverride||h&&!/post/i.test(h)||u.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});e.timeout&&(g=setTimeout(function(){it=!0;b(et)},e.timeout));r=[];try{if(e.extraData)for(i in e.extraData)e.extraData.hasOwnProperty(i)&&(n.isPlainObject(e.extraData[i])&&e.extraData[i].hasOwnProperty("name")&&e.extraData[i].hasOwnProperty("value")?r.push(n('<input type="hidden" name="'+e.extraData[i].name+'">').val(e.extraData[i].value).appendTo(l)[0]):r.push(n('<input type="hidden" name="'+i+'">').val(e.extraData[i]).appendTo(l)[0]));e.iframeTarget||(v.appendTo("body"),a.attachEvent?a.attachEvent("onload",b):a.addEventListener("load",b,!1));setTimeout(f,15);try{l.submit()}catch(y){c=document.createElement("form").submit;c.apply(l)}}finally{l.setAttribute("action",s);o?l.setAttribute("target",o):u.removeAttr("target");n(r).remove()}}function b(i){var u,r,w,f,k,d,h,c,l;if(!o.aborted&&!ct){if(s=ut(a),s||(t("cannot access response document"),i=rt),i===et&&o)return o.abort("timeout"),y.reject(o,"timeout"),void 0;if(i==rt&&o)return o.abort("server abort"),y.reject(o,"error","server abort"),void 0;if(s&&s.location.href!=e.iframeSrc||it){a.detachEvent?a.detachEvent("onload",b):a.removeEventListener("load",b,!1);r="success";try{if(it)throw"timeout";if(w="xml"==e.dataType||s.XMLDocument||n.isXMLDoc(s),t("isXml="+w),!w&&window.opera&&(null===s.body||!s.body.innerHTML)&&--lt)return t("requeing onLoad callback, DOM not available"),setTimeout(b,250),void 0;f=s.body?s.body:s.documentElement;o.responseText=f?f.innerHTML:null;o.responseXML=s.XMLDocument?s.XMLDocument:s;w&&(e.dataType="xml");o.getResponseHeader=function(n){var t={"content-type":e.dataType};return t[n]};f&&(o.status=Number(f.getAttribute("status"))||o.status,o.statusText=f.getAttribute("statusText")||o.statusText);k=(e.dataType||"").toLowerCase();d=/(json|script|text)/.test(k);d||e.textarea?(h=s.getElementsByTagName("textarea")[0],h?(o.responseText=h.value,o.status=Number(h.getAttribute("status"))||o.status,o.statusText=h.getAttribute("statusText")||o.statusText):d&&(c=s.getElementsByTagName("pre")[0],l=s.getElementsByTagName("body")[0],c?o.responseText=c.textContent?c.textContent:c.innerText:l&&(o.responseText=l.textContent?l.textContent:l.innerText))):"xml"==k&&!o.responseXML&&o.responseText&&(o.responseXML=at(o.responseText));try{ht=yt(o,k,e)}catch(nt){r="parsererror";o.error=u=nt||r}}catch(nt){t("error caught: ",nt);r="error";o.error=u=nt||r}o.aborted&&(t("upload aborted"),r=null);o.status&&(r=o.status>=200&&300>o.status||304===o.status?"success":"error");"success"===r?(e.success&&e.success.call(e.context,ht,"success",o),y.resolve(o.responseText,"success",o),p&&n.event.trigger("ajaxSuccess",[o,e])):r&&(void 0===u&&(u=o.statusText),e.error&&e.error.call(e.context,o,r,u),y.reject(o,"error",u),p&&n.event.trigger("ajaxError",[o,e,u]));p&&n.event.trigger("ajaxComplete",[o,e]);p&&!--n.active&&n.event.trigger("ajaxStop");e.complete&&e.complete.call(e.context,o,r);ct=!0;e.timeout&&clearTimeout(g);setTimeout(function(){e.iframeTarget||v.remove();o.responseXML=null},100)}}}var tt,nt,e,p,d,v,a,o,k,w,it,g,l=u[0],y=n.Deferred();if(i)for(nt=0;c.length>nt;nt++)tt=n(c[nt]),f?tt.prop("disabled",!1):tt.removeAttr("disabled");if(e=n.extend(!0,{},n.ajaxSettings,r),e.context=e.context||e,d="jqFormIO"+(new Date).getTime(),e.iframeTarget?(v=n(e.iframeTarget),w=v.attr2("name"),w?d=w:v.attr2("name",d)):(v=n('<iframe name="'+d+'" src="'+e.iframeSrc+'" />'),v.css({position:"absolute",top:"-1000px",left:"-1000px"})),a=v[0],o={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(i){var r="timeout"===i?"timeout":"aborted";t("aborting upload... "+r);this.aborted=1;try{a.contentWindow.document.execCommand&&a.contentWindow.document.execCommand("Stop")}catch(u){}v.attr("src",e.iframeSrc);o.error=r;e.error&&e.error.call(e.context,o,r,i);p&&n.event.trigger("ajaxError",[o,e,r]);e.complete&&e.complete.call(e.context,o,r)}},p=e.global,p&&0==n.active++&&n.event.trigger("ajaxStart"),p&&n.event.trigger("ajaxSend",[o,e]),e.beforeSend&&e.beforeSend.call(e.context,o,e)===!1)return e.global&&n.active--,y.reject(),y;if(o.aborted)return y.reject(),y;k=l.clk;k&&(w=k.name,w&&!k.disabled&&(e.extraData=e.extraData||{},e.extraData[w]=k.value,"image"==k.type&&(e.extraData[w+".x"]=l.clk_x,e.extraData[w+".y"]=l.clk_y)));var et=1,rt=2,ot=n("meta[name=csrf-token]").attr("content"),st=n("meta[name=csrf-param]").attr("content");st&&ot&&(e.extraData=e.extraData||{},e.extraData[st]=ot);e.forceSync?ft():setTimeout(ft,10);var ht,s,ct,lt=50,at=n.parseXML||function(n,t){return window.ActiveXObject?(t=new ActiveXObject("Microsoft.XMLDOM"),t.async="false",t.loadXML(n)):t=(new DOMParser).parseFromString(n,"text/xml"),t&&t.documentElement&&"parsererror"!=t.documentElement.nodeName?t:null},vt=n.parseJSON||function(e){return window.eval("("+e+")")},yt=function(t,i,r){var f=t.getResponseHeader("content-type")||"",e="xml"===i||!i&&f.indexOf("xml")>=0,u=e?t.responseXML:t.responseText;return e&&"parsererror"===u.documentElement.nodeName&&n.error&&n.error("parsererror"),r&&r.dataFilter&&(u=r.dataFilter(u,i)),"string"==typeof u&&("json"===i||!i&&f.indexOf("json")>=0?u=vt(u):("script"===i||!i&&f.indexOf("javascript")>=0)&&n.globalEval(u)),u};return y}var h,b,e,u,a,v,y,c,o,l,s,g,nt,tt,p,ft,w;if(!this.length)return t("ajaxSubmit: skipping submit process - no element selected"),this;if(u=this,"function"==typeof r?r={success:r}:void 0===r&&(r={}),h=r.type||this.attr2("method"),b=r.url||this.attr2("action"),e="string"==typeof b?n.trim(b):"",e=e||window.location.href||"",e&&(e=(e.match(/^([^#]+)/)||[])[1]),r=n.extend(!0,{url:e,success:n.ajaxSettings.success,type:h||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},r),a={},this.trigger("form-pre-serialize",[this,r,a]),a.veto)return t("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(r.beforeSerialize&&r.beforeSerialize(this,r)===!1)return t("ajaxSubmit: submit aborted via beforeSerialize callback"),this;if(v=r.traditional,void 0===v&&(v=n.ajaxSettings.traditional),c=[],o=this.formToArray(r.semantic,c),r.data&&(r.extraData=r.data,y=n.param(r.data,v)),r.beforeSubmit&&r.beforeSubmit(o,this,r)===!1)return t("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[o,this,r,a]),a.veto)return t("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;l=n.param(o,v);y&&(l=l?l+"&"+y:y);"GET"==r.type.toUpperCase()?(r.url+=(r.url.indexOf("?")>=0?"&":"?")+l,r.data=null):r.data=l;s=[];(r.resetForm&&s.push(function(){u.resetForm()}),r.clearForm&&s.push(function(){u.clearForm(r.includeHidden)}),!r.dataType&&r.target)?(g=r.success||function(){},s.push(function(t){var i=r.replaceTarget?"replaceWith":"html";n(r.target)[i](t).each(g,arguments)})):r.success&&s.push(r.success);(r.success=function(n,t,i){for(var e=r.context||this,f=0,o=s.length;o>f;f++)s[f].apply(e,[n,t,i||u,u])},r.error)&&(nt=r.error,r.error=function(n,t,i){var f=r.context||this;nt.apply(f,[n,t,i,u])});r.complete&&(tt=r.complete,r.complete=function(n,t){var i=r.context||this;tt.apply(i,[n,t,u])});var st=n('input[type=file]:enabled[value!=""]',this),it=st.length>0,rt="multipart/form-data",ut=u.attr("enctype")==rt||u.attr("encoding")==rt,k=i.fileapi&&i.formdata;for(t("fileAPI :"+k),ft=(it||ut)&&!k,r.iframe!==!1&&(r.iframe||ft)?r.closeKeepAlive?n.get(r.closeKeepAlive,function(){p=d(o)}):p=d(o):p=(it||ut)&&k?ot(o):n.ajax(r),u.removeData("jqxhr").data("jqxhr",p),w=0;c.length>w;w++)c[w]=null;return this.trigger("form-submit-notify",[this,r]),this};n.fn.ajaxForm=function(i){if(i=i||{},i.delegation=i.delegation&&n.isFunction(n.fn.on),!i.delegation&&0===this.length){var f={s:this.selector,c:this.context};return!n.isReady&&f.s?(t("DOM not ready, queuing ajaxForm"),n(function(){n(f.s,f.c).ajaxForm(i)}),this):(t("terminating; zero elements found by selector"+(n.isReady?"":" (DOM not ready)")),this)}return i.delegation?(n(document).off("submit.form-plugin",this.selector,r).off("click.form-plugin",this.selector,u).on("submit.form-plugin",this.selector,i,r).on("click.form-plugin",this.selector,i,u),this):this.ajaxFormUnbind().bind("submit.form-plugin",i,r).bind("click.form-plugin",i,u)};n.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};n.fn.formToArray=function(t,r){var o=[],e,c,l,s,f,h,u,p,w,a,y,v;if(0===this.length||(e=this[0],c=t?e.getElementsByTagName("*"):e.elements,!c))return o;for(l=0,p=c.length;p>l;l++)if(u=c[l],f=u.name,f&&!u.disabled)if(t&&e.clk&&"image"==u.type)e.clk==u&&(o.push({name:f,value:n(u).val(),type:u.type}),o.push({name:f+".x",value:e.clk_x},{name:f+".y",value:e.clk_y}));else if(h=n.fieldValue(u,!0),h&&h.constructor==Array)for(r&&r.push(u),s=0,w=h.length;w>s;s++)o.push({name:f,value:h[s]});else if(i.fileapi&&"file"==u.type)if(r&&r.push(u),a=u.files,a.length)for(s=0;a.length>s;s++)o.push({name:f,value:a[s],type:u.type});else o.push({name:f,value:"",type:u.type});else null!==h&&h!==void 0&&(r&&r.push(u),o.push({name:f,value:h,type:u.type,required:u.required}));return!t&&e.clk&&(y=n(e.clk),v=y[0],f=v.name,f&&!v.disabled&&"image"==v.type&&(o.push({name:f,value:y.val()}),o.push({name:f+".x",value:e.clk_x},{name:f+".y",value:e.clk_y}))),o};n.fn.formSerialize=function(t){return n.param(this.formToArray(t))};n.fn.fieldSerialize=function(t){var i=[];return this.each(function(){var f=this.name,r,u,e;if(f)if(r=n.fieldValue(this,t),r&&r.constructor==Array)for(u=0,e=r.length;e>u;u++)i.push({name:f,value:r[u]});else null!==r&&r!==void 0&&i.push({name:this.name,value:r})}),n.param(i)};n.fn.fieldValue=function(t){for(var f,i,r=[],u=0,e=this.length;e>u;u++)f=this[u],i=n.fieldValue(f,t),null!==i&&void 0!==i&&(i.constructor!=Array||i.length)&&(i.constructor==Array?n.merge(r,i):r.push(i));return r};n.fieldValue=function(t,i){var a=t.name,u=t.type,h=t.tagName.toLowerCase(),e,r,f;if(void 0===i&&(i=!0),i&&(!a||t.disabled||"reset"==u||"button"==u||("checkbox"==u||"radio"==u)&&!t.checked||("submit"==u||"image"==u)&&t.form&&t.form.clk!=t||"select"==h&&-1==t.selectedIndex))return null;if("select"==h){if(e=t.selectedIndex,0>e)return null;for(var c=[],l=t.options,o="select-one"==u,v=o?e+1:l.length,s=o?e:0;v>s;s++)if(r=l[s],r.selected){if(f=r.value,f||(f=r.attributes&&r.attributes.value&&!r.attributes.value.specified?r.text:r.value),o)return f;c.push(f)}return c}return n(t).val()};n.fn.clearForm=function(t){return this.each(function(){n("input,select,textarea",this).clearFields(t)})};n.fn.clearFields=n.fn.clearInputs=function(t){var i=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var r=this.type,u=this.tagName.toLowerCase();i.test(r)||"textarea"==u?this.value="":"checkbox"==r||"radio"==r?this.checked=!1:"select"==u?this.selectedIndex=-1:"file"==r?/MSIE/.test(navigator.userAgent)?n(this).replaceWith(n(this).clone(!0)):n(this).val(""):t&&(t===!0&&/hidden/.test(r)||"string"==typeof t&&n(this).is(t))&&(this.value="")})};n.fn.resetForm=function(){return this.each(function(){"function"!=typeof this.reset&&("object"!=typeof this.reset||this.reset.nodeType)||this.reset()})};n.fn.enable=function(n){return void 0===n&&(n=!0),this.each(function(){this.disabled=!n})};n.fn.selected=function(t){return void 0===t&&(t=!0),this.each(function(){var r=this.type,i;"checkbox"==r||"radio"==r?this.checked=t:"option"==this.tagName.toLowerCase()&&(i=n(this).parent("select"),t&&i[0]&&"select-one"==i[0].type&&i.find("option").selected(!1),this.selected=t)})};n.fn.ajaxSubmit.debug=!1})(jQuery)