// javascript for all detail pages

// calendar object
var calSelect = new CalendarPopup(); 

// modified flag
var blnModified = false;

function setModified() {
	blnModified = true;
}

function returnList(page) {
	if (checkModified()) {
		document.thisForm.action = page;
		document.thisForm.submit();
	}
}

function returnListUser(page) {
		location = page;
}

function returnListState(page, formRecord) {
	if (checkModified()) {
		formRecord.action = page;
		formRecord.submit();
	}
}

function checkModified() {
	if (blnModified) {
		if (confirm("This page has been modified. Do you want to save your changes first?")) {
			return savePage(self.location);
		} 
	}
	return true;
}
function checkPage(URL) {
	if (checkModified()) {
		self.location = URL;
	} else {
		return false;
	}
	return true;
}

function savePage(page) {
	blnModified = false;
	if (validateThisForm()) {	// must be included on the calling page
		document.thisForm.blnSave.value = "true";
		document.thisForm.action = page;
		document.thisForm.submit();
	} else {
		return false;
	}
	return true;
}

function deletePage(page) {
	if (confirm("Are you sure you want to delete this item?")) {
		document.thisForm.blnSave.value = "delete";
		document.thisForm.action = page;
		document.thisForm.submit();
	} else {
		return false;
	}
	return true;
}

function closePage(page) {
	if (confirm("Are you sure you want to close this item?")) {
		document.thisForm.blnSave.value = "close";
		document.thisForm.action = page;
		document.thisForm.submit();
	} else {
		return false;
	}
	return true;
}

