var time_delta = 1000;
var timerACGoToLey = setTimeout("acGoToLey()", time_delta);
var last_t = '';
var min_chars = 3;

// Funcion de autocomplete de go to ley
function acGoToLey() {
	var t = $('goto_txt').value;

	if(t == '') {
		$('ac_cont').innerHTML = '';
		$('ac_cont').style.display = 'none';
	} else if(t != last_t && t.length >= min_chars) {
		// Hacemos busqueda de autocomplete
		new ajax('/modules.php?name=Legislacion&op=acGoToLey&t='+t, {onComplete:doAcGoToLey});
		
		last_t = t;
	}
	
	timerACGoToLey = setTimeout("acGoToLey()", time_delta);
}

// Callback de acGoToLey
function doAcGoToLey(r) {
	r = r.responseText;

	var pos = findPos($('goto_txt'));
	pos[0] += 0;
	pos[1] += 10;
	$('ac_cont').style.left = pos[0] + 'px';
	$('ac_cont').style.top = pos[1] + 'px';

	if(r != '') {
		$('ac_cont').innerHTML = r;
		$('ac_cont').style.display = 'block';
	} else {
		$('ac_cont').style.display = 'none';
	}
}

// Proxy para buscar rapido
function goToSearch() {
	var ps = $('goto_txt').value;

	if(ps != '') {
		window.parent.location.href = '/modules.php?name=Legislacion&op=nSearch&presearch='+ps;
	} else {
		alert('Por favor introduce un t\xE9rmino de b\xFAsqueda.');
	}
}

