var RicoEasy = {  Version: "1.1.0",  prototypeVersion: parseFloat(Prototype.Version.split(".")[0] + "." + Prototype.Version.split(".")[1])}RicoEasy.FormScanner = Prototype.Class.create();RicoEasy.FormScanner.prototype = {initialize: function(form, parameters){this.form = form;this.parameters = parameters;},addParameter: function(paramId, paramValue){var key = new Array(2);key[0] = paramId;key[1] = paramValue;this.parameters.push(key);},executeRecursiveScan: function(elm, parentElm, ix){if (elm.tagName == "INPUT" || elm.tagName == "SELECT" || elm.tagName == "TEXTAREA"){if (elm.name != null && elm.name != undefined && elm.name != ""){if (elm.type != "checkbox" && elm.type != "radio"){this.addParameter(elm.name, elm.value);}else{if (elm.checked)this.addParameter(elm.name, elm.value)}}}if (elm.hasChildNodes()) this.executeRecursiveScan(elm.childNodes[0], elm,0);ix++;if (ix < parentElm.childNodes.length) this.executeRecursiveScan(parentElm.childNodes[ix], parentElm, ix);return;},executeScan: function(){if (this.form == null) return;if (this.form.hasChildNodes()){var elm = this.form.childNodes[0];this.executeRecursiveScan(elm,this.form,0);}}}//####################################################################################RicoEasy.RicoWrapper = Prototype.Class.create();RicoEasy.RicoWrapper.prototype = {initialize: function(ajaxEngine, form, url, onComplete, renderURLTemplate, actionURLTemplate, URLTokenToReplace){this.ajaxEngine = ajaxEngine;this.form = form;this.url = url;this.onComplete = onComplete;this.renderURLTemplate = renderURLTemplate;this.actionURLTemplate = actionURLTemplate;this.URLTokenToReplace = URLTokenToReplace;this.parameters = new Array();this.elements = new Array();this.ricoParameters = "";this.formAutoScan = true;},setAjaxEngine: function(ajaxEngine){this.ajaxEngine = ajaxEngine;},setForm: function(form){this.form = form;},setUrl: function(url){this.url = url;},setFormAutoScan: function(autoScan){this.formAutoScan = autoScan;},setOnComplete: function(onComplete){this.onComplete = onComplete;},addElement: function(elementId){this.elements.push(elementId);},addParameter: function(paramId, paramValue){var key = new Array(2);key[0] = paramId;key[1] = paramValue;this.parameters.push(key);},setRenderURLTemplate: function(renderURLTemplate){this.renderURLTemplate = renderURLTemplate;},setActionURLTemplate: function(actionURLTemplate){this.actionURLTemplate = actionURLTemplate;},setURLTokenToReplace: function(URLTokenToReplace){this.URLTokenToReplace = URLTokenToReplace;},fetchFormParameters: function(){var formScanner = new RicoEasy.FormScanner(this.form, this.parameters);formScanner.executeScan();},buildParametersString: function(){var ricoParameters = "";for (var ix = 0; ix < this.parameters.length; ix++){ricoParameters += (ricoParameters != "") ? "&" : "";ricoParameters += this.parameters[ix][0] + "=" + this.parameters[ix][1];}this.ricoParameters = ricoParameters;},decodeAction: function(codedAction){var actionDecoded = "";var actionValue = codedAction.split(":");var actionPath = actionValue[0];var actionPurpose = actionValue[1];if (actionPurpose.toUpperCase() == "ACTION") actionDecoded = this.getAjaxRequestActionPath(actionPath);else if (actionPurpose.toUpperCase() == "RENDER")  actionDecoded = this.getAjaxRequestRenderPath(actionPath);else alert("wrong action path");return actionDecoded;},getAjaxRequestActionPath: function(path){while (path.indexOf("/") >= 0) path = path.replace("/", "%2F");return this.actionURLTemplate.replace(this.URLTokenToReplace, path);},getAjaxRequestRenderPath: function(path){while (path.indexOf("/") >= 0) path = path.replace("/", "%2F");return this.renderURLTemplate.replace(this.URLTokenToReplace, path);},prepareAndSendRequest: function(){var ricoURL = this.decodeAction(this.url);this.ajaxEngine.registerRequest("ricoRequest", ricoURL);for (var ix = 0; ix < this.elements.length; ix ++){this.ajaxEngine.registerAjaxElement(this.elements[ix]);}if (this.onComplete != undefined && this.onComplete != null){this.ajaxEngine.sendRequest("ricoRequest", {parameters: this.ricoParameters, onComplete: this.onComplete});}else{this.ajaxEngine.sendRequest("ricoRequest", {parameters: this.ricoParameters});}},executeRequest: function(){if (this.formAutoScan) this.fetchFormParameters();this.buildParametersString();this.prepareAndSendRequest();}}