/** * Javascript common functions. */ // Retrieve a named element from the document function getElement(name) { var obj = null if (document.getElementById) { obj = document.getElementById(name) } if (document.all && obj == null) { obj = document.all[name] } if (document.layers && obj == null) { obj = document.layers[name] } // Could be an element on a form if (obj == null) { for (frmIdx=0; frmIdx < document.forms.length; frmIdx++) { form = document.forms[frmIdx] for (elIdx = 0; elIdx < form.elements.length; elIdx++) { el = form.elements[elIdx] if (el.id == name || el.name == name) { return el } } } } return obj } // Open a new window function fcWindowOpen(url, name, options) { // Preappend the context if the url is an absolute URL on this server if (url.indexOf('/') == 0) { window.open('/financity' + url, name, options) } else { window.open(url, name, options) } } // Change location of current document (e.g. go to new page) function fcLocationChange(url) { // Preappend the context if the url is an absolute URL on this server if (url.indexOf('/') == 0) { window.location = '/financity' + url } else { window.location = url } } function fcHelpWin(url) { fcWindowOpen(url, 'help', 'width=600,height=600, scrollbars=yes'); } // A class encapsulating the functionality of date editing for flexible dates function FlexibleDate() { // Methods this.showDate = showDate this.dateFocus = dateFocus } function FlexibleDate(type, lifeDate, absoluteDate) { this.type = getElement(type) this.lifeDate = getElement(lifeDate) this.absoluteDate = getElement(absoluteDate) // Methods this.showDate = showDate this.showDate() } function showDate() { if (this.type.value == "ABSOLUTE_DATE") { this.absoluteDate.style.visibility="visible" this.lifeDate.style.visibility="hidden" } else if (this.type.value == "LIFE_DATE") { this.absoluteDate.style.visibility="hidden" this.lifeDate.style.visibility="visible" } else { this.absoluteDate.style.visibility="hidden" this.lifeDate.style.visibility="hidden" } } function deleteConfirmation() { return confirm("Do you really want to delete this entry?") } // Double click disable functions function submitThenLink(link, formName) { document.body.style.cursor = "wait" link.onclick = "return true" var form = document.forms[formName] form.submit() } function submitOnce(button) { document.body.style.cursor = "wait" button.onclick = "return false" return true } function linkOnce(link) { document.body.style.cursor = "wait" link.onclick = "return false"; return true; }