//************************************************** // TLUtils.js // Author: Tong Lim // Version: 1.2 // Date: 1/8/2006 // Update: 3/30/2006 //*************************************************** function TLUtils() { var wc3 = (!document.all && document.getElementById); var ie4 = (document.all); var ns4 = (document.layers); this.debug = function () { if (wc3) alert("WC3: " + wc3); if (ie4) alert("IE: " + ie4); if (ns4) alert("NS4: " + ns4); } var v_imgSwap=0; //-------------------------------------------- // Desc: swap image // param: p1 = object // param: p2 = image one // param: p3 = image two // return: nothing this.imgSwap = function (p1, p2, p3) { if (v_imgSwap == p3 || v_imgSwap == 0) { p1.src = p2; v_imgSwap = p2; return 1; } else { p1.src = p3; v_imgSwap = p3; return 2; } } //-------------------------------------------- // Desc: hide layer // param: v_array = array of string name // return: nothing this.doHideLayers = function (v_array) { for (i=0; i= 48 && key <= 57) || (key == 8) || (key == 13) || (key == 9) || (key == 0)) { if ((key >= 48 && key <= 57) && (e.shiftKey == true)) { return false; } else { return true; } } else { return false; } } //-------------------------------------------- // Desc: Function to test if the key pressed is character. // param: e = Pass in an event. // return: true or false // Example how to call it: onkeypress="return(TLUtils.isChar(event))" this.isChar = function (e) { var key = (window.event) ? event.keyCode : e.which; // Was key that was pressed a numeric character (a-z, A-Z) or backspace (8) or return (13) or tab(9)? if ( (key >= 65 && key <= 90) || (key == 8) || (key == 13) || (key == 9) || (key == 0) || (key >= 97 && key <= 122)) return true; else return false; } //-------------------------------------------- // Desc: Function that allow only numeric character to be enter. // param: e = Pass in an event. // return: nothing // Example how to call it: onkeypress="TLUtils.numericOnly(event)" this.numericOnly = function (e) { if (! this.isNumeric(e)) { if (window.event) // IE window.event.returnValue = null; else // Firefox e.preventDefault(); } } //-------------------------------------------- // Desc: Function that allow only character to be enter. // param: e = Pass in an event. // return: nothing // Example how to call it: onkeypress="TLUtils.charOnly(event)" this.charOnly = function (e) { if (! this.isChar(e)) { if (window.event) // IE window.event.returnValue = null; else // Firefox e.preventDefault(); } } } var TLUtils = new TLUtils();