
var x=function($){$.extend($,{protectData:{forms:[],unsavedChanges:false,protectAjax:false,ajaxUnportectNTimes:0,stateChangeCallback:function(isProtected){},initialize:function(){if(this.running)return;this.running=true;var self=this;if($.fn.ajaxSubmit){var oldAjaxSubmit=$.fn.ajaxSubmit;$.fn.ajaxSubmit=function(e){self.unprotect();oldAjaxSubmit.call($.fn,e);}}
$().ajaxSend(function(e,r,s){self.ajaxCallback.call(self,e,r,s)});},reset:function(){this.ajaxUnportectNTimes=0;this.unsavedChanges=false;this.ajaxProtect=false;this.stateChangeCallback=function(isProtected){};window.onbeforeunload=null;for(var key in this.forms){if($.browser.msie){$(':input',this.forms[key].form).unbind('.protectData');}
this.forms[key].form.unbind('.protectData');}
this.forms=[];},forms:[],message:"You did not submit your changes. Do you want to continue?\n",wexMsg:"Are you sure you want to navigate away from this page?\n\nYou did not submit your changes. Do you want to continue?\n\n\nPress OK to continue, or Cancel to stay on the current page.\n",protect:function(){if(this.unsavedChanges)return;this.stateChangeCallback(true);this.unsavedChanges=true;window.onbeforeunload=function(){return $.protectData.message;}},unprotect:function(){if(!this.unsavedChanges)return;this.stateChangeCallback(false);this.unsavedChanges=false;window.onbeforeunload=null;},unprotectAjax:function(times){if(times===0||times==='0')return;if(times===undefined)times=1;times=parseInt(times,10);this.ajaxUnportectNTimes+=times;},ajaxCallback:function(event,request,settings){if(!this.protectAjax)return;if(!this.unsavedChanges)return;if(this.ajaxUnportectNTimes){this.ajaxUnportectNTimes--;return;}
if(confirm(this.message))this.unprotect();else request.abort();},ProtectedForm:function(form){this.form=$(form);$.protectData.forms.push(this);if($.browser.msie){$(':input',form).bind('change.protectData',function(){$.protectData.protect();});}else{this.form.bind('change.protectData',function(){$.protectData.protect();});}
this.form.bind('submit.protectData',function(){$.protectData.unprotect();});}}});$.extend($.fn,{protectData:function(options){options=options||{};$.extend($.protectData,options);$.protectData.initialize();$(this).each(function(){if($(this).is('form')){new $.protectData.ProtectedForm(this);}});}});}(jQuery);