function validar(coma, opcion){
	if (opcion==1) var f=document.forms[0].busqueda;
	else var f=document.forms[1].busqueda;

	var otrasOp = new Array("Á","É","Í","Ó","Ú","Ñ");
	var texto = "";
	var caracter = 0;

	var valor = trim(f.value);

	if (valor == "") {
		alert("Debe ingresar un texto a buscar");
		f.value="";
		f.focus();
		return false;			
	}
	texto = ""
	for (i=0; i<valor.length; i++) {
		txt = valor.charAt(i)
		if (txt >= "0" && txt <= "9") {
			texto = texto + txt
			//caracter = 1;
		}else if (txt.toUpperCase() >= "A" && txt.toUpperCase() <= "Z") {
			texto = texto + txt
			//caracter = 1;
		}else if (txt == " " || txt == coma) {
			texto = texto + txt
			//caracter = 1;
		}else {
			for (j=0 ; j<6 ; j++) {
				if (txt.toUpperCase() == otrasOp[j]) {
					texto = texto + txt
					//caracter = 1;
				}
			}
		}
	}
		
	if (texto.length!=valor.length) {
		alert("Caracter ingresado no válido");
		f.value="";
		f.focus();
		return false;
	}

	return true;
}

function trim(valor) {

	var temp = "";
	var text = "";

	i = 0;
	while (i < valor.length && valor.charAt(i) == " "){
		i++;
	}
	for (j = i; j < valor.length; j++){
		temp = temp + valor.charAt(j)
	}
	i = temp.length - 1;
	while (i > 0 && temp.charAt(i) == " "){
		i--;
	}
	for (j = 0; j<=i; j++){
		text = text + temp.charAt(j)
	}
	return text;
}
