var objParams={'params':{}};var jsStorage={_intErrorCount:null,data:{},_init:function(){jsStorage._intErrorCount=0;},set_data:function(in_strArea,in_objData){if("object"==typeof(in_objData)){var objNewData={};var objRefJsStoreDataArea={};if(jsStorage.data[in_strArea]){objRefJsStoreDataArea=jsStorage.data[in_strArea];}jQuery.each(in_objData,function(strDataName,objDataValue){if(typeof(objRefJsStoreDataArea[strDataName])=="object"){if(objRefJsStoreDataArea[strDataName].val==objDataValue.value){return true;}else if(objRefJsStoreDataArea[strDataName].err){delete(objRefJsStoreDataArea[strDataName].err);}if(objDataValue.label&&objDataValue.label.length>1){objRefJsStoreDataArea[strDataName].lbl=objDataValue.label;}objRefJsStoreDataArea[strDataName].val=objDataValue.value;}else{if(objDataValue.label&&objDataValue.label.length>1){objNewData[strDataName]={"val":objDataValue.value,"lbl":objDataValue.label};}else{objNewData[strDataName]={"val":objDataValue.value};}}});jsStorage.data[in_strArea]=jQuery.extend(jsStorage.data[in_strArea],objNewData);}},remove_data:function(in_strArea,in_strDataName){if("undefined"!=typeof(jsStorage.data[in_strArea])){var objRefJsStoreDataArea=jsStorage.data[in_strArea];if("undefined"!=typeof(objRefJsStoreDataArea[in_strDataName])){delete objRefJsStoreDataArea[in_strDataName];}}},getErrorCount:function(){var error=0;jQuery.each(jsStorage.data,function(strDataAreaName,strDataAreaNode){jQuery.each(strDataAreaNode,function(strDataName,objDataNode){if(undefined!=objDataNode.err){error++;}});});return error;},performJsonResponse:function(in_objJsonReturn){jQuery.each(in_objJsonReturn,function(strDataAreaName,strDataAreaNode){jQuery.each(strDataAreaNode,function(strDataName,objDataNode){var objRefJsStoreDataArea=jsStorage.data[strDataAreaName];if("undefined"!=typeof(objRefJsStoreDataArea[strDataName])){if(strDataAreaNode[strDataName].val==objRefJsStoreDataArea[strDataName].val){if(undefined!=strDataAreaNode[strDataName].err){objRefJsStoreDataArea[strDataName].err=1;}else if(undefined!=objRefJsStoreDataArea[strDataName].err){delete objRefJsStoreDataArea[strDataName].err;}}}});});}};function ajaxModule(){var self=this;var targetId="";var targetType="";var targetCallback="";var targetCallbackParams="";var boolShowWaiting=true;var boolReplaceContent=false;jQuery(document).ajaxStart(function(){var myPos;if(targetId){myPos=getElementPosition(targetId);if(boolShowWaiting)showWaiting((myPos.x+myPos.w),myPos.y);}else{if(boolShowWaiting)showWaiting();}});jQuery(document).ajaxStop(function(){hideWaiting();});this.sendRequest=function(in_hashPostParameters,in_strUrl,in_boolAjaxAsyncReq){if("boolean"!=typeof(in_boolAjaxAsyncReq)){in_boolAjaxAsyncReq="true";}jQuery.ajax({type:"POST",url:in_strUrl,timeout:15000,dataType:"json",async:in_boolAjaxAsyncReq,data:in_hashPostParameters,cache:false,success:function(responseData){processData(responseData.strJsonResponseData);},beforeSend:function(){},error:function(request_object,error_string,exception_object){if(boolTestsystem==true){if("object"==typeof(console)){console.debug(error_string);console.debug(request_object);}}}});};this.setShowWaiting=function(in_boolShowWaiting){if(in_boolShowWaiting){boolShowWaiting=true;}else{boolShowWaiting=false;}};this.setTarget=function(in_strTargetId,in_strTargetCallback,in_strTargetCallbackParams,in_boolReplaceContent){var strTargetType="";if("undefined"==typeof(in_strTargetCallback)){in_strTargetCallback="";}if("undefined"==typeof(in_strTargetCallbackParams)){in_strTargetCallbackParams="";}if("boolean"==typeof(in_boolReplaceContent)){boolReplaceContent=in_boolReplaceContent;}if("string"==typeof(in_strTargetId)){if("check_formular_fields"==in_strTargetId){strTargetType='CHECK_FORMULAR';in_strTargetId="";}else if("callback"==in_strTargetId){strTargetType='CALLBACK';in_strTargetId="";}else if("objSaver"==in_strTargetId){strTargetType='OBJSAVER';in_strTargetId="";}else{if(jQuery("#"+in_strTargetId).length>0){var str_nodeName=jQuery("#"+in_strTargetId).attr("nodeName");switch(str_nodeName){case'SELECT':strTargetType='OPTIONS';break;case'TD':case'DIV':case'SPAN':strTargetType='DOM';break;case'INPUT':case'TEXTAREA':default:strTargetType='TEXT';break;}}}}targetType=strTargetType;targetId=in_strTargetId;targetCallback=in_strTargetCallback;targetCallbackParams=in_strTargetCallbackParams;};this.getTargetType=function(){return targetType;};function processData(in_strData){switch(targetType){case"TEXT":updateTextNode(targetId,in_strData);break;case"DOM":updateDomNode(targetId,in_strData);break;case"OPTIONS":updateOptions(targetId,in_strData);break;case"CHECK_FORMULAR":updateFormularData(in_strData);break;case"OBJSAVER":updateObjSaverData(in_strData);break;case"CALLBACK":var strJoinedParams="";if("object"==typeof(targetCallbackParams)){strJoinedParams=targetCallbackParams.join(",");strJoinedParams=","+strJoinedParams;}eval(targetCallback+"("+JSON.stringify(in_strData)+strJoinedParams+")");break;default:if(boolTestsystem==true){if("object"==typeof(console)){console.debug("No targetType specified");}}}}function updateTextNode(tId,strData){if(strData){var objDiv=document.getElementById(tId);var textObj=document.createTextNode(strData+"<a href=''>t</a>");if(boolReplaceContent){jQuery(objDiv).html("");}objDiv.appendChild(textObj);document.getElementById(tId).style.visibility="visible";}}function updateDomNode(tId,strData){if(strData){var strDivId="#"+tId;if(boolReplaceContent){jQuery(strDivId).html("");}jQuery(strDivId).html(strData);jQuery(strDivId).show();}}function updateOptions(tId,strData){if(strData){var arrOptions=strData.split("\n");var arrOption;jQuery("#"+tId).empty();for(var i=0;i<arrOptions.length;i++){arrOption=arrOptions[i].split('=');jQuery("#"+tId).append("<option title='"+arrOption[0]+"' value='"+arrOption[0]+"'>"+arrOption[1]+"</option>");}if(arrOptions.length<=1){jQuery("#"+tId).attr("disabled","disabled");}else{jQuery("#"+tId).removeAttr("disabled");jQuery("#"+tId).show();}}}function updateFormularData(strData){jsStorage.performJsonResponse(strData.objParams);if(strData){jQuery.each(strData.objParams,function(strAreaName,strAreaNode){jQuery.each(strAreaNode,function(strDataName,strDataNode){var strLabelName=strDataName;if(strDataNode.lbl&&strDataNode.lbl.length>0){strLabelName=strDataNode.lbl;}if(strDataNode.err){jQuery("#"+strDataName).addClass("error").bind("click focus",function(e){jQuery("#"+strDataName).removeClass("error").unbind("click focus");jQuery("#label_"+strLabelName+" > span").remove();});jQuery("#label_"+strLabelName+" > span").remove();jQuery("#label_"+strLabelName).append("<span class='error'><br />"+strDataNode.err+"</span>");}});});}}function updateObjSaverData(in_strData){if("object"==typeof in_strData){if("undefined"==typeof objSaver){objSaver={};}jQuery.each(in_strData,function(strObjName,voidObjData){if(strObjName!="strError"){if("undefined"==typeof objSaver[strObjName]){switch(typeof(voidObjData)){case'boolean':objSaver[strObjName]=false;break;case'number':objSaver[strObjName]=0;break;case'string':objSaver[strObjName]="";break;case'object':if(voidObjData.length>0){objSaver[strObjName]=[];}else{objSaver[strObjName]={};}break;case'function':default:objSaver[strObjName]="";break;}}var objSaverNewProp=objSaver[strObjName];if("object"==typeof(voidObjData)){jQuery.each(voidObjData,function(strOptionName,objOptionData){objSaverNewProp[strOptionName]=objOptionData;});}else{objSaver[strObjName]=voidObjData;}}});}}}
