
/// detect if anything on the form has changed from its default value
function form_is_modified(oForm) {
	var el, opt, hasDefault, i = 0, j;
	while (el = oForm.elements[i++]) {
		switch (el.type) {
			case 'text' :
					case 'textarea' :
					case 'hidden' :
							if (!/^\s*$/.test(el.value) && el.value != el.defaultValue) return true;
							break;
					case 'checkbox' :
					case 'radio' :
							if (el.checked != el.defaultChecked) return true;
							break;
					case 'select-one' :
					case 'select-multiple' :
							j = 0, hasDefault = false;
							while (opt = el.options[j++])
									if (opt.defaultSelected) hasDefault = true;
							j = hasDefault ? 0 : 1;
							while (opt = el.options[j++]) 
									if (opt.selected != opt.defaultSelected) return true;
							break;
		}
	}
	return false;
}

//window.__onunload = window.onunload;

//window.onunload = function() {
//	if (form_is_modified(document.forms[0])) {
//		if (confirm('Save changes?')) {
//			document.forms[0].submit();
//		}
//	}

//	if (typeof window.__onunload == 'function') {
//		window.__onunload();
//	}
//}