/*!
 * jQuery Form Plugin
 * version: 2.45 (09-AUG-2010)
 * @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(s){if(!this.length){a("ajaxSubmit: skipping submit process - no element selected");return this}if(typeof s=="function"){s={success:s}}var d=b.trim(this.attr("action"));if(d){d=(d.match(/^([^#]+)/)||[])[1]}d=d||window.location.href||"";s=b.extend(true,{url:d,type:this.attr("method")||"GET",iframeSrc:/^https/i.test(window.location.href||"")?"javascript:false":"about:blank"},s);var t={};this.trigger("form-pre-serialize",[this,s,t]);if(t.veto){a("ajaxSubmit: submit vetoed via form-pre-serialize trigger");return this}if(s.beforeSerialize&&s.beforeSerialize(this,s)===false){a("ajaxSubmit: submit aborted via beforeSerialize callback");return this}var f,o,l=this.formToArray(s.semantic);if(s.data){s.extraData=s.data;for(f in s.data){if(s.data[f] instanceof Array){for(var h in s.data[f]){l.push({name:f,value:s.data[f][h]})}}else{o=s.data[f];o=b.isFunction(o)?o():o;l.push({name:f,value:o})}}}if(s.beforeSubmit&&s.beforeSubmit(l,this,s)===false){a("ajaxSubmit: submit aborted via beforeSubmit callback");return this}this.trigger("form-submit-validate",[l,this,s,t]);if(t.veto){a("ajaxSubmit: submit vetoed via form-submit-validate trigger");return this}var c=b.param(l);if(s.type.toUpperCase()=="GET"){s.url+=(s.url.indexOf("?")>=0?"&":"?")+c;s.data=null}else{s.data=c}var r=this,j=[];if(s.resetForm){j.push(function(){r.resetForm()})}if(s.clearForm){j.push(function(){r.clearForm()})}if(!s.dataType&&s.target){var p=s.success||function(){};j.push(function(n){var k=s.replaceTarget?"replaceWith":"html";b(s.target)[k](n).each(p,arguments)})}else{if(s.success){j.push(s.success)}}s.success=function(v,n,w){var u=s.context||s;for(var q=0,k=j.length;q<k;q++){j[q].apply(u,[v,n,w||r,r])}};var g=b("input:file",this).length>0;var e="multipart/form-data";var i=(r.attr("enctype")==e||r.attr("encoding")==e);if(s.iframe!==false&&(g||s.iframe||i)){if(s.closeKeepAlive){b.get(s.closeKeepAlive,m)}else{m()}}else{b.ajax(s)}this.trigger("form-submit-notify",[this,s]);return this;function m(){var v=r[0];if(b(":input[name=submit],:input[id=submit]",v).length){alert('Error: Form elements must not have name or id of "submit".');return}var I=b.extend(true,{},b.ajaxSettings,s);I.context=I.context||I;var u="jqFormIO"+(new Date().getTime());var D=b('<iframe id="'+u+'" name="'+u+'" src="'+I.iframeSrc+'" onload="var f = jQuery(this).data(\'form-plugin-onload\'); if (f) f();" />');var F=D[0];D.css({position:"absolute",top:"-1000px",left:"-1000px"});var H={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(){this.aborted=1;D.attr("src",I.iframeSrc)}};var E=I.global;if(E&&!b.active++){b.event.trigger("ajaxStart")}if(E){b.event.trigger("ajaxSend",[H,I])}if(I.beforeSend&&I.beforeSend.call(I.context,H,I)===false){if(I.global){b.active--}return}if(H.aborted){return}var q=false;var z=0;var k=v.clk;if(k){var x=k.name;if(x&&!k.disabled){I.extraData=I.extraData||{};I.extraData[x]=k.value;if(k.type=="image"){I.extraData[x+".x"]=v.clk_x;I.extraData[x+".y"]=v.clk_y}}}function w(){var L=r.attr("target"),J=r.attr("action");v.setAttribute("target",u);if(v.getAttribute("method")!="POST"){v.setAttribute("method","POST")}if(v.getAttribute("action")!=I.url){v.setAttribute("action",I.url)}if(!I.skipEncodingOverride){r.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"})}if(I.timeout){setTimeout(function(){z=true;A()},I.timeout)}var K=[];try{if(I.extraData){for(var M in I.extraData){K.push(b('<input type="hidden" name="'+M+'" value="'+I.extraData[M]+'" />').appendTo(v)[0])}}D.appendTo("body");D.data("form-plugin-onload",A);v.submit()}finally{v.setAttribute("action",J);if(L){v.setAttribute("target",L)}else{r.removeAttr("target")}b(K).remove()}}if(I.forceSync){w()}else{setTimeout(w,10)}var B,G,y=100;function A(){if(q){return}D.removeData("form-plugin-onload");var J=true;try{if(z){throw"timeout"}G=F.contentWindow?F.contentWindow.document:F.contentDocument?F.contentDocument:F.document;var N=I.dataType=="xml"||G.XMLDocument||b.isXMLDoc(G);a("isXml="+N);if(!N&&(G.body==null||G.body.innerHTML=="")){if(--y){a("requeing onLoad callback, DOM not available");setTimeout(A,250);return}a("Could not access iframe DOM after 100 tries.");throw"DOMException: not available"}a("response detected");q=true;H.responseText=G.documentElement?G.documentElement.innerHTML:null;H.responseXML=G.XMLDocument?G.XMLDocument:G;H.getResponseHeader=function(P){var O={"content-type":I.dataType};return O[P]};var M=/(json|script)/.test(I.dataType);if(M||I.textarea){var n=G.getElementsByTagName("textarea")[0];if(n){H.responseText=n.value}else{if(M){var L=G.getElementsByTagName("pre")[0];if(L){H.responseText=L.innerHTML}}}}else{if(I.dataType=="xml"&&!H.responseXML&&H.responseText!=null){H.responseXML=C(H.responseText)}}B=b.httpData(H,I.dataType)}catch(K){a("error caught:",K);J=false;H.error=K;b.handleError(I,H,"error",K)}if(J){I.success.call(I.context,B,"success");if(E){b.event.trigger("ajaxSuccess",[H,I])}}if(E){b.event.trigger("ajaxComplete",[H,I])}if(E&&!--b.active){b.event.trigger("ajaxStop")}if(I.complete){I.complete.call(I.context,H,J?"success":"error")}setTimeout(function(){D.removeData("form-plugin-onload");D.remove();H.responseXML=null},100)}function C(n,J){if(window.ActiveXObject){J=new ActiveXObject("Microsoft.XMLDOM");J.async="false";J.loadXML(n)}else{J=(new DOMParser()).parseFromString(n,"text/xml")}return(J&&J.documentElement&&J.documentElement.tagName!="parsererror")?J:null}}};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(f){if(!f.isDefaultPrevented()){f.preventDefault();b(this).ajaxSubmit(c)}}).bind("click.form-plugin",function(j){var i=j.target;var g=b(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 b.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)})};b.fn.ajaxFormUnbind=function(){return this.unbind("submit.form-plugin click.form-plugin")};b.fn.formToArray=function(o){var m=[];if(this.length===0){return m}var c=this[0];var f=o?c.getElementsByTagName("*"):c.elements;if(!f){return m}var h,g,e,p,d;for(h=0,max=f.length;h<max;h++){d=f[h];e=d.name;if(!e){continue}if(o&&c.clk&&d.type=="image"){if(!d.disabled&&c.clk==d){m.push({name:e,value:b(d).val()});m.push({name:e+".x",value:c.clk_x},{name:e+".y",value:c.clk_y})}continue}p=b.fieldValue(d,true);if(p&&p.constructor==Array){for(g=0,jmax=p.length;g<jmax;g++){m.push({name:e,value:p[g]})}}else{if(p!==null&&typeof p!="undefined"){m.push({name:e,value:p})}}}if(!o&&c.clk){var k=b(c.clk),l=k[0];e=l.name;if(e&&!l.disabled&&l.type=="image"){m.push({name:e,value:k.val()});m.push({name:e+".x",value:c.clk_x},{name:e+".y",value:c.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,j){var e=c.name,p=c.type,q=c.tagName.toLowerCase();if(j===undefined){j=true}if(j&&(!e||c.disabled||p=="reset"||p=="button"||(p=="checkbox"||p=="radio")&&!c.checked||(p=="submit"||p=="image")&&c.form&&c.form.clk!=c||q=="select"&&c.selectedIndex==-1)){return null}if(q=="select"){var k=c.selectedIndex;if(k<0){return null}var m=[],d=c.options;var g=(p=="select-one");var l=(g?k+1:d.length);for(var f=(g?k:0);f<l;f++){var h=d[f];if(h.selected){var o=h.value;if(!o){o=(h.attributes&&h.attributes.value&&!(h.attributes.value.specified))?h.text:h.value}if(g){return o}m.push(o)}}return m}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(){return this.each(function(){var d=this.type,c=this.tagName.toLowerCase();if(d=="text"||d=="password"||c=="textarea"){this.value=""}else{if(d=="checkbox"||d=="radio"){this.checked=false}else{if(c=="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}}})};function a(){if(b.fn.ajaxSubmit.debug){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);