DOMAssistant.NephtaliForms = function () { return { publicMethods : [ "setNephtaliForm" ], pipe : null, portGroup : null, invalidHandler : null, onValidating : function () {}, responseHandler : null, onLoading : function () {}, valid : null, action : null, method : null, parameters : null, setNephtaliForm : function (nObj) { $(this).addEvent("submit", DOMAssistant.NephtaliForms.sendForm); this.pipe = nObj.pipe; this.portGroup = nObj.portGroup; this.invalidHandler = nObj.invalidHandler; this.onValidating = (nObj.onValidating != undefined) ? nObj.onValidating : DOMAssistant.NephtaliForms.onValidating; this.responseHandler = nObj.responseHandler; this.onLoading = (nObj.onLoading != undefined) ? nObj.onLoading : DOMAssistant.NephtaliForms.onLoading; this.action = this.getAttribute("action"); this.method = this.getAttribute("method"); return this; }, isValid : function (validationResponse){ if(validationResponse.indexOf("n__none") == -1){ var keyValuePairs = validationResponse.split('__'); var errors = new Array(); for(var i = 1; i < keyValuePairs.length; i++){ var tandem = keyValuePairs[i].split('--'); errors[tandem[0]] = tandem[1]; } this.invalidHandler.call(this, errors); this.valid = false; } else{ this.valid = true; this.onLoading(); DOMAssistant.NephtaliForms.send.call(this); } }, validate : function () { if(this.method == "get"){ var validateURL = this.action + "?" + this.parameters + "nmode=validate&npipe=" + this.pipe + "&nportgroup=" + this.portGroup; this.ajax({ url : validateURL, method: "GET", params : "", callback : DOMAssistant.NephtaliForms.isValid, headers : {} }); }else{ var validateURL = this.action + "?nmode=validate&npipe=" + this.pipe + "&nportgroup=" + this.portGroup; this.ajax({ url : validateURL, method: "POST", params : this.parameters, callback : DOMAssistant.NephtaliForms.isValid, headers : {}, noParse : true }); } }, send : function () { if(this.method == "get"){ var requestURL = this.action + "?" + this.parameters + "nmode=htmlfrag&npipe=" + this.pipe; this.ajax({ url : requestURL, method: "GET", params : "", callback : this.responseHandler, headers : {} }); } else{ var requestURL = this.action + "?nmode=htmlfrag&npipe=" + this.pipe; this.ajax({ url : requestURL, method: "POST", params : this.parameters, callback : this.responseHandler, headers : {}, noParse : true }); } }, sendForm : function () { var fields = this.elements; this.parameters = ""; for (var i=0, il=fields.length, field, type, isSelect; i