// misc utility functions for javascript // all parameters should be strings, use "yes" or "no" for booleans function launchWin(dest, width, height, showToolbar, showMenubar, showStatusbar, showScrollbars, showLocation, isResizable) { popUp = window.open(dest,"popUp", "width=" + width + "," + "height=" + height + "," + "toolbar=" + showToolbar + "," + "menubar=" + showMenubar + "," + "status=" + showStatusbar + "," + "scrollbars=" + showScrollbars + "," + "location=" + showLocation + "," + "resizable=" + isResizable); popUp.focus(); } // launches window positioned in the center of the screen // all parameters should be strings, use "yes" or "no" for booleans function launchWinCS(dest, width, height, showToolbar, showMenubar, showStatusbar, showScrollbars, showLocation, isResizable) { var winL = ((screen.width / 2) - (width / 2)); var winT = ((screen.height / 2) - (height / 2)); popUp = window.open(dest,"popUp", "width=" + width + "," + "height=" + height + "," + "left=" + winL + "," + "top=" + winT + "," + "toolbar=" + showToolbar + "," + "menubar=" + showMenubar + "," + "status=" + showStatusbar + "," + "scrollbars=" + showScrollbars + "," + "location=" + showLocation + "," + "resizable=" + isResizable); popUp.focus(); } // handles alerting the user of too many characters in a field function doLimitLength(field, maxLen, fieldName) { if (field.value.length > maxLen) { alert('You have exceded ' + maxLen + ' characters for the ' + fieldName + ' field. Please delete at least ' + (field.value.length - maxLen) + ' character(s).'); field.focus(); } } // used for date selection forms function setDays(mf, df, yf, topBlank) { var m; var y; var idxCheck = (topBlank) ? 1 : 0; if (mf.selectedIndex < idxCheck) { m = 1; } else { m = mf.options[mf.selectedIndex].value; } if (yf.selectedIndex < idxCheck) { y = 2002; } else { y = yf.options[yf.selectedIndex].value; } var nd = 31 + idxCheck; if (m == 4 || m == 6 || m == 9 || m == 11) { nd -= 1; } else if (m == 2) { if ((y % 400 == 0) || ((y % 4 == 0) && (y % 100 != 0))) nd -= 2; else nd -= 3; } var prevDaySel = df.selectedIndex; while (df.options.length < nd) { var nextDay; if (topBlank) nextDay = df.options.length; else nextDay = df.options.length + 1; df.options[df.options.length] = new Option(nextDay, nextDay); } if (df.options.length > nd) df.options.length = nd; if (prevDaySel >= df.options.length) df.selectedIndex = df.options.length - 1; }