$(document).ready(f_init);

var nLast = -1;
var aHidden = [];
var aShowed = [];

function f_init() {
	var nl = null;
	nl = $("p.sel");
	nl.each(function(iter, elm) {
		elm.num = aHidden.length;
		aHidden[iter] = elm;
	});
	nl = $(".preg input");
	nl.each(function(iter, elm) {
		elm.num = aShowed.length;
		aShowed[iter] = elm;
	});
	jQuery.each(aShowed, function(iter, elm) {
		elm.onfocus = function() {
			if(nLast>-1) {
				aHidden[nLast].style.display = "none";
			}
			var y = this.offsetTop + this.offsetHeight - 1;
			var x = this.offsetLeft;
			aHidden[elm.num].style.display = "block";
			aHidden[elm.num].style.top  = y+"px";
			aHidden[elm.num].style.left = x+"px";
//			this.style.width = (aHidden[elm.num].offsetWidth-10)+"px";
			nLast = elm.num;
		};
		elm.onblur = function() {
			//aHidden[elm.num].style.display = "none";
		}
	});
}

function f_put(anc, n, v) {
	aShowed[n].value = v;
	aHidden[n].style.display = "none";
	return false;
}

function f_correct() {
	document.forms["ejer"].submit();
	return false;
}