function CheckDirty() {
	if (__form_is_dirty == true && !confirm("There are unsaved changes. Click OK to navigate away from task without saving. Click Cancel to return to task."))
		return false;
	else
		return true;
}

var __form_is_dirty = false;

function SetDirtyForm() {
	__form_is_dirty = true;
}

function SetupLinkHooks() {
	if (__old_window_onload != null)
		__old_window_onload();
	for (i = 0; i < document.links.length; i++) {
		var link = document.links[i];
		if (link.noconfirm != "1" && (link.target == "_self" || link.target == "" || link.target == window.name)) {
			if (link.onclick != null) {
				var f = function(x) {	if (!CheckDirty())
											return false;
										if (arguments.callee.next != null)
											return arguments.callee.next(x);
									}
				f.next = link.onclick;
				link.onclick = f;		
			}
			else
				link.onclick = CheckDirty;
		}
	}
}

var __old_window_onload = window.onload;

window.onload = SetupLinkHooks;

