var space=registerNamespace("RS");space.form=function(a){this.key=a;this.fieldList=new Object();this.errorList=new Object();this.method=new Object();this.fieldAdd=function(b,c){if(this.fieldList[b]!=undefined){throw'Field "'+b+'" already exist'}this.fieldList[b]=c;$("#"+b).bind("keyup",{func:this.method.submit},function(d){if(d.keyCode==13){d.data.func()}})};this.onSubmit=function(b){if(b.keyCode==13){return this.method.submit()}};this.fieldGet=function(b){if(this.fieldList[b]==undefined){throw'Field "'+b+'" does not exist'}return this.fieldList[b]};this.validate=function(){this.getCurrentData();this.clearErrors();for(a in this.fieldList){if(!this.fieldList[a].isValid()){this.errorList[a]=this.fieldList[a].errorMessage}}this.showErrors();if(this.countErrors()==0){return true}return};this.getCurrentData=function(){for(a in this.fieldList){this.fieldList[a].data=$("#"+a).val()}};this.showErrors=function(){var b;for(a in this.errorList){b=$("<span>");b.attr("id","vldError"+a);b.addClass("FormError");b.css("padding-left","5px");b.html(this.errorList[a]);$("#"+a).parent().append('<span id="vldError'+a+'" class="FormError" style="padding-left: 0;">'+this.errorList[a]+"</span>")}};this.clearErrors=function(){for(a in this.errorList){$("#vldError"+a).remove()}this.errorList=new Object()};this.countErrors=function(){var b=0;for(a in this.errorList){++b}return b};this.addExtraError=function(c,b){this.errorList[c]=b};this.isValid=function(){return this.validate()};this.setMethod=function(b,c){this.method[b]=c};this.setSubmitHandler=function(c,b){switch(b){case"click":$("#"+c).bind("click",this.method.submit);break}};this.setSubmitButtonHandler=function(b){$("#"+b).bind("submit",function(){return false})}};