function setHandlers (l, f) {
	// These nested functions become closures which will continue to refer
	// to the current values of the l and f vars in this scope.
	l.onclick = function () { f.focus() };
	f.onkeyup = function () { l.style.visibility = this.value.length == 0 ? "visible" : "hidden" };
	f.onchange = function () { l.style.visibility = this.value.length == 0 ? "visible" : "hidden" };
	f.onblur = function () { if ( this.value.length == 0 ) l.style.visibility = "visible" };
	// Give the browser 1/5 second to autofill fields
	setTimeout( function () { if ( f.value.length == 0 ) l.style.visibility = "visible" }, 200 )
}

$( function () {
	var ls = document.getElementsByTagName("label");
	for ( var ln = 0; ln < ls.length; ln++ ) {
		var l = ls[ln];
		if ( l.className == 'in_field' ) {
			var f = document.getElementById(l.getAttribute("for") || l.getAttribute("htmlFor"));
			if ( ! f ) 
				alert( "No f for " + l.getAttribute("for") )
			else 
				setHandlers( l, f );			
		}
	}
} );