String.prototype.trim = function() { return( this.replace(/(^\s+)|(\s+$)/g, "") ); } String.prototype.is_email = function() { return( /.*@.*\..+/.test(this) ); } Array.prototype.in_array = function(val) { var i, len = this.length; for (i = 0; i < len; i++) if ( this[i] == val ) return( true ); return( false ); } function get_event(e) { var obj = e; if ( window.event ) { obj.layerX = e.offsetX; obj.layerY = e.offsetY; obj.target = e.srcElement; obj.preventDefault = function() { event.returnValue = false; } obj.stopPropagation = function() { event.cancelBubble = true; } } return( obj ); } function get_node_info(node) { var xPos = 0, yPos = 0, width = 0, height = 0, srcNode = node; while ( node.nodeType == 1 ) { if (node.tagName != "TR") { xPos += node.offsetLeft; yPos += node.offsetTop; } if ( node.offsetParent ) node = node.offsetParent; else break; } if (typeof srcNode.offsetWidth != "undefined") { width = srcNode.offsetWidth; height = srcNode.offsetHeight; } else if (typeof srcNode.width != "undefined") { width = srcNode.width; height = srcNode.height; } return( { x : xPos , y : yPos , w : width , h : height } ); } function check_username(str) { var err = []; var min_chars = 5; var max_chars = 20; if ( str.trim() == "" ) return( true ); var strlen = str.length; if ( strlen > 0 && strlen < min_chars ) err.push("Your username must have at least "+ min_chars +" characters. Your username currently uses "+ strlen); else if ( strlen > max_chars ) err.push("Your usrename cannot have more than "+ max_chars +" characters. Your username currently users "+ strlen); if ( err.length > 0 ) { alert( "Your username does not meet the following criteria:\n\n\t"+ err.join("\n\t") ); return( false ); } else return( true ); } function check_password(str) { if ( str.trim() == "" ) return( true ); var err = []; var min_chars = 7; var max_chars = 20; if ( !(/[0-9]/.test(str)) ) err.push("Password does not contain at least one numeric character."); if ( !(/[A-Z]/i.test(str)) ) err.push("Password does not contain at least one alphabetic character."); if ( str.length < min_chars ) err.push("Password is too short; the minimum password length is "+ min_chars +" characters."); else if ( str.length > max_chars ) err.push("Password is too long; the maximum password length is "+ max_chars +" characters."); if ( err.length > 0 ) { alert( "Your password does not meet the following criteria:\n\n\t"+ err.join("\n\t") ); return( false ); } else return( true ); }