function doubleSelectionList(A){$("select[id*="+A+"]").each(function(){var C=$(this);var B=$(C).parent().siblings().next("div").children("select");if((C.children("option").length+B.children("option").length)==0){C.attr("disabled","disabled");B.attr("disabled","disabled")}A=A.replace(/\.from$/,"");C.dblclick(function(){return !C.children("option:selected").remove().appendTo(B)});B.dblclick(function(){return !B.children("option:selected").remove().appendTo(C)});$("#add").click(function(){return !C.children("option:selected").remove().appendTo(B)});$("#remove").click(function(){return !B.children("option:selected").remove().appendTo(C)})});$("form input[type='submit']").click(function(){$("select[id*="+A+"]").each(function(){$(this).children("option").each(function(B){$(this).removeAttr("selected")});$(this).parent().siblings().next("div").children("select").children("option").each(function(B){$(this).attr("selected","selected")})})})}function bindDoubleSelect(B,A){$("select[id*="+A+"]").each(function(){var C=$(this).val();$("select[id*="+B+"]").each(function(){var E=$(this);var D=$(E).parent().siblings().next("div").children("select");if(C==0||(E.children("option").length+D.children("option").length)==0){E.attr("disabled","disabled");D.attr("disabled","disabled");E.closest("tr").hide()}dependentId=B.replace(/\.from$/,"");E.dblclick(function(){return !E.children("option:selected").remove().appendTo(D)});D.dblclick(function(){return !D.children("option:selected").remove().appendTo(E)});$("#add").click(function(){return !E.children("option:selected").remove().appendTo(D)});$("#remove").click(function(){return !D.children("option:selected").remove().appendTo(E)})})});$("form input[type='submit']").click(function(){$("select[id*="+B+"]").each(function(){$(this).children("option").each(function(C){$(this).removeAttr("selected")});$(this).parent().siblings().next("div").children("select").children("option").each(function(C){$(this).attr("selected","selected")})})});$("select[id*="+A+"]").change(function(){var C=$(this).val().replace(/[^0-9]/g,"");$("select[id*="+B+"]").each(function(){var E=$(this);var D=E.parent().siblings().next("div").children("select");E.attr("disabled","disabled");D.attr("disabled","disabled");E.closest("tr").hide();if(C>0){dependentId=B.replace(/\.from$/,"");$(this).parent("span").addClass("loading");$.get("/selection-list-external/"+dependentId+"/"+C+".html",function(G,I){var H=$(G).children("option");var F="";$(H).each(function(){F+='<option value="'+$(this).attr("value")+'">'+$(this).text()+"</option>"});E.html(F);E.parent("span").removeClass("loading");if($(H).length>0){E.removeAttr("disabled");D.removeAttr("disabled");E.closest("tr").show()}D.html("")})}else{E.children("option").removeAttr("selected");E.html("");D.html("")}})})}function bindCheckbox(B,A){$("input[id*="+B+"]").click(function(){var D=$(this).attr("checked");var C=this.id.substring(0,this.id.indexOf(".")+1)+A;$("[id*="+C+"]").each(function(){if(this.tagName!="SPAN"){var E=this.id;E=E.substring(C.length+1);if($(this).attr("disabled")){$(this).removeAttr("disabled")}else{$(this).attr("disabled",true)}$(this).toggleClass("disabled");if(E.match("^false")){E=E.replace(/^false/,"true")}else{if(E.match("^true")){E=E.replace(/^true/,"false")}}E=C+"."+E;this.id=E;E=E.replace(/:input$/,"");$(this).attr("name",E)}})})}function bindSelect(B,A){$("select[id*="+A+"]").each(function(){if($(this).val()==0){$("select[id*="+B+"]").each(function(){this.disabled=true})}});$("select[id*="+A+"]").bind("change keyup",function(){var C=$(this).val().replace(/[^0-9]/g,"");$("select[id*="+B+"]").each(function(){if($(this).data("id")==C){return }$(this).data("id",C);var D=this;D.disabled=true;if(C>0){$(this).parent("span").addClass("loading");$.get("/selection-list-external/"+B+"/"+C+".html",function(F,I){var H=$(D).children("option:selected").attr("value");var G=$(F).children("option");var E="";$(G).each(function(){var J=$(this).attr("value");E+='<option value="'+J+'" '+(H==J?'selected="selected"':"")+">"+$(this).text()+"</option>"});$(D).html(E);$(D).parent("span").removeClass("loading");D.disabled=false})}else{$("option",D).removeAttr("selected")}})})}function reloadPage(D){var B=D.split(",");for(var A=0;A<B.length;A++){var C=B[A];$("select[id*="+C+"], input[type=radio][id*="+C+"]").change(function(){$($(this).parents("form").get(0)).append('<input type="hidden" name="forms_submit_id" id="forms_submit_id:input" value="no-validation"/>').submit()})}}function setCalendar(A){$("input.calendar").each(function(){var I=$(this);var K=I.metadata();var E=K.yearRange;var G=new Date(K.defaultDate);var F=K.format;var C=K.changeYear;var D=K.yearSet;var H=K.defaultDateSet;var J=K.dateSetIfAfter;var B="dd/mm/yy";if(K.dateFormat){B=K.dateFormat}I.datepicker({changeMonth:true,showOn:"both",buttonImage:"/.grafika/ikonki/calendar.gif",buttonImageOnly:true,changeYear:true,dateFormat:B,onChangeMonthYear:function(N,Q,O){if(D!==undefined){var P=$('*[id="'+D+':input"]');var L=new Date();var M=P.datepicker("getDate");if(M!=null){L.setFullYear(N,M.getMonth()+1,M.getDay())}else{L.setFullYear(N,Q-1,1)}P.datepicker("setDate",L)}},onSelect:function(Q,O){var L=Q.split("/");if(L.length==3){var M=new Date();M.setFullYear(L[2],L[1]-1,L[0]);if(H!==undefined){var P=$('*[id="'+H+':input"]');P.datepicker("option","defaultDate",M)}if(J!==undefined){var P=$('*[id="'+J+':input"]');var N=P.datepicker("getDate");if(N!=null&&M>N){P.datepicker("setDate",M)}}}if(A){A()}}});if(C!==undefined){I.datepicker("option","changeYear",false)}if(F!==undefined){I.datepicker("option","dateFormat",F)}if(E!==undefined){I.datepicker("option","yearRange",E)}if(G!==undefined&&!isNaN(G)){I.datepicker("option","defaultDate",G)}})}function setTimePicker(){$("input.timepicker").each(function(){$(this).timepickr({suffix:"",buttonImage:"/.grafika/ikonki/clock.gif"})})};
