var settingsChanged = false; function initSettingsForm(id) { $('#' + id + ' input, #' + id + ' textarea, #' + id + ' select').each(function(i) { var type = $(this).attr('type'); if ('hidden' != type && 'submit' != type && 'button' != type) { $(this).bind('change', function() { settingsChanged = true; }); } }); $('#' + id + ' #btnSubmit').bind('click', function(e) { settingsChanged = false; }); var clickEvents = document.getElementById('btnCancel').onclick; document.getElementById('btnCancel').onclick = null; $('#' + id + ' #btnCancel').bind('click', function(e) { settingsChanged = false; }); $('#' + id + ' #btnCancel').bind('click', clickEvents); window.onbeforeunload = function() { if (settingsChanged) { return "You've made the changes to the form.\nClicking Okay button will cancel changes you've made."; } }; } function FCKeditor_OnComplete(fckEditor) { fckEditor.Events.AttachEvent('OnSelectionChange', FCKeditor_OnChange); } function FCKeditor_OnChange(fckEditor) { if (fckEditor.IsDirty()) { settingsChanged = true; } }