!function(e){e.fn.getAjaxForSelect=function(t){this.defParams={disabledText:"",targetPage:"",concatValue:!1,trigger:!1},thisopt=e.extend(!0,{},this.defParams,t);var i={};i.init=function(){o.length&&(source=o.attr("id"),selval=e("#"+source).val(),e.ajax({url:thisopt.targetPage,cache:!1,timeout:opt.funcTimeOut,dataType:"json",data:{source:source,selval:selval,trigger:thisopt.trigger}}).done(function(t){null!=t?(e.fn.toggleLoader("show"),i.refreshit(t)):e.fn.showDialog({type:"danger",title:"Errore!",bodymsg:"Si è verificato un errore nell'elaborazione dei dati",buttonLabel:"Chiudi"})}).fail(function(){""!=selval?e.fn.showDialog({type:"danger",title:"Errore!",bodymsg:"Si è verificato un errore nell'elaborazione dei dati",buttonLabel:"Chiudi"}):i.disableall()}))},i.disableall=function(t){disabledTitle=thisopt.disabledText,"undefined"==typeof e("#"+source).data("group")&&(result=e("#"+source).parents(opt.eGroupFormCont).nextUntil().find("select"+opt.eSelectDynamic),result=result.length>0?result:"",e("#"+source).data("group",result),e.fn.toLog("registro il group per "+source)),group=e("#"+source).data("group"),e.each(group,function(){thisid=e(this).attr("id"),"undefined"==typeof e("#"+thisid).data("title")&&(title=e("#"+thisid+" option:selected").text(),e("#"+thisid).data("title",title),e.fn.toLog("registro il title per "+thisid)),""==thisopt.disabledText&&(disabledTitle="undefined"!=typeof t&&"n"==t.subdataConcat?t.label:e("#"+thisid).data("title")),e("#"+thisid).html('<option value=" " selected disabled>'+disabledTitle+"</option>").promise().done(function(){e(this).prop("disabled",!0)}),e.fn.toLog("disabilito select "+thisid)})},i.refreshit=function(t){disable_select="n"==t.subdataConcat?!0:!1,i.disableall(t),"undefined"==typeof e("#"+source).data("nextid")&&(result=e("#"+source).parents(opt.eGroupFormCont).next().find("select"+opt.eSelectDynamic).attr("id"),result="undefined"!=typeof result?result:"",e("#"+source).data("nextid",result),e.fn.toLog("registro il nextid per "+source)),nextid=e("#"+source).data("nextid"),""!=nextid&&(disabledTitle=""!=thisopt.disabledText?thisopt.disabledText:t.label,disabledTitle="n"==t.subdataConcat?disabledTitle:e("#"+nextid).data("choice"),"y"==t.subdataConcat&&t.subdata.length>0&&e("#"+nextid).html('<option value="" selected>'+disabledTitle+"</option>").promise().done(function(){e(this).append(e.map(t.subdata,function(t){return console.log(t.selected),thisvalue=1==thisopt.concatValue?t.code+"__"+encodeURI(t.label):t.code,thisselect="undefined"!=typeof t.selected&&"y"==t.selected?!0:!1,e(e.parseHTML("<option>")).attr({value:thisvalue,selected:thisselect,disabled:disable_select}).text(t.label)})),e(this).prop("disabled",disable_select)})),e.fn.toggleLoader("hide")},i.setdefault=function(){e(opt.eSelectDynamic).map(function(){e("#"+this.id).get(0).selectedIndex=0})};var o=e(this);return i.init(),i},e.fn.autoCompleteAddon=function(t,i){if(this.defParams={elem:"",suffix:"_autocomplete",type:"hidden",name:"",value:"",keypressed:"",keyprevent:"9, 13",debug:!1},this.opt=e.extend(!0,{},this.defParams,t),"object"==typeof this.opt.elem&&""!=this.opt.elem){originId=e(this.opt.elem).attr("id"),cloneId=originId+this.opt.suffix;var o={init:function(){0==e("#"+cloneId).length&&e(e.parseHTML("<input>")).attr({id:cloneId,name:cloneId,value:this.opt.value,type:this.opt.type}).insertAfter("#"+originId)},remove:function(){var t=this.opt.keyprevent.split(",").map(function(e){return parseInt(e,10)});console.log(e("#"+cloneId)),e("#"+cloneId).length&&-1===e.inArray(this.opt.keypressed,t)&&e("#"+cloneId).remove()},reset:function(){e("#"+originId).length&&(0==e("#"+cloneId).length||""==e("#"+cloneId).val())&&e("#"+originId).val("")}};if(o[i])return o[i].apply(this,Array.prototype.slice.call(arguments,1));if("object"==typeof i||!i)return o.init.apply(this,Array.prototype.slice.call(arguments,1));this.opt.debug===!0&&console.log("Il metodo "+i+"non esiste")}},e.fn.validDate=function(e,t){t="undefined"!=typeof t?t:"/";var i=e.split(t),o=new Date(i[2]+"/"+i[1]+"/"+i[0]);return!(!o||o.getMonth()+1!=i[1]||o.getDate()!=Number(i[0]))}}(jQuery),$(document).ready(function(){$(opt.eReadOnly).focus(function(){$.fn.showDialog({type:"info",title:"Informazione",bodymsg:"Questo campo non pu&ograve; essere modificato",buttonLabel:"Chiudi"})}),$(opt.ePassPolicy).focus(function(){"y"!=$(opt.ePolicyPassword).data("viewed")&&($(opt.ePolicyPassword).removeClass("hidden"),$(opt.ePolicyPassword).data("viewed","y"))}),$(opt.ePassPolicy).on("blur change focusout",function(){$(opt.ePolicyPassword).addClass("hidde")}),$(opt.ePolicyToggle).click(function(){$(opt.ePolicyPassword).toggleClass("hidden")}),$(opt.eTareaCountChars).on("focus keyup keypress",function(){limit=$(this).attr("maxlength");var e=[limit-$(this).val().length];$(this).parent().children(opt.eCharsLeft).removeClass("invisible"),$(this).parent().children(opt.eCharsLeft).find("span").text(e)}),$(opt.ePassShow).click(function(e){e.preventDefault(),_this=$(this),field=_this.parent("div").find("input"),"password"==field.attr("type")?(field.focus(),field.attr("type","text"),field.attr("autocomplete","off"),_this.children("span").addClass("miur-eye-slash-close")):(field.attr("type","password"),field.attr("autocomplete","on"),_this.children("span").removeClass("miur-eye-slash-close"))}),$("[data-"+opt.eChainSelGroup+"]").on("change now",function(){_thisOption=$(this).find("option:selected"),_thisGroup=$(this).data(opt.eChainSelGroup),$(this).parents().nextAll().find("[data-"+opt.eChainSelGroup+"="+_thisGroup+"]").each(function(){$(this).parent(opt.eIsChainselHide).addClass("hidden"),1!=$(this).hasClass("hidden")&&$(this).find("option:selected").attr("selected",!1)}),"undefined"!=typeof _thisOption.data(opt.eIsChildData)&&$("#"+_thisOption.data(opt.eIsChildData)).removeClass("hidden")}).trigger("now"),$("[data-"+opt.switchDataInput+"]").on("click now",function(e){_thisradio=$(this),switchid=$(_thisradio).data(opt.switchDataInput),ischecked=$(_thisradio).prop("checked"),$(_thisradio).closest("form").find(opt.eSwitchInputToggle).each(function(){_thisgroup=$(this),_thisid=$(_thisgroup).attr("id"),"click"==e.type&&($(_thisgroup).hasClass("switch-input-onlydisable")||$(_thisgroup).addClass("hidden"),$(_thisgroup).find("input, select, textarea").prop("disabled",!0),$("[data-switch-input='"+_thisid+"']").next("span").removeClass(opt.switchInputActive)),_thisid==switchid&&ischecked===!0&&($(_thisgroup).hasClass("switch-input-onlydisable")||$("#"+switchid).removeClass("hidden"),$(_thisgroup).find("input, select, textarea").prop("disabled",!1),$("[data-switch-input='"+switchid+"']").next("span").addClass(opt.switchInputActive))})}).trigger("now"),$(opt.eCheckBoxAll).change(function(){var e=$(this).closest("form").find(":checkbox");$(this).is(":checked")?e.prop("checked",!0):e.prop("checked",!1)})});