/*!
 * jQuery Form Plugin
 * version: 3.15 (09-SEP-2012)
 * @requires jQuery v1.3.2 or later
 *
 * Examples and documentation at: http://malsup.com/jquery/form/
 * Project repository: https://github.com/malsup/form
 * Dual licensed under the MIT and GPL licenses:
 *    http://malsup.github.com/mit-license.txt
 *    http://malsup.github.com/gpl-license-v2.txt
 */
(function(e){var c={};c.fileapi=e("<input type='file'/>").get(0).files!==undefined;c.formdata=window.FormData!==undefined;e.fn.ajaxSubmit=function(h){if(!this.length){d("ajaxSubmit: skipping submit process - no element selected");return this}var g,x,j,m=this;if(typeof h=="function"){h={success:h}}g=this.attr("method");x=this.attr("action");j=(typeof x==="string")?e.trim(x):"";j=j||window.location.href||"";if(j){j=(j.match(/^([^#]+)/)||[])[1]}h=e.extend(true,{url:j,success:e.ajaxSettings.success,type:g||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},h);var s={};this.trigger("form-pre-serialize",[this,h,s]);if(s.veto){d("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(h.beforeSerialize&&h.beforeSerialize(this,h)===false){d("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var l=h.traditional;if(l===undefined){l=e.ajaxSettings.traditional}var p=[];var A,B=this.formToArray(h.semantic,p);if(h.data){h.extraData=h.data;A=e.param(h.data,l)}if(h.beforeSubmit&&h.beforeSubmit(B,this,h)===false){d("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[B,this,h,s]);if(s.veto){d("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var v=e.param(B,l);if(A){v=(v?(v+"&"+A):A)}if(h.type.toUpperCase()=="GET"){h.url+=(h.url.indexOf("?")>=0?"&":"?")+v;h.data=null}else{h.data=v}var D=[];if(h.resetForm){D.push(function(){m.resetForm()})}if(h.clearForm){D.push(function(){m.clearForm(h.includeHidden)})}if(!h.dataType&&h.target){var i=h.success||function(){};D.push(function(q){var k=h.replaceTarget?"replaceWith":"html";e(h.target)[k](q).each(i,arguments)})}else{if(h.success){D.push(h.success)}}h.success=function(G,q,H){var F=h.context||this;for(var E=0,k=D.length;E<k;E++){D[E].apply(F,[G,q,H||m,m])}};var z=e("input:file:enabled[value]",this);var n=z.length>0;var y="multipart/form-data";var u=(m.attr("enctype")==y||m.attr("encoding")==y);var t=c.fileapi&&c.formdata;d("fileAPI :"+t);var o=(n||u)&&!t;if(h.iframe!==false&&(h.iframe||o)){if(h.closeKeepAlive){e.get(h.closeKeepAlive,function(){C(B)})}else{C(B)}}else{if((n||u)&&t){r(B)}else{e.ajax(h)}}for(var w=0;w<p.length;w++){p[w]=null}this.trigger("form-submit-notify",[this,h]);return this;function f(G){var H=e.param(G).split("&");var q=H.length;var k={};var F,E;for(F=0;F<q;F++){E=H[F].split("=");k[decodeURIComponent(E[0])]=decodeURIComponent(E[1])}return k}function r(q){var k=new FormData();for(var E=0;E<q.length;E++){k.append(q[E].name,q[E].value)}if(h.extraData){var H=f(h.extraData);for(var I in H){if(H.hasOwnProperty(I)){k.append(I,H[I])}}}h.data=null;var G=e.extend(true,{},e.ajaxSettings,h,{contentType:false,processData:false,cache:false,type:"POST"});if(h.uploadProgress){G.xhr=function(){var J=jQuery.ajaxSettings.xhr();if(J.upload){J.upload.onprogress=function(N){var M=0;var K=N.loaded||N.position;var L=N.total;if(N.lengthComputable){M=Math.ceil(K/L*100)}h.uploadProgress(N,K,L,M)}}return J}}G.data=null;var F=G.beforeSend;G.beforeSend=function(K,J){J.data=k;if(F){F.call(this,K,J)}};e.ajax(G)}function C(ac){var H=m[0],G,Y,S,aa,V,J,N,L,M,W,Z,Q;var K=!!e.fn.prop;if(e(":input[name=submit],:input[id=submit]",H).length){alert('Error: Form elements must not have name or id of "submit".');return}if(ac){for(Y=0;Y<p.length;Y++){G=e(p[Y]);if(K){G.prop("disabled",false)}else{G.removeAttr("disabled")}}}S=e.extend(true,{},e.ajaxSettings,h);S.context=S.context||S;V="jqFormIO"+(new Date().getTime());if(S.iframeTarget){J=e(S.iframeTarget);W=J.attr("name");if(!W){J.attr("name",V)}else{V=W}}else{J=e('<iframe name="'+V+'" src="'+S.iframeSrc+'" />');J.css({position:"absolute",top:"-1000px",left:"-1000px"})}N=J[0];L={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(af){var ag=(af==="timeout"?"timeout":"aborted");d("aborting upload... "+ag);this.aborted=1;if(N.contentWindow.document.execCommand){try{N.contentWindow.document.execCommand("Stop")}catch(ah){}}J.attr("src",S.iframeSrc);L.error=ag;if(S.error){S.error.call(S.context,L,ag,af)}if(aa){e.event.trigger("ajaxError",[L,S,ag])}if(S.complete){S.complete.call(S.context,L,ag)}}};aa=S.global;if(aa&&0===e.active++){e.event.trigger("ajaxStart")}if(aa){e.event.trigger("ajaxSend",[L,S])}if(S.beforeSend&&S.beforeSend.call(S.context,L,S)===false){if(S.global){e.active--}return}if(L.aborted){return}M=H.clk;if(M){W=M.name;if(W&&!M.disabled){S.extraData=S.extraData||{};S.extraData[W]=M.value;if(M.type=="image"){S.extraData[W+".x"]=H.clk_x;S.extraData[W+".y"]=H.clk_y}}}var R=1;var O=2;function P(ag){var af=ag.contentWindow?ag.contentWindow.document:ag.contentDocument?ag.contentDocument:ag.document;return af}var F=e("meta[name=csrf-token]").attr("content");var E=e("meta[name=csrf-param]").attr("content");if(E&&F){S.extraData=S.extraData||{};S.extraData[E]=F}function X(){var ah=m.attr("target"),af=m.attr("action");H.setAttribute("target",V);if(!g){H.setAttribute("method","POST")}if(af!=S.url){H.setAttribute("action",S.url)}if(!S.skipEncodingOverride&&(!g||/post/i.test(g))){m.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(S.timeout){Q=setTimeout(function(){Z=true;U(R)},S.timeout)}function ai(){try{var ak=P(N).readyState;d("state = "+ak);if(ak&&ak.toLowerCase()=="uninitialized"){setTimeout(ai,50)}}catch(al){d("Server abort: ",al," (",al.name,")");U(O);if(Q){clearTimeout(Q)}Q=undefined}}var ag=[];try{if(S.extraData){for(var aj in S.extraData){if(S.extraData.hasOwnProperty(aj)){if(e.isPlainObject(S.extraData[aj])&&S.extraData[aj].hasOwnProperty("name")&&S.extraData[aj].hasOwnProperty("value")){ag.push(e('<input type="hidden" name="'+S.extraData[aj].name+'">').attr("value",S.extraData[aj].value).appendTo(H)[0])}else{ag.push(e('<input type="hidden" name="'+aj+'">').attr("value",S.extraData[aj]).appendTo(H)[0])}}}}if(!S.iframeTarget){J.appendTo("body");if(N.attachEvent){N.attachEvent("onload",U)}else{N.addEventListener("load",U,false)}}setTimeout(ai,15);H.submit()}finally{H.setAttribute("action",af);if(ah){H.setAttribute("target",ah)}else{m.removeAttr("target")}e(ag).remove()}}if(S.forceSync){X()}else{setTimeout(X,10)}var ad,ae,ab=50,I;function U(ak){if(L.aborted||I){return}try{ae=P(N)}catch(an){d("cannot access response document: ",an);ak=O}if(ak===R&&L){L.abort("timeout");return}else{if(ak==O&&L){L.abort("server abort");return}}if(!ae||ae.location.href==S.iframeSrc){if(!Z){return}}if(N.detachEvent){N.detachEvent("onload",U)}else{N.removeEventListener("load",U,false)}var ai="success",am;try{if(Z){throw"timeout"}var ah=S.dataType=="xml"||ae.XMLDocument||e.isXMLDoc(ae);d("isXml="+ah);if(!ah&&window.opera&&(ae.body===null||!ae.body.innerHTML)){if(--ab){d("requeing onLoad callback, DOM not available");setTimeout(U,250);return}}var ao=ae.body?ae.body:ae.documentElement;L.responseText=ao?ao.innerHTML:null;L.responseXML=ae.XMLDocument?ae.XMLDocument:ae;if(ah){S.dataType="xml"}L.getResponseHeader=function(ar){var aq={"content-type":S.dataType};return aq[ar]};if(ao){L.status=Number(ao.getAttribute("status"))||L.status;L.statusText=ao.getAttribute("statusText")||L.statusText}var af=(S.dataType||"").toLowerCase();var al=/(json|script|text)/.test(af);if(al||S.textarea){var aj=ae.getElementsByTagName("textarea")[0];if(aj){L.responseText=aj.value;L.status=Number(aj.getAttribute("status"))||L.status;L.statusText=aj.getAttribute("statusText")||L.statusText}else{if(al){var ag=ae.getElementsByTagName("pre")[0];var ap=ae.getElementsByTagName("body")[0];if(ag){L.responseText=ag.textContent?ag.textContent:ag.innerText}else{if(ap){L.responseText=ap.textContent?ap.textContent:ap.innerText}}}}}else{if(af=="xml"&&!L.responseXML&&L.responseText){L.responseXML=T(L.responseText)}}try{ad=k(L,af,S)}catch(ak){ai="parsererror";L.error=am=(ak||ai)}}catch(ak){d("error caught: ",ak);ai="error";L.error=am=(ak||ai)}if(L.aborted){d("upload aborted");ai=null}if(L.status){ai=(L.status>=200&&L.status<300||L.status===304)?"success":"error"}if(ai==="success"){if(S.success){S.success.call(S.context,ad,"success",L)}if(aa){e.event.trigger("ajaxSuccess",[L,S])}}else{if(ai){if(am===undefined){am=L.statusText}if(S.error){S.error.call(S.context,L,ai,am)}if(aa){e.event.trigger("ajaxError",[L,S,am])}}}if(aa){e.event.trigger("ajaxComplete",[L,S])}if(aa&&!--e.active){e.event.trigger("ajaxStop")}if(S.complete){S.complete.call(S.context,L,ai)}I=true;if(S.timeout){clearTimeout(Q)}setTimeout(function(){if(!S.iframeTarget){J.remove()}L.responseXML=null},100)}var T=e.parseXML||function(af,ag){if(window.ActiveXObject){ag=new ActiveXObject("Microsoft.XMLDOM");ag.async="false";ag.loadXML(af)}else{ag=(new DOMParser()).parseFromString(af,"text/xml")}return(ag&&ag.documentElement&&ag.documentElement.nodeName!="parsererror")?ag:null};var q=e.parseJSON||function(af){return window["eval"]("("+af+")")};var k=function(ak,ai,ah){var ag=ak.getResponseHeader("content-type")||"",af=ai==="xml"||!ai&&ag.indexOf("xml")>=0,aj=af?ak.responseXML:ak.responseText;if(af&&aj.documentElement.nodeName==="parsererror"){if(e.error){e.error("parsererror")}}if(ah&&ah.dataFilter){aj=ah.dataFilter(aj,ai)}if(typeof aj==="string"){if(ai==="json"||!ai&&ag.indexOf("json")>=0){aj=q(aj)}else{if(ai==="script"||!ai&&ag.indexOf("javascript")>=0){e.globalEval(aj)}}}return aj}}};e.fn.ajaxForm=function(f){f=f||{};f.delegation=f.delegation&&e.isFunction(e.fn.on);if(!f.delegation&&this.length===0){var g={s:this.selector,c:this.context};if(!e.isReady&&g.s){d("DOM not ready, queuing ajaxForm");e(function(){e(g.s,g.c).ajaxForm(f)});return this}d("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)"));return this}if(f.delegation){e(document).off("submit.form-plugin",this.selector,b).off("click.form-plugin",this.selector,a).on("submit.form-plugin",this.selector,f,b).on("click.form-plugin",this.selector,f,a);return this}return this.ajaxFormUnbind().bind("submit.form-plugin",f,b).bind("click.form-plugin",f,a)};function b(g){var f=g.data;if(!g.isDefaultPrevented()){g.preventDefault();e(this).ajaxSubmit(f)}}function a(j){var i=j.target;var g=e(i);if(!(g.is(":submit,input:image"))){var f=g.closest(":submit");if(f.length===0){return}i=f[0]}var h=this;h.clk=i;if(i.type=="image"){if(j.offsetX!==undefined){h.clk_x=j.offsetX;h.clk_y=j.offsetY}else{if(typeof e.fn.offset=="function"){var k=g.offset();h.clk_x=j.pageX-k.left;h.clk_y=j.pageY-k.top}else{h.clk_x=j.pageX-i.offsetLeft;h.clk_y=j.pageY-i.offsetTop}}}setTimeout(function(){h.clk=h.clk_x=h.clk_y=null},100)}e.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};e.fn.formToArray=function(w,f){var u=[];if(this.length===0){return u}var k=this[0];var o=w?k.getElementsByTagName("*"):k.elements;if(!o){return u}var q,p,m,x,l,s,h;for(q=0,s=o.length;q<s;q++){l=o[q];m=l.name;if(!m){continue}if(w&&k.clk&&l.type=="image"){if(!l.disabled&&k.clk==l){u.push({name:m,value:e(l).val(),type:l.type});u.push({name:m+".x",value:k.clk_x},{name:m+".y",value:k.clk_y})}continue}x=e.fieldValue(l,true);if(x&&x.constructor==Array){if(f){f.push(l)}for(p=0,h=x.length;p<h;p++){u.push({name:m,value:x[p]})}}else{if(c.fileapi&&l.type=="file"&&!l.disabled){if(f){f.push(l)}var g=l.files;if(g.length){for(p=0;p<g.length;p++){u.push({name:m,value:g[p],type:l.type})}}else{u.push({name:m,value:"",type:l.type})}}else{if(x!==null&&typeof x!="undefined"){if(f){f.push(l)}u.push({name:m,value:x,type:l.type,required:l.required})}}}}if(!w&&k.clk){var r=e(k.clk),t=r[0];m=t.name;if(m&&!t.disabled&&t.type=="image"){u.push({name:m,value:r.val()});u.push({name:m+".x",value:k.clk_x},{name:m+".y",value:k.clk_y})}}return u};e.fn.formSerialize=function(f){return e.param(this.formToArray(f))};e.fn.fieldSerialize=function(g){var f=[];this.each(function(){var l=this.name;if(!l){return}var j=e.fieldValue(this,g);if(j&&j.constructor==Array){for(var k=0,h=j.length;k<h;k++){f.push({name:l,value:j[k]})}}else{if(j!==null&&typeof j!="undefined"){f.push({name:this.name,value:j})}}});return e.param(f)};e.fn.fieldValue=function(l){for(var k=[],h=0,f=this.length;h<f;h++){var j=this[h];var g=e.fieldValue(j,l);if(g===null||typeof g=="undefined"||(g.constructor==Array&&!g.length)){continue}if(g.constructor==Array){e.merge(k,g)}else{k.push(g)}}return k};e.fieldValue=function(f,m){var h=f.name,s=f.type,u=f.tagName.toLowerCase();if(m===undefined){m=true}if(m&&(!h||f.disabled||s=="reset"||s=="button"||(s=="checkbox"||s=="radio")&&!f.checked||(s=="submit"||s=="image")&&f.form&&f.form.clk!=f||u=="select"&&f.selectedIndex==-1)){return null}if(u=="select"){var o=f.selectedIndex;if(o<0){return null}var q=[],g=f.options;var k=(s=="select-one");var p=(k?o+1:g.length);for(var j=(k?o:0);j<p;j++){var l=g[j];if(l.selected){var r=l.value;if(!r){r=(l.attributes&&l.attributes.value&&!(l.attributes.value.specified))?l.text:l.value}if(k){return r}q.push(r)}}return q}return e(f).val()};e.fn.clearForm=function(f){return this.each(function(){e("input,select,textarea",this).clearFields(f)})};e.fn.clearFields=e.fn.clearInputs=function(f){var g=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var i=this.type,h=this.tagName.toLowerCase();if(g.test(i)||h=="textarea"){this.value=""}else{if(i=="checkbox"||i=="radio"){this.checked=false}else{if(h=="select"){this.selectedIndex=-1}else{if(f){if((f===true&&/hidden/.test(i))||(typeof f=="string"&&e(this).is(f))){this.value=""}}}}}})};e.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset()}})};e.fn.enable=function(f){if(f===undefined){f=true}return this.each(function(){this.disabled=!f})};e.fn.selected=function(f){if(f===undefined){f=true}return this.each(function(){var g=this.type;if(g=="checkbox"||g=="radio"){this.checked=f}else{if(this.tagName.toLowerCase()=="option"){var h=e(this).parent("select");if(f&&h[0]&&h[0].type=="select-one"){h.find("option").selected(false)}this.selected=f}}})};e.fn.ajaxSubmit.debug=false;function d(){if(!e.fn.ajaxSubmit.debug){return}var f="[jquery.form] "+Array.prototype.join.call(arguments,"");if(window.console&&window.console.log){window.console.log(f)}else{if(window.opera&&window.opera.postError){window.opera.postError(f)}}}})(jQuery);