// // NOTE! Only put truly reusuable functions in here. // Wait until you have at least two or three different pages using your function before putting it here. // Use on your page until you reach that threshold. // // Used for hiding and showing a span or div value, (block or inline) function setDisplayStyle(objID, displayValue) { // displayValue param should be: none, block, or inline //alert("setDisplayStyle " + document.getElementById(objID)); var style = document.getElementById(objID).style; style.display = displayValue; } // Hides the block with the given ID // Deprecated in favor of the more flexible setDisplayStyle function function hideBlock(strObjID) { alert("hiding block " + stringObjId); var style = document.getElementById(strObjID).style; style.display = "none"; return true; } // Shows the block with the given ID // Deprecated in favor of the more flexible setDisplayStyle function function showBlock(strObjID) { alert("showing block " + stringObjId); var style = document.getElementById(strObjID).style; style.display = "block"; return true; } // // // hides the specified (strObjID + "_subnav") id // Deprecated in favor of the more flexible setDisplayStyle function function hide_subnav(strObjID) { var style = document.getElementById(strObjID + "_subnav").style; style.display = "none"; } // shows the specified (strObjID + "_subnav") id // Deprecated in favor of the more flexible setDisplayStyle function function show_subnav(strObjID) { var style = document.getElementById(strObjID + "_subnav").style; style.display = "block"; } // Returns the href from the related element. // Elements are related as follows: // If o.id = "xa_yyyy" // the related element must have an id = "a_yyyy". // In short, the first character is dropped to find the id of the related item function ga(o,e) { if (document.getElementById) { a=o.id.substring(1); p = ""; r = ""; g = e.target; if (g) { t = g.id; f = g.parentNode; if (f) { p = f.id; h = f.parentNode; if (h) r = h.id; } } else { h = e.srcElement; f = h.parentNode; if (f) p = f.id; t = h.id; } if (t==a || p==a || r==a) return true; location.href=document.getElementById(a).href } } // navigationKeyCodes: // 8=backspace, 37=left-arrow, 46=delete, 9=tab, 39=right-arrow, 13=enter, 16=shift, 116=F5 var navigationKeyCodes = "|8|37|46|9|39|13|16|116|"; // Allows only numbers and certain nav keys into the entry field. // Use: // Or jQuery: $('input#pageNum').keydown(numbersOnly) function numbersOnly(e) { var keyCode = (e.charCode || e.keyCode || 0); // Safari fix if (navigationKeyCodes.indexOf("|" + keyCode + "|") >= 0) return true; if (keyCode >= 96 && keyCode <= 105) return true; // numeric keypad values. return /\d/.test(String.fromCharCode(keyCode)); } function getKeyCode(e) { // alternative implementation return (e.charCode || e.keyCode || 0); // This is here for historical purposes in case the above doesn't always work. // var keyCode = 0; // if (window.event) { // keyCode = e.keyCode; // IE and Safari // } else if (e.which) { // keyCode = e.which; // Netscape/Firefox/Opera // } // return keyCode; } // Submits the form when "enter" is pressed. // Use: // For a numeric field use: function submitEnter(myField, e) { var keyCode = e.charCode || e.keyCode || 0; var returnValue = false; if (keyCode == 13/*enter*/) { myField.form.submit(); } else { returnValue = true; } return returnValue; }