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