function initInputs() { var _inputs = document.getElementsByTagName('input'); if (_inputs) { for(var i=0; i<_inputs.length; i++) { if (_inputs[i].type == 'text' || _inputs[i].type == 'password') { _inputs[i].alt = _inputs[i].value; (function(i){ var _hasFocus = false; _inputs[i].onmouseover = function(){ if(this.className.indexOf('hover')<0) this.className += ' hover'; } _inputs[i].onmouseout = function(){ if(!_hasFocus) this.className = this.className.replace('hover',''); } _inputs[i].onfocus = function(){ if(this.className.indexOf('hover')<0) this.className += ' hover'; _hasFocus = true; } _inputs[i].onblur = function(){ this.className = this.className.replace('hover',''); _hasFocus = false; } })(i); } } } } if (window.addEventListener) window.addEventListener("load", initInputs, false); else if (window.attachEvent) window.attachEvent("onload", initInputs);