function _ajaxTemplate(n,t,i,r,u,f,e){return e===undefined&&(e=!0),$.ajax({url:n,type:u?"get":"post",async:e,cache:f?!0:!1,data:t,success:function(n){$(".alert").remove();$.trim(n.message)&&(n.alertType==undefined?showAlert("success",n.message):showAlert(n.alertType,n.message));i!=undefined&&i(n,r)},complete:function(){}})}function KeepDecimalPlaces(n,t){if(!$.isNumeric(n)||Math.floor(t)!=t||!$.isNumeric(t))return"";var i=Math.pow(10,t);return n=Math.floor(n*i)/i,parseFloat(n).toFixed(t)}function Sortit(){var n=$("#currentRolelist option");n.sort(function(n,t){return n.text<t.text?-1:n.text==t.text?0:1});$(n).remove();$("#currentRolelist").append($(n))}var ajaxGet=function(n,t,i,r,u){return _ajaxTemplate(n,t,i,r,!0,u)},ajaxGet1=function(n){return _ajaxTemplate(n.actionUrl,n.params,n.funcOnSuccess,n.paramsFuncOnSuccess,!0,n.isCache)},ajaxPost=function(n,t,i,r,u){return _ajaxTemplate(n,t,i,r,!1,!1,u)},ajaxPost1=function(n){return _ajaxTemplate(n.actionUrl,n.params,n.funcOnSuccess,n.paramsFuncOnSuccess,!1,!1,n.isAsync)},resetValidationErrors,removeValidationIndicator,formatFileSize,btnLoading;$("#main").on("submit",".formAjax",function(n){var r,u;n.preventDefault();var t=$(this),f=$(this).parent(),i=t.find("button[type=submit]");btnLoading(i,"on");resetValidationErrors(t);r=t.serializeArray();u=t.prop("action");ajaxPost(u,r,function(n){n.html!=undefined&&f.empty().prepend(n.html);n.UserName!=undefined&&$("#userName").text(n.UserName)}).done(function(){btnLoading(i,"off");t.find("input").prop("disabled",!1);t.find("select").prop("disabled",!1)});t.find("input").prop("disabled",!0);t.find("select").prop("disabled",!0)});resetValidationErrors=function(n){n.find("input").removeClass("input-validation-error");n.find("select").removeClass("input-validation-error");n.find(".field-validation-error").empty()};removeValidationIndicator=function(n){$("#"+n).removeClass("input-validation-error");$("span.field-validation-error[data-valmsg-for="+n+"]").empty()};formatFileSize=function(n){return typeof n!="number"?"":n>=1073741824?(n/1073741824).toFixed(2)+" GB":n>=1048576?(n/1048576).toFixed(2)+" MB":(n/1024).toFixed(2)+" KB"};jQuery.fn.center=function(){return this.css("position","absolute"),this.css("top",Math.max(0,($(window).height()-$(this).outerHeight())/2+$(window).scrollTop())+"px"),this.css("left",Math.max(0,($(window).width()-$(this).outerWidth())/2+$(window).scrollLeft())+"px"),this};btnLoading=function(n,t){switch(t){case"on":var i=n.css("width"),r=n.css("height");n.prop("disabled",!0).css({width:i,height:r}).text("").addClass("loading20");break;case"off":n.removeClass("loading20").text(n.prop("name")).prop("disabled",!1);break;default:n.text()!==""?(i=n.css("width"),r=n.css("height"),n.prop("disabled",!0).css({width:i,height:r}).text("").addClass("loading20")):n.removeClass("loading20").text(n.prop("name")).prop("disabled",!1)}};$("body").on("click",":input[data-loading-text]",function(){var t=$(this),i=t.hasClass("validateBeforeSubmit"),n;i?(n=t.closest("form"),n.length>0?n.valid()&&$(this).button("loading"):alert("Error: form is not specified.")):$(this).button("loading")});var formSubmitOneParam=function(n,t,i){$('<form action="'+n+'" method="POST"><input type="hidden" name="'+t+'" id="'+t+'" value="'+i+'"><\/form>').appendTo($(document.body)).submit()},formSubmit=function(n,t){$("#xgForm").remove();var i='<form id="xgForm" action="'+n+'" method="POST">';$.each(t,function(n,t){i+='<input type="hidden" name="'+n+'" id="'+n+'" value="'+t+'">'});i+="<\/form>";$(i).appendTo($(document.body)).submit()},showAlert=function(n,t){var i='<div class="alert alert-'+n+' alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;<\/button>'+t+"<\/div>";$(".alert").remove();$("#main").prepend(i)},deleteIcon='<span class="glyphicon glyphicon-trash red" style="font-size:16px"><\/span>',deleteLink='<a class="deleteLink" title="Delete">'+deleteIcon+"<\/a>",deleteButton='<button id="deleteButton" type="button">'+deleteIcon+"<\/button>",editIcon='<span class="glyphicon glyphicon-edit" style="font-size:16px"><\/span>',editLink='<a class="editLink" title="Edit">'+editIcon+"<\/a>",editButton='<button id="editButton" type="button">'+editIcon+"<\/button>",listIcon='<span class="glyphicon glyphicon-list" style="font-size:16px"><\/span>',listButton='<button id="listButton" type="button">'+listIcon+"<\/button>",showAlertModal=function(n){var t=function(n,t,i,r,u){if(n=n==undefined?"Confirm":n,t=t==undefined?"Are you sure you want to delete the record?":t,i=i==undefined?"Yes":i,r=r==undefined?"No":r,u=u==undefined?"400px":u,$("#modalAlert").length<1){var f='<div class="modal fade bs-example-modal-sm" id="modalAlert" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true"><div class="modal-dialog" style="max-width: '+u+'; transform: translate(0, 50%) !important; -ms-transform: translate(0, 50%) !important; -webkit-transform: translate(0, 50%) !important;" ><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;<\/span><span class="sr-only">Close<\/span><\/button><h4 id="modalLabelAlert" class="modal-title">'+n+'<\/h4><\/div><div id="modalBodyAlert" class="modal-body"><p id="modalDescAlert">'+t+'<\/p><br /><div class="formEditGroup text-center"><button class="width100 btn btn-success" id="btnYesAlert">'+i+'<\/button> <button type="button" class="width100 btn btn-default" id="btnNoAlert" data-dismiss="modal">'+r+"<\/button><\/div><\/div><\/div><\/div><\/div>";$("body").append(f);$("#modalAlert").on("hide.bs.modal",function(){$("body").off("click","#btnYesAlert")});$("#modalAlert").on("shown.bs.modal",function(){$("#btnNoAlert").focus()})}else $("#modalLabelAlert").text(n),$("#modalDescAlert").html(t),$("#btnYesAlert").text(i),$("#btnNoAlert").text(r)};t(n.title,n.discHtml,n.yesBtnName,n.noBtnName,n.modalWidth);$("body").one("click","#btnYesAlert",function(){n.callbackYes!=undefined?n.callbackYes(n.yesParams):n.callbackNo!=undefined&&n.callbackNo(n.noParams);$("#modalAlert").modal("hide")});$("#modalAlert").modal({backdrop:"static"})},docReadyLayout=function(){Modernizr.history&&ajaxify();autoShowHideDropdown();ajaxErrorGlobalHandler()},ajaxify=function(){window.addEventListener("popstate",function(n){var t=n.state,i;t!=undefined&&(t.redirectUrl!=undefined?location.href=t.redirectUrl:(i=window[t.caller],i!=undefined?i(t.dataArray):location.href=t.url))});$("#navBar a").click(function(){var n=$(this).prop("href");history.pushState({redirectUrl:n},null,n)})},historyPushState=function(n,t,i){Modernizr.history&&history.pushState({dataArray:n,caller:t,url:i},null,i)},historyReplaceState=function(n,t,i){Modernizr.history&&history.replaceState({dataArray:n,caller:t,url:i},null,i)},autoShowHideDropdown=function(){$("#userProfileDropdown .dropdown-toggle, #userProfileDropdown .dropdown-menu").mouseenter(function(){$("#userProfileDropdown").addClass("open")}).mouseleave(function(){$("#userProfileDropdown").removeClass("open")})},ajaxErrorGlobalHandler=function(){$(document).ajaxError(function(n,t){typeof AjaxModal!="undefined"&&(AjaxModal.resetModalAfterSubmit(),AjaxModal.hideModal());t.responseJSON!=undefined?showAlert("danger",t.responseJSON.message):showAlert("danger","ajax error")})},getSelect2Config=function(n,t,i,r){r==undefined&&(r=10);var u={initSelection:function(n,t){t({text:$(n).attr("hName"),id:$(n).val()})},placeholder:n,delay:250,minimumInputLength:0,allowClear:!0,ajax:{quietMillis:150,url:t,dataType:"json",data:function(n,t){return{pageSize:r,pageNum:t,searchTerm:n}},results:function(n,t){var i=t*r<n.Total;return{results:n.Results,more:i}}}};return i!=undefined&&$.extend(u,{width:i}),u};$(function(){$.validator.methods.date=function(n){var t=!0;try{$.datepicker.parseDate("d M yy",n)}catch(i){t=!1}return t}})