var ssp={};ssp.summary={init:function(){var n=$("#group-member-list"),t,i,r;if(n.length==1&&n.children().length>1){n.children().hide();t=$('<li class="group-member-toggle">'+n.data("toggle")+"<\/li>");n.prepend(t);t.on("click",function(){t.remove();n.children().show()})}i=$("#summary-victims-list");i.on("click",".delete-button",function(){var n=$(this),t=$("#summary-victim-delete-confirmation");return t.find("em").text(n.parent().data("name")),t.show(),$("#summary-victim-delete-confirm-button").attr("href",n.attr("href")),!1});$("#summary-victim-delete-cancel-button").on("click",function(){$("#summary-victim-delete-confirmation").hide()});r=$("#summary-perp-list");$(r).on("click",".delete-button",function(){var n=$(this),t=$("#summary-perp-delete-confirmation");return t.find("em").text(n.parent().data("name")),t.show(),$("#summary-perp-delete-confirm-button").attr("href",n.attr("href")),!1});$("#summary-perp-delete-cancel-button").on("click",function(){$("#summary-perp-delete-confirmation").hide()})}};ssp.type={current:null,init:function(){var n=$("#submission-type-list");ssp.type.current=n.data("current");n.on("click","input[type=radio]",function(){ssp.type.current>0&&(this.value!=ssp.type.current?$("#submission-change-warning").show():$("#submission-change-warning").hide())})}};ssp.dates={init:function(){$(".datepicker").each(function(){var n=$(this);n.datepicker({changeMonth:!0,changeYear:!0,yearRange:n.data("range"),maxDate:0,dateFormat:"dd/mm/yy"})})}};ssp.text={init:function(){$("textarea").each(function(n,t){var i=$(t),r=parseInt(i.attr("maxlength")),u=i.next().show().find(".textarea-counter-current");u.text(i.val().length);i.on("input propertychange",function(){var n=i.val().length;if(n<=r){u.text(n);return}i.val(i.val.substring(0,r));u.text(r)})})}};ssp.files={init:function(){ssp.files.initMultipleVictims();ssp.files.initAttachments()},initMultipleVictims:function(){var n=$("#File"),t,i;if(n.length==1){t=n.prev();t.addClass("hidden");n.addClass("hidden");i=$('<button class="orphan" type="button">'+t.html().replace(":","")+"<\/button>");n.closest("form").append(i);i.on("click",function(){n.click()});$("#Reset").show().on("click",function(){n.val("");$("#selected-file").remove()});n.on("change",function(){$("#selected-file").remove();t.after('<p id="selected-file">'+n.val().substring(n.val().lastIndexOf("\\")+1)+"<\/p>")})}},initAttachments:function(){var n=$("#Attachments"),t,i;if(n.length==1){t=n.prev();t.addClass("hidden");n.addClass("hidden");i=$('<button class="orphan" type="button">'+t.html().replace(":","")+"<\/button>");n.closest("fieldset").append(i);i.on("click",function(){n.click()});$("#Reset").show().on("click",function(){n.val("");$("#selected-file").remove()});n.on("change",function(){$("#selected-file").remove();window.File&&window.FileList?t.before('<p id="selected-file">'+$.map(n.prop("files"),function(n){return n.name.substring(n.name.lastIndexOf("\\")+1)}).join(", ")+"<\/p>"):t.before('<p id="selected-file">'+n.val().substring(n.val().lastIndexOf("\\")+1)+"<\/p>")})}}};ssp.lists={boundRadioButtonLists:[],init:function(){$("[data-specifies]").each(function(n){for(var t,i,r=$(this),u=!0,f=r.data("specifies").split(","),n=0;n<f.length;n++)if(t=document.getElementById(f[n]),i=t.tagName.toLowerCase(),i=="select"&&$(t.options[t.selectedIndex]).data("specify")==!0||i=="input"&&t.checked||i=="ul"&&$(t).find('input[data-specify="true"]:checked').length>0){u=!1;break}u&&r.hide()});$("select[data-specify]").on("change",function(){var n=$(this.options[this.selectedIndex]);n.data("specify")==!0?$('[data-specifies="'+this.id+'"]').show():$('[data-specifies="'+this.id+'"]').val("").hide()});$("input[data-specify]").each(function(){var n=$(this);if(n.attr("type")=="radio"){if(ssp.lists.boundRadioButtonLists.indexOf(this.name)==-1){ssp.lists.boundRadioButtonLists.push(this.name);$('input[name="'+this.name+'"]').on("change",function(){var n=$(this);$('[data-specifies*="'+n.attr("name")+'"]').each(function(){var t=$(this);t.data("specifies").indexOf(n.attr("id"))==-1?(this.tagName.toLowerCase()=="textarea"&&(t.next().find(".textarea-counter-current").text("0"),t.val("")),t.hide()):t.show()});$('[data-group-specifies*="'+n.attr("name")+'"]').each(function(){var n=$(this);n.find("input[type=text], textarea").val("");n.find("input[type=radio], input[type=checkbox]").prop("checked",!1);n.find("select").prop("selectedIndex",0);n.find("[data-specifies]").hide();n.hide()});n.data("specify")&&$('[data-group-specifies="'+n.attr("id")+'"]').show()})}}else if(n.attr("type")=="checkbox")n.on("click",function(){var n=$(this),t=n.data("container"),i=$('[data-specifies="'+t+'"]'),r=$('[data-specifies="'+n.attr("name")+'"]');n.is(":checked")?(r.show(),t!=null&&i.show()):$('[data-specify="'+n.attr("name")+'"]:checked').length==0&&(r.hide(),t!=null&&i.hide())})})}};ssp.collapsable={init:function(){$(document).on("click",".collapsable",function(n){n.preventDefault();let i=$(this).data("collapsable"),r=$(this).html(),t=$("#"+i);r=="+"?($(this).html("-"),t.show()):($(this).html("+"),t.hide())})}}