"use strict";Type.registerNamespace("ZeroHarm");ZeroHarm.SavePrompt={hasChangesElement:null,prompt:"Are you sure? You will lose any unsaved changes.",confirmHref:function(b){var a=Function.createDelegate(this,function(){this.set_hasChanges(false);window.setTimeout(function(){window.location.href=b},0)});if(this.get_hasChanges()){if(window.confirm(this.prompt))return a()}else return a()},confirmOnClick:function(b){var a=Function.createDelegate(this,function(){this.set_hasChanges(false);return b()});if(ZeroHarm.SavePrompt.get_hasChanges()){if(window.confirm(this.prompt))return a()}else return a()},confirmOnChange:function(a,c){var b=Function.createDelegate(this,function(){this.set_hasChanges(false);return c()});if(ZeroHarm.SavePrompt.get_hasChanges()){if(window.confirm(this.prompt))return b();else if(a.originalSelectedIndex>=-1){a.selectedIndex=a.originalSelectedIndex;a.originalSelectedIndex=null}}else return b()},handleHref:function(){var d="originalHref",a=this,b=a.href,c=a.getAttribute(d);if(a.SavePrompt===undefined)if(b&&!a.onclick){if(c)b=c;else a.setAttribute(d,b);a.href="javascript:;";a.onclick=Function.createDelegate(ZeroHarm.SavePrompt,function(){this.confirmHref(b)});a.SavePrompt=ZeroHarm.SavePrompt}},handleOnClick:function(){var a=this,b=a.onclick||function(){return true};if(a.SavePrompt===undefined){if(a.type==="submit")throw Error.create(String.format('The form button {0} is of type SUBMIT and cannot be registered with the SavePrompt component. If this is an <asp:Button> control then specify UseSubmitBehavior="false".',a.id));a.onclick=Function.createDelegate(ZeroHarm.SavePrompt,function(){return this.confirmOnClick(b)});a.SavePrompt=ZeroHarm.SavePrompt}},handleOnFocus:function(){var b=this.onchange||function(){return true},a=this;if(a.SavePrompt===undefined){a.onchange=Function.createDelegate(ZeroHarm.SavePrompt,function(){return this.confirmOnChange(a,b)});a.SavePrompt=ZeroHarm.SavePrompt}},handleOnChange:function(){this.originalSelectedIndex=this.selectedIndex},onChange:function(){this.set_hasChanges(true)},get_hasChanges:function(){if(this.hasChangesElement===null)return false;var a=this.hasChangesElement.value;if(a.toLowerCase()==="true")return true;return false},set_hasChanges:function(a){if(this.hasChangesElement===null)return;this.hasChangesElement.value=a},init:function(){var d="select.save-prompt",b=this,a,c;$("a.save-prompt").each(b.handleHref);$("input.save-prompt").each(b.handleOnClick);$(d).each(b.handleOnFocus);$(d).each(b.handleOnChange);for(c=0;c<document.forms[0].elements.length;c++){a=document.forms[0].elements[c];if(a.name==="HasChanges")b.hasChangesElement=a;if(a.SavePrompt===undefined)if(Sys.UI.DomElement.containsCssClass(a,"prompt")||Sys.UI.DomElement.containsCssClass(a.parentNode,"prompt")){if(a.type==="checkbox")$addHandler(a,"click",Function.createDelegate(b,b.onChange));else $addHandler(a,"change",Function.createDelegate(b,b.onChange));a.SavePrompt=b}}}};if(typeof Sys!=="undefined"){Sys.Application.add_load(function(){$(Function.createDelegate(ZeroHarm.SavePrompt,ZeroHarm.SavePrompt.init))});Sys.Application.notifyScriptLoaded()};
