function autoSave(n,t,i,r){$.ajax({url:"/Home/PingServer",async:!0,success:function(u){var o,f,e;if(u=="1"){if(typeof CKEDITOR!="undefined")for(instance in CKEDITOR.instances)CKEDITOR.instances[instance].updateElement();$("[data-role=editor].k-content").each((n,t)=>$(t).getKendoEditor().refresh());o=formatAutosaveDateTime();r&&(t+=" : "+o,i+=" : "+o);f=document.forms[n];e={method:$(f).attr("method"),action:$(f).attr("action"),data:$(f).serialize(),onSuccess:$(f).attr("onSuccess"),onError:$(f).attr("onError")};$.ajax({async:!0,type:e.method,url:e.action,data:e.data,success:function(){typeof e.onSuccess!="undefined"&&eval(e.onSuccess);$("#autosaveSuccessNotification").html(t).css("background-color","#1A1").fadeIn("slow",function(){setTimeout(function(){$("#autosaveSuccessNotification").fadeOut("slow")},15e3)})},error:function(){typeof e.onError!="undefined"?eval(e.onError):$("#autosaveErrorNotification").html(i).css("background-color","#F00").fadeIn("slow",function(){setTimeout(function(){$("#autosaveErrorNotification").fadeOut("slow")},15e3)});showErrorModal(f)}})}else showErrorModal(f)},error:function(){}})}function manualSubmit(n){$('form[is="autosave-form"]').each(function(){var jFormElem=$(this),formIndex=$("form").index(jFormElem);if($(this).find("[data-dirty=true]").length||!n){var successMsg=jFormElem.attr("successMsg")||"Your form data has been saved.",errorMsg=jFormElem.attr("errorMsg")||"There was an error saving your form data. Will retry in "+parseFloat(this.submitInterval/1e3)+" seconds.",onPostBack=function(){};typeof jFormElem.attr("onPostBack")!="undefined"&&eval("onPostBack = "+jFormElem.attr("onPostBack"));jFormElem.find(":input[data-dirty=true]").attr("data-dirty",!1);typeof jFormElem[0].isDirty!="undefined"&&(jFormElem[0].isDirty.value=0);autoSave(formIndex,successMsg,errorMsg);onPostBack()}})}function initAutosaveForm(formId){var jFormElem=$("#"+formId);jFormElem[0].autosaveInterval===undefined&&(jFormElem[0].autosaveInterval=null);window.clearInterval(jFormElem[0].autosaveInterval);jFormElem.find("textarea").add("[form="+formId+"]").not(":disabled").each(function(){var n,t;dirty=$(this).attr("data-dirty")==null?!1:$(this).attr("data-dirty");$(this).attr("data-dirty",dirty).on("change keyup paste",function(){$(this).attr("data-dirty",!0)});n=$(this).getKendoEditor();n&&(t=n=>n.sender.element.trigger("change"),n.bind("change",t),n.bind("keyup",t),n.bind("keydown",t),n.bind("paste",t))});var formIndex=$("form").index(jFormElem),formElem=document.forms[formIndex],submitInterval=jFormElem.attr("submitInterval")||3e4,successMsg=jFormElem.attr("successMsg")||"Your form data has been saved.",errorMsg=jFormElem.attr("errorMsg")||"There was an error saving your form data. Will retry in "+parseFloat(submitInterval/1e3)+" seconds.",showTimestamp=0,onPostBack=function(){};typeof jFormElem.attr("onPostBack")!="undefined"&&eval("onPostBack = "+jFormElem.attr("onPostBack"));typeof jFormElem.attr("showTimestamp")!="undefined"&&(showTimestamp=1);jFormElem[0].autosaveInterval=setInterval(function(){var n=jFormElem.find("[data-dirty=true]").add("[form=autosaveForm][data-dirty=true]");n.length>0&&(n.attr("data-dirty",!1),typeof formElem.isDirty!="undefined"&&(formElem.isDirty.value=0),autoSave(formIndex,successMsg,errorMsg,showTimestamp),onPostBack())},submitInterval)}function formatAutosaveDateTime(){var n=new Date;return n.getMonth()+1+"/"+n.getDate()+"/"+n.getFullYear()+" "+formatAMPM(n)}function formatAMPM(n){var t=n.getHours(),i=n.getMinutes(),r=t>=12?"PM":"AM",t=t%12;return t=t?t:12,i=i<10?"0"+i:i,strTime=t+":"+i+r}function clearAutosaveIntervals(){$('form[is="autosave-form"]').each((n,t)=>{t.autosaveInterval&&clearInterval(t.autosaveInterval),t.autosaveInterval=null})}function copyToClipboard(){function t(t){t.clipboardData.setData("text/html",n);t.clipboardData.setData("text/plain",n);t.preventDefault()}var n=$("#formContentContainer").first().html();document.addEventListener("copy",t);document.execCommand("copy");document.removeEventListener("copy",t)}function showErrorModal(n){if(typeof CKEDITOR!="undefined")for(instance in CKEDITOR.instances)CKEDITOR.instances[instance].updateElement();$("[data-role=editor].k-content").each((n,t)=>$(t).getKendoEditor().refresh());var t=$("#modalBSContainer");t.modal().html('<div class="modal-dialog modal-lg"><div class="modal-container"><div class="modal-content"><div class="modal-body"><\/div><\/div><\/div><\/div>');t.data("bs.modal").options={backdrop:"static",keyboard:!1,show:!1};$(".modal .modal-body").css("overflow-y","auto");$(".modal .modal-body").css("max-height",$(window).height()*.75);$(".modal-content").prepend("<div class='modal-header text-center bg-primary'>Copy and Save Your Work<\/div>");$(".modal-body").append('<div class="alert alert-danger modal-heaader"><p>An unexpected error has occurred.  Please use the button below to copy your work and paste into another location (e.g. Word Document) to avoid data loss.<\/p><p>Closing this modal will cause the page to reload.  If the error was due to a loss of connectivity, you will be logged off.<\/p><\/div>').append('<div id="formContentContainer"><\/div>');$(n).find(":input").not("[type=hidden],[type=submit],[type=button],button").each(function(){$("#formContentContainer").append("<strong>"+$(this.form).find("[for="+this.id+"]").text()+"<\/strong><br /> "+$(this).val()+"<br /><br />")});$(".modal-content").append("<div class='modal-footer'><p align='center'><input type='button' class='focus' value='Copy To Clipboard' onclick='copyToClipboard()'/><\/p><input type='button' class='normal pull-right' data-dismiss='modal' value='Close and Reload' onclick='window.location.reload()' /><\/div>")}$(function(){$('form[is="autosave-form"] [type=submit]').on("click",function(){return($submitButton=$(this),$submitButton.data("connectionChecked")==!0)?!0:($.ajax({url:"/Home/PingServer",async:!0,success:function(n){$submitButton.data("connectionChecked",!0);n=="1"?$submitButton.trigger("click"):showErrorModal($submitButton[0].form)},error:function(){}}),!1)});$("body").append("<style> .autosaveNotifications {display:none;color:#FFF;font-weight:bold;text-align:center;position:fixed;top:0;left:0;width:100%;z-index:10000;}<\/style>").append("<div id='autosaveSuccessNotification' class='autosaveNotifications'>Your form data has been saved.<\/div>").append("<div id='autosaveErrorNotification' class='autosaveNotifications'>There was an error saving your form data. Will retry shortly.<\/div>")}),function(n){function t(t){n(t).find("input[type='text']").each(function(){n(this).after("<div id='readOnly-"+n(this).attr("name")+"'>"+n(this).val()+"<\/div>");n(this).hide()})}function i(t){n(t).find("textarea").each(function(){n(this).after("<div id='readOnly-"+n(this).attr("name")+"'>"+n(this).val().replace(/\n/g,"<br />")+"<\/div>");n(this).hide()})}function r(t){n(t).find("select").each(function(){var t=[];n(this).children("option:selected").each(function(){""!=n(this).html()&&t.push(n(this).html())});n(this).after("<div id='readOnly-"+n(this).attr("name")+"'>"+t.join(", ")+"<\/div>");n(this).hide()})}function u(t){n(t).submit=function(){return!1}}n.fn.readOnlyForm=function(){return n(this).find(":submit").hide(),n(this).find(":button").hide(),t(this),i(this),n(this).find("input[type='checkbox']").attr("disabled","disabled"),n(this).find("input[type='radio']").attr("disabled","disabled"),r(this),u(this),n(this)}}(jQuery);$(document).ready(function(){$('[is="readonly-form"]').each(function(){$(this).readOnlyForm()})}),function(n){n.fn.autogrow=function(){return this.filter("textarea").each(function(){var u=this,t=n(u),e=t.height(),f=t.hasClass("autogrow-short")?0:parseInt(t.css("lineHeight"))||0,r=n("<div><\/div>").css({position:"absolute",top:-1e4,left:-1e4,width:t.width(),fontSize:t.css("fontSize"),fontFamily:t.css("fontFamily"),fontWeight:t.css("fontWeight"),lineHeight:t.css("lineHeight"),resize:"none","word-wrap":"break-word"}).appendTo(document.body),i=function(n){var o=function(n,t){for(var i=0,r="";i<t;i++)r+=n;return r},i=u.value.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/&/g,"&amp;").replace(/\n$/,"<br/>&nbsp;").replace(/\n/g,"<br/>").replace(/ {2,}/g,function(n){return o("&nbsp;",n.length-1)+" "});n&&n.data&&n.data.event==="keydown"&&n.keyCode===13&&(i+="<br />");r.css("width",t.width());r.html(i+(f===0?"...":""));t.height(Math.max(r.height()+f,e))};t.change(i).keyup(i).keydown({event:"keydown"},i);n(window).resize(i);i()})}}(jQuery)