/*!
 * jQuery Form Plugin
 * version: 2.83 (11-JUL-2011)
 * @requires jQuery v1.3.2 or later
 *
 * Examples and documentation at: http://malsup.com/jquery/form/
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
(function(n){function t(){var n="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(n):window.opera&&window.opera.postError&&window.opera.postError(n)}n.fn.ajaxSubmit=function(i){function b(u){function it(n){return n.contentWindow?n.contentWindow.document:n.contentDocument?n.contentDocument:n.document}function rt(){function a(){try{var n=it(l).readyState;t("state = "+n);n.toLowerCase()=="uninitialized"&&setTimeout(a,50)}catch(i){t("Server abort: ",i," (",i.name,")");y(d);b&&clearTimeout(b);b=undefined}}var e=r.attr("target"),o=r.attr("action"),i,u;h.setAttribute("target",w);s||h.setAttribute("method","POST");o!=f.url&&h.setAttribute("action",f.url);f.skipEncodingOverride||s&&!/post/i.test(s)||r.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"});f.timeout&&(b=setTimeout(function(){g=!0;y(nt)},f.timeout));i=[];try{if(f.extraData)for(u in f.extraData)i.push(n('<input type="hidden" name="'+u+'" />').attr("value",f.extraData[u]).appendTo(h)[0]);f.iframeTarget||(c.appendTo("body"),l.attachEvent?l.attachEvent("onload",y):l.addEventListener("load",y,!1));setTimeout(a,15);h.submit()}finally{h.setAttribute("action",o);e?h.setAttribute("target",e):r.removeAttr("target");n(i).remove()}}function y(i){var r,u,p,s,tt,w,h,v,k;if(!e.aborted&&!et){try{o=it(l)}catch(rt){t("cannot access response document: ",rt);i=d}if(i===nt&&e){e.abort("timeout");return}if(i==d&&e){e.abort("server abort");return}if(o&&o.location.href!=f.iframeSrc||g){l.detachEvent?l.detachEvent("onload",y):l.removeEventListener("load",y,!1);r="success";try{if(g)throw"timeout";if(p=f.dataType=="xml"||o.XMLDocument||n.isXMLDoc(o),t("isXml="+p),!p&&window.opera&&(o.body==null||o.body.innerHTML=="")&&--ft){t("requeing onLoad callback, DOM not available");setTimeout(y,250);return}s=o.body?o.body:o.documentElement;e.responseText=s?s.innerHTML:null;e.responseXML=o.XMLDocument?o.XMLDocument:o;p&&(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);tt=f.dataType||"";w=/(json|script|text)/.test(tt.toLowerCase());w||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):w&&(v=o.getElementsByTagName("pre")[0],k=o.getElementsByTagName("body")[0],v?e.responseText=v.textContent?v.textContent:v.innerHTML:k&&(e.responseText=k.innerHTML))):f.dataType!="xml"||e.responseXML||e.responseText==null||(e.responseXML=st(e.responseText));try{ut=ct(e,f.dataType,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,ut,"success",e),a&&n.event.trigger("ajaxSuccess",[e,f])):r&&(u==undefined&&(u=e.statusText),f.error&&f.error.call(f.context,e,r,u),a&&n.event.trigger("ajaxError",[e,f,u]));a&&n.event.trigger("ajaxComplete",[e,f]);a&&!--n.active&&n.event.trigger("ajaxStop");f.complete&&f.complete.call(f.context,e,r);et=!0;f.timeout&&clearTimeout(b);setTimeout(function(){f.iframeTarget||c.remove();e.responseXML=null},100)}}}var h=r[0],tt,k,f,a,w,c,l,e,p,v,g,b,ot=!!n.fn.prop,nt,d,ut,o,ft,et;if(u)for(k=0;k<u.length;k++)tt=n(h[u[k].name]),tt[ot?"prop":"attr"]("disabled",!1);if(n(":input[name=submit],:input[id=submit]",h).length){alert('Error: Form elements must not have name or id of "submit".');return}if(f=n.extend(!0,{},n.ajaxSettings,i),f.context=f.context||f,w="jqFormIO"+(new Date).getTime(),f.iframeTarget?(c=n(f.iframeTarget),v=c.attr("name"),v==null?c.attr("name",w):w=v):(c=n('<iframe name="'+w+'" src="'+f.iframeSrc+'" />'),c.css({position:"absolute",top:"-1000px",left:"-1000px"})),l=c[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";t("aborting upload... "+r);this.aborted=1;c.attr("src",f.iframeSrc);e.error=r;f.error&&f.error.call(f.context,e,r,i);a&&n.event.trigger("ajaxError",[e,f,r]);f.complete&&f.complete.call(f.context,e,r)}},a=f.global,a&&!n.active++&&n.event.trigger("ajaxStart"),a&&n.event.trigger("ajaxSend",[e,f]),f.beforeSend&&f.beforeSend.call(f.context,e,f)===!1){f.global&&n.active--;return}if(!e.aborted){p=h.clk;p&&(v=p.name,v&&!p.disabled&&(f.extraData=f.extraData||{},f.extraData[v]=p.value,p.type=="image"&&(f.extraData[v+".x"]=h.clk_x,f.extraData[v+".y"]=h.clk_y)));nt=1;d=2;f.forceSync?rt():setTimeout(rt,10);ft=50;var st=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},ht=n.parseJSON||function(n){return window.eval("("+n+")")},ct=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=ht(u):(i==="script"||!i&&f.indexOf("javascript")>=0)&&n.globalEval(u)),u}}}var s,l,f,r,c,e,h,u,y,a,o,p,v;if(!this.length)return t("ajaxSubmit: skipping submit process - no element selected"),this;if(r=this,typeof i=="function"&&(i={success:i}),s=this.attr("method"),l=this.attr("action"),f=typeof l=="string"?n.trim(l):"",f=f||window.location.href||"",f&&(f=(f.match(/^([^#]+)/)||[])[1]),i=n.extend(!0,{url:f,success:n.ajaxSettings.success,type:s||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},i),c={},this.trigger("form-pre-serialize",[this,i,c]),c.veto)return t("ajaxSubmit: submit vetoed via form-pre-serialize trigger"),this;if(i.beforeSerialize&&i.beforeSerialize(this,i)===!1)return t("ajaxSubmit: submit aborted via beforeSerialize callback"),this;if(u=this.formToArray(i.semantic),i.data){i.extraData=i.data;for(e in i.data)if(i.data[e]instanceof Array)for(y in i.data[e])u.push({name:e,value:i.data[e][y]});else h=i.data[e],h=n.isFunction(h)?h():h,u.push({name:e,value:h})}if(i.beforeSubmit&&i.beforeSubmit(u,this,i)===!1)return t("ajaxSubmit: submit aborted via beforeSubmit callback"),this;if(this.trigger("form-submit-validate",[u,this,i,c]),c.veto)return t("ajaxSubmit: submit vetoed via form-submit-validate trigger"),this;a=n.param(u);i.type.toUpperCase()=="GET"?(i.url+=(i.url.indexOf("?")>=0?"&":"?")+a,i.data=null):i.data=a;o=[];i.resetForm&&o.push(function(){r.resetForm()});i.clearForm&&o.push(function(){r.clearForm()});!i.dataType&&i.target?(p=i.success||function(){},o.push(function(t){var r=i.replaceTarget?"replaceWith":"html";n(i.target)[r](t).each(p,arguments)})):i.success&&o.push(i.success);i.success=function(n,t,u){for(var e=i.context||i,f=0,s=o.length;f<s;f++)o[f].apply(e,[n,t,u||r,r])};var k=n("input:file",this).length>0,w="multipart/form-data",d=r.attr("enctype")==w||r.attr("encoding")==w;return i.iframe!==!1&&(k||i.iframe||d)?i.closeKeepAlive?n.get(i.closeKeepAlive,function(){b(u)}):b(u):(n.browser.msie&&s=="get"&&(v=r[0].getAttribute("method"),typeof v=="string"&&(i.type=v)),n.ajax(i)),this.trigger("form-submit-notify",[this,i]),this};n.fn.ajaxForm=function(i){if(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)}return this.ajaxFormUnbind().bind("submit.form-plugin",function(t){t.isDefaultPrevented()||(t.preventDefault(),n(this).ajaxSubmit(i))}).bind("click.form-plugin",function(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)})};n.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};n.fn.formToArray=function(t){var u=[],r,o,s,h,i,f,e,a,v,l,c;if(this.length===0||(r=this[0],o=t?r.getElementsByTagName("*"):r.elements,!o))return u;for(s=0,a=o.length;s<a;s++)if(e=o[s],i=e.name,i){if(t&&r.clk&&e.type=="image"){e.disabled||r.clk!=e||(u.push({name:i,value:n(e).val()}),u.push({name:i+".x",value:r.clk_x},{name:i+".y",value:r.clk_y}));continue}if(f=n.fieldValue(e,!0),f&&f.constructor==Array)for(h=0,v=f.length;h<v;h++)u.push({name:i,value:f[h]});else f!==null&&typeof f!="undefined"&&u.push({name:i,value:f})}return!t&&r.clk&&(l=n(r.clk),c=l[0],i=c.name,i&&!c.disabled&&c.type=="image"&&(u.push({name:i,value:l.val()}),u.push({name:i+".x",value:r.clk_x},{name:i+".y",value:r.clk_y}))),u};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(){return this.each(function(){n("input,select,textarea",this).clearFields()})};n.fn.clearFields=n.fn.clearInputs=function(){var n=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var t=this.type,i=this.tagName.toLowerCase();n.test(t)||i=="textarea"?this.value="":t=="checkbox"||t=="radio"?this.checked=!1:i=="select"&&(this.selectedIndex=-1)})};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)})}})(jQuery)