/*!
* jQuery Form Plugin
* version: 3.32.0-2013.04.09
* @requires jQuery v1.5 or later
* Copyright (c) 2013 M. Alsup
* Examples and documentation at: http://malsup.com/jquery/form/
* Project repository: https://github.com/malsup/form
* Dual licensed under the MIT and GPL licenses.
* https://github.com/malsup/form#copyright-and-license
*/
(function(n){"use strict";function u(t){var i=t.data;t.isDefaultPrevented()||(t.preventDefault(),n(this).ajaxSubmit(i))}function f(t){var r=t.target,u=n(r),f,i,e;if(!u.is("[type=submit],[type=image]")){if(f=u.closest("[type=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={},r;i.fileapi=n("<input type='file'/>").get(0).files!==undefined;i.formdata=window.FormData!==undefined;r=!!n.fn.prop;n.fn.attr2=function(){if(!r)return this.attr.apply(this,arguments);var n=this.prop.apply(this,arguments);return n&&n.jquery||typeof n=="string"?n:this.attr.apply(this,arguments)};n.fn.ajaxSubmit=function(u){function ft(t){for(var r=n.param(t).split("&"),e=r.length,f=[],u,i=0;i<e;i++)r[i]=r[i].replace(/\+/g," "),u=r[i].split("="),f.push([decodeURIComponent(u[0]),decodeURIComponent(u[1])]);return f}function et(t){for(var f,r,o,e=new FormData,i=0;i<t.length;i++)e.append(t[i].name,t[i].value);if(u.extraData)for(f=ft(u.extraData),i=0;i<f.length;i++)f[i]&&e.append(f[i][0],f[i][1]);return u.data=null,r=n.extend(!0,{},n.ajaxSettings,u,{contentType:!1,processData:!1,cache:!1,type:h||"POST"}),u.uploadProgress&&(r.xhr=function(){var n=jQuery.ajaxSettings.xhr();return n.upload&&n.upload.addEventListener("progress",function(n){var t=0,i=n.loaded||n.position,r=n.total;n.lengthComputable&&(t=Math.ceil(i/r*100));u.uploadProgress(n,i,r,t)},!1),n}),r.data=null,o=r.beforeSend,r.beforeSend=function(n,t){t.data=e;o&&o.call(this,n,t)},n.ajax(r)}function rt(i){function ot(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 st(){function s(){try{var n=ot(a).readyState;t("state = "+n);n&&n.toLowerCase()=="uninitialized"&&setTimeout(s,50)}catch(i){t("Server abort: ",i," (",i.name,")");b(tt);g&&clearTimeout(g);g=undefined}}var u=f.attr2("target"),o=f.attr2("action"),r,i,c;l.setAttribute("target",d);h||l.setAttribute("method","POST");o!=e.url&&l.setAttribute("action",e.url);e.skipEncodingOverride||h&&!/post/i.test(h)||f.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});e.timeout&&(g=setTimeout(function(){rt=!0;b(ut)},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(s,15);try{l.submit()}catch(y){c=document.createElement("form").submit;c.apply(l)}}finally{l.setAttribute("action",o);u?l.setAttribute("target",u):f.removeAttr("target");n(r).remove()}}function b(i){var r,u,w,f,k,d,h,c,l;if(!o.aborted&&!lt){if(s=ot(a),s||(t("cannot access response document"),i=tt),i===ut&&o){o.abort("timeout");y.reject(o,"timeout");return}if(i==tt&&o){o.abort("server abort");y.reject(o,"error","server abort");return}if(s&&s.location.href!=e.iframeSrc||rt){a.detachEvent?a.detachEvent("onload",b):a.removeEventListener("load",b,!1);r="success";try{if(rt)throw"timeout";if(w=e.dataType=="xml"||s.XMLDocument||n.isXMLDoc(s),t("isXml="+w),!w&&window.opera&&(s.body===null||!s.body.innerHTML)&&--ct){t("requeing onLoad callback, DOM not available");setTimeout(b,250);return}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))):k=="xml"&&!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&&o.status<300||o.status===304?"success":"error");r==="success"?(e.success&&e.success.call(e.context,ht,"success",o),y.resolve(o.responseText,"success",o),p&&n.event.trigger("ajaxSuccess",[o,e])):r&&(u===undefined&&(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);lt=!0;e.timeout&&clearTimeout(g);setTimeout(function(){e.iframeTarget||v.remove();o.responseXML=null},100)}}}var l=f[0],it,nt,e,p,d,v,a,o,k,w,rt,g,y=n.Deferred(),ut,tt,ft,et,ht,s,ct,lt;if(i)for(nt=0;nt<c.length;nt++)it=n(c[nt]),r?it.prop("disabled",!1):it.removeAttr("disabled");if(e=n.extend(!0,{},n.ajaxSettings,u),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=i==="timeout"?"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,k.type=="image"&&(e.extraData[w+".x"]=l.clk_x,e.extraData[w+".y"]=l.clk_y)));ut=1;tt=2;ft=n("meta[name=csrf-token]").attr("content");et=n("meta[name=csrf-param]").attr("content");et&&ft&&(e.extraData=e.extraData||{},e.extraData[et]=ft);e.forceSync?st():setTimeout(st,10);ct=50;var 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&&t.documentElement.nodeName!="parsererror"?t:null},vt=n.parseJSON||function(n){return window.eval("("+n+")")},yt=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=vt(u):(i==="script"||!i&&f.indexOf("javascript")>=0)&&n.globalEval(u)),u};return y}var h,b,e,f,a,v,c,y,o,l,s,d,it,p,w;if(!this.length)return t("ajaxSubmit: skipping submit process - no element selected"),this;if(f=this,typeof u=="function"&&(u={success:u}),h=this.attr2("method"),b=this.attr2("action"),e=typeof b=="string"?n.trim(b):"",e=e||window.location.href||"",e&&(e=(e.match(/^([^#]+)/)||[])[1]),u=n.extend(!0,{url:e,success:n.ajaxSettings.success,type:h||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},u),a={},this.trigger("form-pre-serialize",[this,u,a]),a.veto)return t("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(u.beforeSerialize&&u.beforeSerialize(this,u)===!1)return t("ajaxSubmit: submit aborted via beforeSerialize callback"),this;if(v=u.traditional,v===undefined&&(v=n.ajaxSettings.traditional),c=[],o=this.formToArray(u.semantic,c),u.data&&(u.extraData=u.data,y=n.param(u.data,v)),u.beforeSubmit&&u.beforeSubmit(o,this,u)===!1)return t("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[o,this,u,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);u.type.toUpperCase()=="GET"?(u.url+=(u.url.indexOf("?")>=0?"&":"?")+l,u.data=null):u.data=l;s=[];u.resetForm&&s.push(function(){f.resetForm()});u.clearForm&&s.push(function(){f.clearForm(u.includeHidden)});!u.dataType&&u.target?(d=u.success||function(){},s.push(function(t){var i=u.replaceTarget?"replaceWith":"html";n(u.target)[i](t).each(d,arguments)})):u.success&&s.push(u.success);u.success=function(n,t,i){for(var e=u.context||this,r=0,o=s.length;r<o;r++)s[r].apply(e,[n,t,i||f,f])};var ut=n('input[type=file]:enabled[value!=""]',this),g=ut.length>0,nt="multipart/form-data",tt=f.attr("enctype")==nt||f.attr("encoding")==nt,k=i.fileapi&&i.formdata;for(t("fileAPI :"+k),it=(g||tt)&&!k,u.iframe!==!1&&(u.iframe||it)?u.closeKeepAlive?n.get(u.closeKeepAlive,function(){p=rt(o)}):p=rt(o):p=(g||tt)&&k?et(o):n.ajax(u),f.removeData("jqxhr").data("jqxhr",p),w=0;w<c.length;w++)c[w]=null;return this.trigger("form-submit-notify",[this,u]),this};n.fn.ajaxForm=function(i){if(i=i||{},i.delegation=i.delegation&&n.isFunction(n.fn.on),!i.delegation&&this.length===0){var r={s:this.selector,c:this.context};return!n.isReady&&r.s?(t("DOM not ready, queuing ajaxForm"),n(function(){n(r.s,r.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,u).off("click.form-plugin",this.selector,f).on("submit.form-plugin",this.selector,i,u).on("click.form-plugin",this.selector,i,f);return this}return this.ajaxFormUnbind().bind("submit.form-plugin",i,u).bind("click.form-plugin",i,f)};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&&!u.disabled){if(t&&e.clk&&u.type=="image"){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")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:r=="file"?/MSIE/.test(navigator.userAgent)?n(this).replaceWith(n(this).clone(!0)):n(this).val(""):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)