$(document).ready(function(){$(".entryform tbody tr:first td").addClass("pad_top_10");$(".entryform tr:last td").addClass("pad_bot_10");$("#url").css("display","none");$("#urlshow").click(function(){$("#url").toggle("blind")});$("#copyr").click(function(){copy_report()});$("#editr,#editok").click(function(){EditReport(this)});$(".param_other").dropdownchecklist();$(".ui-dropdownchecklist-dropcontainer-wrapper,.ui-dropdownchecklist-dropcontainer").css("width","auto").css("height","auto");$('.ui-dropdownchecklist-item > input[value="title"]').each(function(){var b=$(this).closest(".rparam_row").attr("data-id"),a=$(this).closest(".rparam_row").find('select > option[value="title"]').attr("data-title");$(this).next().css("margin-right","5px").after('<input class="param_title_input" name="param_title'+b+'" />');$(this).nextAll(".param_title_input").val(a)});$('.ui-dropdownchecklist-item > input[value="year"]').each(function(){var b=$(this).closest(".rparam_row").attr("data-id"),a=$(this).closest(".rparam_row").find('select > option[value="year"]').attr("data-year");$(this).next().css("margin-right","5px").after('<input class="param_year_input" name="param_year'+b+'" />');$(this).nextAll(".param_year_input").val(a).attr("title","1950:2050 / -100:+0")});$('.ui-dropdownchecklist-item > input[value="width"]').each(function(){var b=$(this).closest(".rparam_row").attr("data-id"),a=$(this).closest(".rparam_row").find('select > option[value="width"]').attr("data-width");$(this).next().css("margin-right","5px").after('<input class="param_width_input" name="param_width'+b+'" /> '+mydbr_loc.MYDBR_EDITREPORT_PARAM_CHARS);$(this).nextAll(".param_width_input").val(a)});$("#rname").focus();UserSearch("")});function copy_report(){jPrompt(mydbr_loc.MYDBR_EDITREPORT_COPY_NAME,$("#dbrreportprefix").val(),mydbr_loc.MYDBR_EDITREPORT_COPY,copyreport)}function copyreport(a){if(!a){return}$.ajax({url:"apps_v/copy_report.php",type:"post",data:{old_r:$("#spname").val(),new_r:a,csrf_token:csrf_token_get()},success:function(b){alert(b)}})}function EditReport(b){var a=$(b).attr("data-url");$.ajax({url:"apps_v/editReportInfo.php",type:"post",data:$("#myform").serialize()+"&csrf_token="+csrf_token_get(),success:function(c){if(c!=""){alert(c)}else{ReportParamsSet(a)}}});return false}function UserSearch(a){$.ajax({url:"apps_v/er_usersearch.php",type:"post",data:{report:$("#reportid").val(),search:a},success:function(b){$("#userlist").html(b)}});return false}function UserPrivSet(b,c,a,d){var e=0;if(b.checked){e=1}$.ajax({url:"apps_v/editReportUsr.php",type:"post",data:{add:e,user:c,report:a,auth:d,csrf_token:csrf_token_get()}});return false}function GroupPrivSet(b,d,a){var c=0;if(b.checked){c=1}$.ajax({url:"apps_v/editReportGrp.php",type:"post",data:{add:c,group:d,report:a,csrf_token:csrf_token_get()}});return false}function ReportParamsSet(a){$.ajax({url:"apps_v/editReportParam.php",type:"post",data:$("#procparams").serialize()+"&csrf_token="+csrf_token_get(),success:function(b){if(a){window.location.href=a}}});return false}function SetPublic(a,c){var b=a.checked?1:0;$.ajax({url:"apps/grantp.php",type:"post",data:{user:c,reportid:$("#reportid").val(),grant:b,csrf_token:csrf_token_get()},success:function(d){if(d!=""){alert(d)}}})}function SaveExts(a){var c="",b;for(b=0;b<a;b++){if(document.getElementById("extension"+b).checked){if(c!=""){c+=","}c+=document.getElementById("extension"+b).value}}$.ajax({url:"apps/reportexts.php",type:"post",data:{report:document.forms.myform.spname.value,extensions:c,csrf_token:csrf_token_get()}})};