(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(":submit,input:image")){if(f=u.closest(":submit"),f.length===0)return;r=f[0]}i=this;i.clk=r;r.type=="image"&&(t.offsetX!==undefined?(i.clk_x=t.offsetX,i.clk_y=t.offsetY):typeof n.fn.offset=="function"?(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={};i.fileapi=n("<input type='file'/>").get(0).files!==undefined;i.formdata=window.FormData!==undefined;n.fn.ajaxSubmit=function(r){function rt(t){for(var u=n.param(t).split("&"),e=u.length,f={},r,i=0;i<e;i++)r=u[i].split("="),f[decodeURIComponent(r[0])]=decodeURIComponent(r[1]);return f}function ut(t){for(var f,e,i,s,o=new FormData,u=0;u<t.length;u++)o.append(t[u].name,t[u].value);if(r.extraData){f=rt(r.extraData);for(e in f)f.hasOwnProperty(e)&&o.append(e,f[e])}r.data=null;i=n.extend(!0,{},n.ajaxSettings,r,{contentType:!1,processData:!1,cache:!1,type:"POST"});r.uploadProgress&&(i.xhr=function(){var n=jQuery.ajaxSettings.xhr();return n.upload&&(n.upload.onprogress=function(n){var t=0,i=n.loaded||n.position,u=n.total;n.lengthComputable&&(t=Math.ceil(i/u*100));r.uploadProgress(n,i,u,t)}),n});i.data=null;s=i.beforeSend;i.beforeSend=function(n,t){t.data=o;s&&s.call(this,n,t)};n.ajax(i)}function tt(i){function ft(n){return n.contentWindow?n.contentWindow.document:n.contentDocument?n.contentDocument:n.document}function et(){function s(){try{var n=ft(l).readyState;t("state = "+n);n&&n.toLowerCase()=="uninitialized"&&setTimeout(s,50)}catch(i){t("Server abort: ",i," (",i.name,")");p(g);k&&clearTimeout(k);k=undefined}}var e=u.attr("target"),o=u.attr("action"),r,i;h.setAttribute("target",b);c||h.setAttribute("method","POST");o!=f.url&&h.setAttribute("action",f.url);f.skipEncodingOverride||c&&!/post/i.test(c)||u.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});f.timeout&&(k=setTimeout(function(){tt=!0;p(it)},f.timeout));r=[];try{if(f.extraData)for(i in f.extraData)f.extraData.hasOwnProperty(i)&&(n.isPlainObject(f.extraData[i])&&f.extraData[i].hasOwnProperty("name")&&f.extraData[i].hasOwnProperty("value")?r.push(n('<input type="hidden" name="'+f.extraData[i].name+'">').attr("value",f.extraData[i].value).appendTo(h)[0]):r.push(n('<input type="hidden" name="'+i+'">').attr("value",f.extraData[i]).appendTo(h)[0]));f.iframeTarget||(a.appendTo("body"),l.attachEvent?l.attachEvent("onload",p):l.addEventListener("load",p,!1));setTimeout(s,15);h.submit()}finally{h.setAttribute("action",o);e?h.setAttribute("target",e):u.removeAttr("target");n(r).remove()}}function p(i){var r,u,w,s,b,d,h,c,y;if(!e.aborted&&!ht){try{o=ft(l)}catch(nt){t("cannot access response document: ",nt);i=g}if(i===it&&e){e.abort("timeout");return}if(i==g&&e){e.abort("server abort");return}if(o&&o.location.href!=f.iframeSrc||tt){l.detachEvent?l.detachEvent("onload",p):l.removeEventListener("load",p,!1);r="success";try{if(tt)throw"timeout";if(w=f.dataType=="xml"||o.XMLDocument||n.isXMLDoc(o),t("isXml="+w),!w&&window.opera&&(o.body===null||!o.body.innerHTML)&&--st){t("requeing onLoad callback, DOM not available");setTimeout(p,250);return}s=o.body?o.body:o.documentElement;e.responseText=s?s.innerHTML:null;e.responseXML=o.XMLDocument?o.XMLDocument:o;w&&(f.dataType="xml");e.getResponseHeader=function(n){var t={"content-type":f.dataType};return t[n]};s&&(e.status=Number(s.getAttribute("status"))||e.status,e.statusText=s.getAttribute("statusText")||e.statusText);b=(f.dataType||"").toLowerCase();d=/(json|script|text)/.test(b);d||f.textarea?(h=o.getElementsByTagName("textarea")[0],h?(e.responseText=h.value,e.status=Number(h.getAttribute("status"))||e.status,e.statusText=h.getAttribute("statusText")||e.statusText):d&&(c=o.getElementsByTagName("pre")[0],y=o.getElementsByTagName("body")[0],c?e.responseText=c.textContent?c.textContent:c.innerText:y&&(e.responseText=y.textContent?y.textContent:y.innerText))):b=="xml"&&!e.responseXML&&e.responseText&&(e.responseXML=lt(e.responseText));try{ot=vt(e,b,f)}catch(i){r="parsererror";e.error=u=i||r}}catch(i){t("error caught: ",i);r="error";e.error=u=i||r}e.aborted&&(t("upload aborted"),r=null);e.status&&(r=e.status>=200&&e.status<300||e.status===304?"success":"error");r==="success"?(f.success&&f.success.call(f.context,ot,"success",e),v&&n.event.trigger("ajaxSuccess",[e,f])):r&&(u===undefined&&(u=e.statusText),f.error&&f.error.call(f.context,e,r,u),v&&n.event.trigger("ajaxError",[e,f,u]));v&&n.event.trigger("ajaxComplete",[e,f]);v&&!--n.active&&n.event.trigger("ajaxStop");f.complete&&f.complete.call(f.context,e,r);ht=!0;f.timeout&&clearTimeout(k);setTimeout(function(){f.iframeTarget||a.remove();e.responseXML=null},100)}}}var h=u[0],nt,d,f,v,b,a,l,e,w,y,tt,k,ct=!!n.fn.prop,it,g,rt,ut,ot,o,st,ht;if(n(":input[name=submit],:input[id=submit]",h).length){alert('Error: Form elements must not have name or id of "submit".');return}if(i)for(d=0;d<s.length;d++)nt=n(s[d]),ct?nt.prop("disabled",!1):nt.removeAttr("disabled");if(f=n.extend(!0,{},n.ajaxSettings,r),f.context=f.context||f,b="jqFormIO"+(new Date).getTime(),f.iframeTarget?(a=n(f.iframeTarget),y=a.attr("name"),y?b=y:a.attr("name",b)):(a=n('<iframe name="'+b+'" src="'+f.iframeSrc+'" />'),a.css({position:"absolute",top:"-1000px",left:"-1000px"})),l=a[0],e={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(i){var r=i==="timeout"?"timeout":"aborted";if(t("aborting upload... "+r),this.aborted=1,l.contentWindow.document.execCommand)try{l.contentWindow.document.execCommand("Stop")}catch(u){}a.attr("src",f.iframeSrc);e.error=r;f.error&&f.error.call(f.context,e,r,i);v&&n.event.trigger("ajaxError",[e,f,r]);f.complete&&f.complete.call(f.context,e,r)}},v=f.global,v&&0==n.active++&&n.event.trigger("ajaxStart"),v&&n.event.trigger("ajaxSend",[e,f]),f.beforeSend&&f.beforeSend.call(f.context,e,f)===!1){f.global&&n.active--;return}if(!e.aborted){w=h.clk;w&&(y=w.name,y&&!w.disabled&&(f.extraData=f.extraData||{},f.extraData[y]=w.value,w.type=="image"&&(f.extraData[y+".x"]=h.clk_x,f.extraData[y+".y"]=h.clk_y)));it=1;g=2;rt=n("meta[name=csrf-token]").attr("content");ut=n("meta[name=csrf-param]").attr("content");ut&&rt&&(f.extraData=f.extraData||{},f.extraData[ut]=rt);f.forceSync?et():setTimeout(et,10);st=50;var lt=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&&t.documentElement.nodeName!="parsererror"?t:null},at=n.parseJSON||function(s){return window.eval("("+s+")")},vt=function(t,i,r){var f=t.getResponseHeader("content-type")||"",e=i==="xml"||!i&&f.indexOf("xml")>=0,u=e?t.responseXML:t.responseText;return e&&u.documentElement.nodeName==="parsererror"&&n.error&&n.error("parsererror"),r&&r.dataFilter&&(u=r.dataFilter(u,i)),typeof u=="string"&&(i==="json"||!i&&f.indexOf("json")>=0?u=at(u):(i==="script"||!i&&f.indexOf("javascript")>=0)&&n.globalEval(u)),u}}}var c,p,f,u,l,a,s,v,e,h,o,b,nt,y;if(!this.length)return t("ajaxSubmit: skipping submit process - no element selected"),this;if(u=this,typeof r=="function"&&(r={success:r}),c=this.attr("method"),p=this.attr("action"),f=typeof p=="string"?n.trim(p):"",f=f||window.location.href||"",f&&(f=(f.match(/^([^#]+)/)||[])[1]),r=n.extend(!0,{url:f,success:n.ajaxSettings.success,type:c||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},r),l={},this.trigger("form-pre-serialize",[this,r,l]),l.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(a=r.traditional,a===undefined&&(a=n.ajaxSettings.traditional),s=[],e=this.formToArray(r.semantic,s),r.data&&(r.extraData=r.data,v=n.param(r.data,a)),r.beforeSubmit&&r.beforeSubmit(e,this,r)===!1)return t("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[e,this,r,l]),l.veto)return t("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;h=n.param(e,a);v&&(h=h?h+"&"+v:v);r.type.toUpperCase()=="GET"?(r.url+=(r.url.indexOf("?")>=0?"&":"?")+h,r.data=null):r.data=h;o=[];r.resetForm&&o.push(function(){u.resetForm()});r.clearForm&&o.push(function(){u.clearForm(r.includeHidden)});!r.dataType&&r.target?(b=r.success||function(){},o.push(function(t){var i=r.replaceTarget?"replaceWith":"html";n(r.target)[i](t).each(b,arguments)})):r.success&&o.push(r.success);r.success=function(n,t,i){for(var e=r.context||this,f=0,s=o.length;f<s;f++)o[f].apply(e,[n,t,i||u,u])};var it=n("input:file:enabled[value]",this),k=it.length>0,d="multipart/form-data",g=u.attr("enctype")==d||u.attr("encoding")==d,w=i.fileapi&&i.formdata;for(t("fileAPI :"+w),nt=(k||g)&&!w,r.iframe!==!1&&(r.iframe||nt)?r.closeKeepAlive?n.get(r.closeKeepAlive,function(){tt(e)}):tt(e):(k||g)&&w?ut(e):n.ajax(r),y=0;y<s.length;y++)s[y]=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&&this.length===0){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)}if(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);return this}return 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(this.length===0||(e=this[0],c=t?e.getElementsByTagName("*"):e.elements,!c))return o;for(l=0,p=c.length;l<p;l++)if(u=c[l],f=u.name,f){if(t&&e.clk&&u.type=="image"){u.disabled||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}));continue}if(h=n.fieldValue(u,!0),h&&h.constructor==Array)for(r&&r.push(u),s=0,w=h.length;s<w;s++)o.push({name:f,value:h[s]});else if(i.fileapi&&u.type=="file"&&!u.disabled)if(r&&r.push(u),a=u.files,a.length)for(s=0;s<a.length;s++)o.push({name:f,value:a[s],type:u.type});else o.push({name:f,value:"",type:u.type});else h!==null&&typeof h!="undefined"&&(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&&v.type=="image"&&(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;u<e;u++)i.push({name:f,value:r[u]});else r!==null&&typeof r!="undefined"&&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;u<e;u++)(f=this[u],i=n.fieldValue(f,t),i!==null&&typeof i!="undefined"&&(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,o,r,f;if(i===undefined&&(i=!0),i&&(!a||t.disabled||u=="reset"||u=="button"||(u=="checkbox"||u=="radio")&&!t.checked||(u=="submit"||u=="image")&&t.form&&t.form.clk!=t||h=="select"&&t.selectedIndex==-1))return null;if(h=="select"){if(e=t.selectedIndex,e<0)return null;var c=[],l=t.options,s=u=="select-one",v=s?e+1:l.length;for(o=s?e:0;o<v;o++)if(r=l[o],r.selected){if(f=r.value,f||(f=r.attributes&&r.attributes.value&&!r.attributes.value.specified?r.text:r.value),s)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)||u=="textarea"?this.value="":r=="checkbox"||r=="radio"?this.checked=!1:u=="select"?this.selectedIndex=-1:t&&(t===!0&&/hidden/.test(r)||typeof t=="string"&&n(this).is(t))&&(this.value="")})};n.fn.resetForm=function(){return this.each(function(){typeof this.reset!="function"&&(typeof this.reset!="object"||this.reset.nodeType)||this.reset()})};n.fn.enable=function(n){return n===undefined&&(n=!0),this.each(function(){this.disabled=!n})};n.fn.selected=function(t){return t===undefined&&(t=!0),this.each(function(){var r=this.type,i;r=="checkbox"||r=="radio"?this.checked=t:this.tagName.toLowerCase()=="option"&&(i=n(this).parent("select"),t&&i[0]&&i[0].type=="select-one"&&i.find("option").selected(!1),this.selected=t)})};n.fn.ajaxSubmit.debug=!1})(jQuery)