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