function popup(url, name, width, height, scroll) { if (!scroll) { scroll = "yes"; } var startX = screen.availWidth/2 - width/2; var startY = screen.availHeight/2 - height/2; stats="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + scroll +", resizable=yes," + "width=" + width + ",height=" + height + ", screenX=" + startX + " , left=" + startX + ", screenY=" + startY + " top=" + startY; win = window.open (url, name, stats); win.focus(); return win; } function popupNoMenu(url, name, width, height, scroll) { if (!scroll) { scroll = "yes"; } var startX = screen.availWidth/2 - width/2; var startY = screen.availHeight/2 - height/2; stats="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=" + scroll +", resizable=yes," + "width=" + width + ",height=" + height + ", screenX=" + startX + " , left=" + startX + ", screenY=" + startY + " top=" + startY; win = window.open (url, name, stats); win.focus(); return win; } function editName(nameId, companyId, dimValueIdLanguage) { var url = "/ADTravel/text/NameEditor.jsp?nameId=" + nameId; if (companyId) { url += "&companyId=" + companyId; } if (dimValueIdLanguage) { url += "&dimValueIdLanguage=" + dimValueIdLanguage; } popup(url, "nameEditor", 570, 370); } function getNewSubmitForm(){ var submitForm = document.createElement("FORM"); document.body.appendChild(submitForm); submitForm.method = "POST"; return submitForm; } //function that creates the form, adds some elements //and then submits it function createFormAndSubmit(url, title){ var submitForm = getNewSubmitForm(); submitForm.action= url; submitForm.submit(); } function popupReport(url, title) { var name = title; var width = 900; var height = 400; var startX = screen.availWidth/2 - width/2; var startY = screen.availHeight/2 - height/2; stats="toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=yes," + "width=" + width + ",height=" + height + ", screenX=" + startX + " , left=" + startX + ", screenY=" + startY + " top=" + startY; var win = window.open (url, name, stats); } function setSelectedValue(selectBox, value) { for (var i = 0; i < selectBox.length; i++) { if (selectBox[i].value == value) { selectBox.selectedIndex = i; break; } } } function closeAndFocus() { top.opener.focus(); self.close(); } function closeAndReload(messageKey) { top.close(); top.opener.reload(messageKey); } function reload(messageKey) { var f = document.forms["reloadForm"]; if (f) { if (messageKey && f.messageKey) { f.messageKey.value = messageKey; } f.submit(); } else { window.location.reload(); } window.focus(); } function reloadNoFocus() { var f = document.forms["reloadForm"]; if (f) { f.submit(); } else { window.location.reload(); } } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } function setValueFromDummy(check) { var name = check.name.substring(0, check.name.indexOf('_')); var box = getElement(check.form, name); if (box) { if (check.checked) { box.value = 1; } else { box.value = 0; } } } function getElement(f, name) { for (var i = 0; i < f.elements.length; i++) { if (f.elements[i].name == name) { return f.elements[i]; } } return null; } function batchNotValidForApproval(language, secretary) { var pre = secretary? "/ADTravel/" : "/ADTravel/"; popup(pre + "batches/BatchNotValidForApproval.jsp", 'noValid', 400, 250); } function infoInvalidExpense() { popup("/ADTravel/expenses/InvalidExpense.jsp", 'noValid', 400, 250); } function infoInvalidDrive() { popup("/ADTravel/drives/InvalidDrive.jsp", 'noValid', 400, 250); } function batchIsOverdue(language, companyName, expirationMonths, secretary) { var pre = secretary? "/ADTravel/" : "/ADTravel/"; popup(pre + "batches/BatchNotValidForApprovalOverdue.jsp?companyName="+companyName+"&expirationMonths="+expirationMonths, 'noValid', 550, 250); } function batchNotValidForApprovalSums(language, secretary) { var pre = secretary? "/ADTravel/" : "/ADTravel/"; popup(pre + "batches/approver/BatchNotValidForApprovalSums.jsp", 'noValid', 400, 200); } function hasSelectedCheckbox(f) { if (f && f.elements && f.elements.length > 0) { for (var i = 0; i < f.elements.length; i++) { if (f.elements[i].type == "checkbox" && f.elements[i].checked) { return true; } } } return false; }