/*
 * jQuery Form Plugin
 * version: 2.85 (23-SEP-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(B){B.fn.ajaxSubmit=function(D){if(!this.length){A("ajaxSubmit: skipping submit process - no element selected");return this}var C,N,F,G=this;if(typeof D=="function"){D={success:D}}C=this.attr("method");N=this.attr("action");F=(typeof N==="string")?B.trim(N):"";F=F||window.location.href||"";if(F){F=(F.match(/^([^#]+)/)||[])[1]}D=B.extend(true,{url:F,success:B.ajaxSettings.success,type:C||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},D);var J={};this.trigger("form-pre-serialize",[this,D,J]);if(J.veto){A("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(D.beforeSerialize&&D.beforeSerialize(this,D)===false){A("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var M,I,S=this.formToArray(D.semantic);if(D.data){D.extraData=D.data;for(M in D.data){if(B.isArray(D.data[M])){for(var O in D.data[M]){S.push({name:M,value:D.data[M][O]})}}else{I=D.data[M];I=B.isFunction(I)?I():I;S.push({name:M,value:I})}}}if(D.beforeSubmit&&D.beforeSubmit(S,this,D)===false){A("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[S,this,D,J]);if(J.veto){A("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var L=B.param(S);if(D.type.toUpperCase()=="GET"){D.url+=(D.url.indexOf("?")>=0?"&":"?")+L;D.data=null}else{D.data=L}var T=[];if(D.resetForm){T.push(function(){G.resetForm()})}if(D.clearForm){T.push(function(){G.clearForm()})}if(!D.dataType&&D.target){var E=D.success||function(){};T.push(function(V){var U=D.replaceTarget?"replaceWith":"html";B(D.target)[U](V).each(E,arguments)})}else{if(D.success){T.push(D.success)}}D.success=function(Y,V,Z){var X=D.context||D;for(var W=0,U=T.length;W<U;W++){T[W].apply(X,[Y,V,Z||G,G])}};var Q=B("input:file",this).length>0;var P="multipart/form-data";var K=(G.attr("enctype")==P||G.attr("encoding")==P);if(D.iframe!==false&&(Q||D.iframe||K)){if(D.closeKeepAlive){B.get(D.closeKeepAlive,function(){H(S)})}else{H(S)}}else{if(B.browser.msie&&C=="get"&&typeof D.type==="undefined"){var R=G[0].getAttribute("method");if(typeof R==="string"){D.type=R}}B.ajax(D)}this.trigger("form-submit-notify",[this,D]);return this;function H(x){var X=G[0],W,t,l,v,p,Z,e,c,d,q,u,j;var b=!!B.fn.prop;if(x){if(b){for(t=0;t<x.length;t++){W=B(X[x[t].name]);W.prop("disabled",false)}}else{for(t=0;t<x.length;t++){W=B(X[x[t].name]);W.removeAttr("disabled")}}}if(B(":input[name=submit],:input[id=submit]",X).length){alert('Error: Form elements must not have name or id of "submit".');return }l=B.extend(true,{},B.ajaxSettings,D);l.context=l.context||l;p="jqFormIO"+(new Date().getTime());if(l.iframeTarget){Z=B(l.iframeTarget);q=Z.attr("name");if(q==null){Z.attr("name",p)}else{p=q}}else{Z=B('<iframe name="'+p+'" src="'+l.iframeSrc+'" />');Z.css({position:"absolute",top:"-1000px",left:"-1000px"})}e=Z[0];c={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(a){var g=(a==="timeout"?"timeout":"aborted");A("aborting upload... "+g);this.aborted=1;Z.attr("src",l.iframeSrc);c.error=g;l.error&&l.error.call(l.context,c,g,a);v&&B.event.trigger("ajaxError",[c,l,g]);l.complete&&l.complete.call(l.context,c,g)}};v=l.global;if(v&&!B.active++){B.event.trigger("ajaxStart")}if(v){B.event.trigger("ajaxSend",[c,l])}if(l.beforeSend&&l.beforeSend.call(l.context,c,l)===false){if(l.global){B.active--}return }if(c.aborted){return }d=X.clk;if(d){q=d.name;if(q&&!d.disabled){l.extraData=l.extraData||{};l.extraData[q]=d.value;if(d.type=="image"){l.extraData[q+".x"]=X.clk_x;l.extraData[q+".y"]=X.clk_y}}}var k=1;var f=2;function h(g){var a=g.contentWindow?g.contentWindow.document:g.contentDocument?g.contentDocument:g.document;return a}function r(){var s=G.attr("target"),g=G.attr("action");X.setAttribute("target",p);if(!C){X.setAttribute("method","POST")}if(g!=l.url){X.setAttribute("action",l.url)}if(!l.skipEncodingOverride&&(!C||/post/i.test(C))){G.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(l.timeout){j=setTimeout(function(){u=true;o(k)},l.timeout)}function AA(){try{var a=h(e).readyState;A("state = "+a);if(a.toLowerCase()=="uninitialized"){setTimeout(AA,50)}}catch(n){A("Server abort: ",n," (",n.name,")");o(f);j&&clearTimeout(j);j=undefined}}var i=[];try{if(l.extraData){for(var AB in l.extraData){i.push(B('<input type="hidden" name="'+AB+'" />').attr("value",l.extraData[AB]).appendTo(X)[0])}}if(!l.iframeTarget){Z.appendTo("body");e.attachEvent?e.attachEvent("onload",o):e.addEventListener("load",o,false)}setTimeout(AA,15);X.submit()}finally{X.setAttribute("action",g);if(s){X.setAttribute("target",s)}else{G.removeAttr("target")}B(i).remove()}}if(l.forceSync){r()}else{setTimeout(r,10)}var y,z,w=50,Y;function o(AA){if(c.aborted||Y){return }try{z=h(e)}catch(AD){A("cannot access response document: ",AD);AA=f}if(AA===k&&c){c.abort("timeout");return }else{if(AA==f&&c){c.abort("server abort");return }}if(!z||z.location.href==l.iframeSrc){if(!u){return }}e.detachEvent?e.detachEvent("onload",o):e.removeEventListener("load",o,false);var n="success",AC;try{if(u){throw"timeout"}var i=l.dataType=="xml"||z.XMLDocument||B.isXMLDoc(z);A("isXml="+i);if(!i&&window.opera&&(z.body==null||z.body.innerHTML=="")){if(--w){A("requeing onLoad callback, DOM not available");setTimeout(o,250);return }}var AE=z.body?z.body:z.documentElement;c.responseText=AE?AE.innerHTML:null;c.responseXML=z.XMLDocument?z.XMLDocument:z;if(i){l.dataType="xml"}c.getResponseHeader=function(AH){var AG={"content-type":l.dataType};return AG[AH]};if(AE){c.status=Number(AE.getAttribute("status"))||c.status;c.statusText=AE.getAttribute("statusText")||c.statusText}var a=(l.dataType||"").toLowerCase();var AB=/(json|script|text)/.test(a);if(AB||l.textarea){var s=z.getElementsByTagName("textarea")[0];if(s){c.responseText=s.value;c.status=Number(s.getAttribute("status"))||c.status;c.statusText=s.getAttribute("statusText")||c.statusText}else{if(AB){var g=z.getElementsByTagName("pre")[0];var AF=z.getElementsByTagName("body")[0];if(g){c.responseText=g.textContent?g.textContent:g.innerText}else{if(AF){c.responseText=AF.textContent?AF.textContent:AF.innerText}}}}}else{if(a=="xml"&&!c.responseXML&&c.responseText!=null){c.responseXML=m(c.responseText)}}try{y=U(c,a,l)}catch(AA){n="parsererror";c.error=AC=(AA||n)}}catch(AA){A("error caught: ",AA);n="error";c.error=AC=(AA||n)}if(c.aborted){A("upload aborted");n=null}if(c.status){n=(c.status>=200&&c.status<300||c.status===304)?"success":"error"}if(n==="success"){l.success&&l.success.call(l.context,y,"success",c);v&&B.event.trigger("ajaxSuccess",[c,l])}else{if(n){if(AC==undefined){AC=c.statusText}l.error&&l.error.call(l.context,c,n,AC);v&&B.event.trigger("ajaxError",[c,l,AC])}}v&&B.event.trigger("ajaxComplete",[c,l]);if(v&&!--B.active){B.event.trigger("ajaxStop")}l.complete&&l.complete.call(l.context,c,n);Y=true;if(l.timeout){clearTimeout(j)}setTimeout(function(){if(!l.iframeTarget){Z.remove()}c.responseXML=null},100)}var m=B.parseXML||function(a,g){if(window.ActiveXObject){g=new ActiveXObject("Microsoft.XMLDOM");g.async="false";g.loadXML(a)}else{g=(new DOMParser()).parseFromString(a,"text/xml")}return(g&&g.documentElement&&g.documentElement.nodeName!="parsererror")?g:null};var V=B.parseJSON||function(a){return window["eval"]("("+a+")")};var U=function(AB,n,i){var g=AB.getResponseHeader("content-type")||"",a=n==="xml"||!n&&g.indexOf("xml")>=0,AA=a?AB.responseXML:AB.responseText;if(a&&AA.documentElement.nodeName==="parsererror"){B.error&&B.error("parsererror")}if(i&&i.dataFilter){AA=i.dataFilter(AA,n)}if(typeof AA==="string"){if(n==="json"||!n&&g.indexOf("json")>=0){AA=V(AA)}else{if(n==="script"||!n&&g.indexOf("javascript")>=0){B.globalEval(AA)}}}return AA}}};B.fn.ajaxForm=function(C){if(this.length===0){var D={s:this.selector,c:this.context};if(!B.isReady&&D.s){A("DOM not ready, queuing ajaxForm");B(function(){B(D.s,D.c).ajaxForm(C)});return this}A("terminating; zero elements found by selector"+(B.isReady?"":" (DOM not ready)"));return this}return this.ajaxFormUnbind().bind("submit.form-plugin",function(E){if(!E.isDefaultPrevented()){E.preventDefault();B(this).ajaxSubmit(C)}}).bind("click.form-plugin",function(I){var H=I.target;var F=B(H);if(!(F.is(":submit,input:image"))){var E=F.closest(":submit");if(E.length==0){return }H=E[0]}var G=this;G.clk=H;if(H.type=="image"){if(I.offsetX!=undefined){G.clk_x=I.offsetX;G.clk_y=I.offsetY}else{if(typeof B.fn.offset=="function"){var J=F.offset();G.clk_x=I.pageX-J.left;G.clk_y=I.pageY-J.top}else{G.clk_x=I.pageX-H.offsetLeft;G.clk_y=I.pageY-H.offsetTop}}}setTimeout(function(){G.clk=G.clk_x=G.clk_y=null},100)})};B.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};B.fn.formToArray=function(N){var M=[];if(this.length===0){return M}var D=this[0];var G=N?D.getElementsByTagName("*"):D.elements;if(!G){return M}var I,H,F,O,E,K,C;for(I=0,K=G.length;I<K;I++){E=G[I];F=E.name;if(!F){continue}if(N&&D.clk&&E.type=="image"){if(!E.disabled&&D.clk==E){M.push({name:F,value:B(E).val()});M.push({name:F+".x",value:D.clk_x},{name:F+".y",value:D.clk_y})}continue}O=B.fieldValue(E,true);if(O&&O.constructor==Array){for(H=0,C=O.length;H<C;H++){M.push({name:F,value:O[H]})}}else{if(O!==null&&typeof O!="undefined"){M.push({name:F,value:O})}}}if(!N&&D.clk){var J=B(D.clk),L=J[0];F=L.name;if(F&&!L.disabled&&L.type=="image"){M.push({name:F,value:J.val()});M.push({name:F+".x",value:D.clk_x},{name:F+".y",value:D.clk_y})}}return M};B.fn.formSerialize=function(C){return B.param(this.formToArray(C))};B.fn.fieldSerialize=function(D){var C=[];this.each(function(){var H=this.name;if(!H){return }var F=B.fieldValue(this,D);if(F&&F.constructor==Array){for(var G=0,E=F.length;G<E;G++){C.push({name:H,value:F[G]})}}else{if(F!==null&&typeof F!="undefined"){C.push({name:this.name,value:F})}}});return B.param(C)};B.fn.fieldValue=function(H){for(var G=[],E=0,C=this.length;E<C;E++){var F=this[E];var D=B.fieldValue(F,H);if(D===null||typeof D=="undefined"||(D.constructor==Array&&!D.length)){continue}D.constructor==Array?B.merge(G,D):G.push(D)}return G};B.fieldValue=function(C,I){var E=C.name,N=C.type,O=C.tagName.toLowerCase();if(I===undefined){I=true}if(I&&(!E||C.disabled||N=="reset"||N=="button"||(N=="checkbox"||N=="radio")&&!C.checked||(N=="submit"||N=="image")&&C.form&&C.form.clk!=C||O=="select"&&C.selectedIndex==-1)){return null}if(O=="select"){var J=C.selectedIndex;if(J<0){return null}var L=[],D=C.options;var G=(N=="select-one");var K=(G?J+1:D.length);for(var F=(G?J:0);F<K;F++){var H=D[F];if(H.selected){var M=H.value;if(!M){M=(H.attributes&&H.attributes.value&&!(H.attributes.value.specified))?H.text:H.value}if(G){return M}L.push(M)}}return L}return B(C).val()};B.fn.clearForm=function(){return this.each(function(){B("input,select,textarea",this).clearFields()})};B.fn.clearFields=B.fn.clearInputs=function(){var C=/^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;return this.each(function(){var E=this.type,D=this.tagName.toLowerCase();if(C.test(E)||D=="textarea"){this.value=""}else{if(E=="checkbox"||E=="radio"){this.checked=false}else{if(D=="select"){this.selectedIndex=-1}}}})};B.fn.resetForm=function(){return this.each(function(){if(typeof this.reset=="function"||(typeof this.reset=="object"&&!this.reset.nodeType)){this.reset()}})};B.fn.enable=function(C){if(C===undefined){C=true}return this.each(function(){this.disabled=!C})};B.fn.selected=function(C){if(C===undefined){C=true}return this.each(function(){var D=this.type;if(D=="checkbox"||D=="radio"){this.checked=C}else{if(this.tagName.toLowerCase()=="option"){var E=B(this).parent("select");if(C&&E[0]&&E[0].type=="select-one"){E.find("option").selected(false)}this.selected=C}}})};B.fn.ajaxSubmit.debug=false;function A(){if(!B.fn.ajaxSubmit.debug){return }var C="[jquery.form] "+Array.prototype.join.call(arguments,"");if(window.console&&window.console.log){window.console.log(C)}else{if(window.opera&&window.opera.postError){window.opera.postError(C)}}}})(jQuery);