function validaBusqueda(id, valor) {
	var campo = document.getElementById(id).value;
	if (campo && (campo.length > 0)) {
		campo = campo.replace(/[+\-&|!(){}\[\]^\"~*?\\: ]/g, "");
	} else {
		campo = "";
	}
	return ((campo.length > 0) && (campo != valor));
}

function resetAvanzada(inputIDs, inputValores, selectIDs) {
	for (var i = 0; i < inputIDs.length; i++) {
		document.getElementById(inputIDs[i]).value = inputValores[i];
	}
	for (var i = 0; i < selectIDs.length; i++) {
		document.getElementById(selectIDs[i]).selectedIndex = 0;
	}
}

function puntear(parametro) {
	var sep=".";
	salida = "";
	if (typeof(parametro) != "undefined") {
		for (i=parametro.length-1; i>=0; i=i-1) {
			salida += parametro.charAt(i);
		}
		salida = salida.replace(/(\d{3})/g, "$1" + ".");
		if (salida.slice(-sep.length) == sep) {
			salida = salida.slice(0, -sep.length);
		}
		x = "";
		for (i=salida.length-1;i>=0;i=i-1) {
			x += salida.charAt(i);
		}
	}
	return (x);
}

function setFocus() {
	document.f.as_q.focus();
}

function esc(x) {
	x = escape(x).replace(/\+/g, "%2b");
	if (x.substring(0,2)=="\%u") x="";
	return x;
}

function collecturl(target, custom) {
	var p = new Array();var i = 0;var url="";var z = document.f;
	if (z.as_q.value.length) {p[i++] = 'as_q=' + esc(z.as_q.value);}
	if (z.as_epq.value.length) {p[i++] = 'as_epq=' + esc(z.as_epq.value);}
	if (z.as_oq.value.length) {p[i++] = 'as_oq=' + esc(z.as_oq.value);}
	if (z.as_eq.value.length) {p[i++] = 'as_eq=' + esc(z.as_eq.value);}
	if (z.as_sitesearch.value.length)
		{p[i++]='as_sitesearch='+esc(z.as_sitesearch.value);}
	if (z.as_lq.value.length) {p[i++] = 'as_lq=' + esc(z.as_lq.value);}
	if (z.as_occt.options[z.as_occt.selectedIndex].value.length)
		{p[i++]='as_occt='+esc(z.as_occt.options[z.as_occt.selectedIndex].value);}
	if (z.as_dt.options[z.as_dt.selectedIndex].value.length)
		{p[i++]='as_dt='+esc(z.as_dt.options[z.as_dt.selectedIndex].value);}
	if (z.lr.options[z.lr.selectedIndex].value != '') {p[i++] = 'lr=' +
		z.lr.options[z.lr.selectedIndex].value;}
	if (z.num.options[z.num.selectedIndex].value != '10')
		{p[i++] = 'num=' + z.num.options[z.num.selectedIndex].value;}
	if (z.sort.options[z.sort.selectedIndex].value != '')
		{p[i++] = 'sort=' + z.sort.options[z.sort.selectedIndex].value;}
	if (typeof(z.client) != 'undefined')
		{p[i++] = 'client=' + esc(z.client.value);}
	if (typeof(z.site) != 'undefined')
		{p[i++] = 'site=' + esc(z.site.value);}
	if (typeof(z.output) != 'undefined')
		{p[i++] = 'output=' + esc(z.output.value);}
	if (typeof(z.proxystylesheet) != 'undefined')
		{p[i++] = 'proxystylesheet=' + esc(z.proxystylesheet.value);}
	if (typeof(z.ie) != 'undefined')
		{p[i++] = 'ie=' + esc(z.ie.value);}
	if (typeof(z.oe) != 'undefined')
		{p[i++] = 'oe=' + esc(z.oe.value);}
	if (typeof(z.access) != 'undefined')
		{p[i++] = 'access=' + esc(z.access.value);}
	if (custom != '')
		{p[i++] = 'proxycustom=' + '&lt;ADVANCED/&gt;';}
	if (p.length > 0) {
		url = p[0];
		for (var j = 1; j < p.length; j++) {
			url += "&amp;" + p[j];
		}
	}
	location.href = target + '?' + url;
}

