if(!window.Form){window.Form={}}(function(){Form.Request=new Class({Binds:["onSubmit","onFormValidate"],Implements:[Options,Events,Class.Occlude],options:{requestOptions:{evalScripts:true,useSpinner:true,emulation:false,link:"ignore"},sendButtonClicked:true,extraData:{},resetForm:true},property:"form.request",initialize:function(b,c,a){this.element=document.id(b);if(this.occlude()){return this.occluded}this.update=document.id(c);this.setOptions(a);this.makeRequest();if(this.options.resetForm){this.request.addEvent("success",function(){$try(function(){this.element.reset()}.bind(this));if(window.OverText){OverText.update()}}.bind(this))}this.attach()},toElement:function(){return this.element},makeRequest:function(){this.request=new Request.HTML($merge({update:this.update,emulation:false,spinnerTarget:this.element,method:this.element.get("method")||"post"},this.options.requestOptions)).addEvents({success:function(b,d,c,a){["complete","success"].each(function(e){this.fireEvent(e,[this.update,b,d,c,a])},this)}.bind(this),failure:function(){this.fireEvent("complete",arguments).fireEvent("failure",arguments)}.bind(this),exception:function(){this.fireEvent("failure",arguments)}.bind(this)})},attach:function(a){a=$pick(a,true);method=a?"addEvent":"removeEvent";this.element[method]("click:relay(button, input[type=submit])",this.saveClickedButton.bind(this));var b=this.element.retrieve("validator");if(b){b[method]("onFormValidate",this.onFormValidate)}else{this.element[method]("submit",this.onSubmit)}},detach:function(){this.attach(false);return this},enable:function(){this.attach();return this},disable:function(){this.detach();return this},onFormValidate:function(b,a,d){if(!d){return}var c=this.element.retrieve("validator");if(b||(c&&!c.options.stopOnFailure)){if(d&&d.stop){d.stop()}this.send()}},onSubmit:function(b){var a=this.element.retrieve("validator");if(a){this.element.removeEvent("submit",this.onSubmit);a.addEvent("onFormValidate",this.onFormValidate);this.element.validate();return}if(b){b.stop()}this.send()},saveClickedButton:function(a,b){if(!this.options.sendButtonClicked){return}if(!b.get("name")){return}this.options.extraData[b.get("name")]=b.get("value")||true;this.clickedCleaner=function(){delete this.options.extraData[b.get("name")];this.clickedCleaner=$empty}.bind(this)},clickedCleaner:$empty,send:function(){var b=this.element.toQueryString().trim();var a=$H(this.options.extraData).toQueryString();if(b){b+="&"+a}else{b=a}this.fireEvent("send",[this.element,b.parseQueryString()]);this.request.send({data:b,url:this.element.get("action")});this.clickedCleaner();return this}});Element.Properties.formRequest={set:function(){var a=Array.link(arguments,{options:Object.type,update:Element.type,updateId:String.type});var c=a.update||a.updateId;var b=this.retrieve("form.request");if(c){if(b){b.update=document.id(c)}this.store("form.request:update",c)}if(a.options){if(b){b.setOptions(a.options)}this.store("form.request:options",a.options)}return this},get:function(){var a=Array.link(arguments,{options:Object.type,update:Element.type,updateId:String.type});var b=a.update||a.updateId;if(a.options||b||!this.retrieve("form.request")){if(a.options||!this.retrieve("form.request:options")){this.set("form.request",a.options)}if(b){this.set("form.request",b)}this.store("form.request",new Form.Request(this,this.retrieve("form.request:update"),this.retrieve("form.request:options")))}return this.retrieve("form.request")}};Element.implement({formUpdate:function(b,a){this.get("formRequest",b,a).send();return this}})})();