function 	Valida( esteform, estevalor ) {


	if ( !ValidarPalabraBuscador(estevalor) ) {

		estevalor.focus();

	} else {

		if ( esteform.pubId[0].checked ) {

			esteform.action = 'index.php';

			esteform.q.value = estevalor.value

			esteform.submit();

		} else {

			esteform.action = 'http://www.google.com/search';

			esteform.submit();

		}

	}


}



/* VALIDACIÓN BUSCADOR  */

function 	ValidarPalabraBuscador( estevalor ) {

	estevalor.value = estevalor.value.split('?').join(' ');

	estevalor.value = estevalor.value.split(',').join(' ');


	while ( '' + estevalor.value.indexOf('  ') > 0 ) {

		estevalor.value = estevalor.value.split('  ').join(' ');

	}


	while ( '' + estevalor.value.charAt(0) == ' ' ) {

		estevalor.value = estevalor.value.substring(1,estevalor.value.length);

	}
	
	
	while ( '' + estevalor.value.charAt(estevalor.value.length-1) == ' ' ) {

		estevalor.value = estevalor.value.substring(0,estevalor.value.length-1);

	}


	if ( (estevalor.value == "") || (estevalor.value == " ") ||  (estevalor.value == "  ") || (estevalor.value == "   ") ) {

		alert("Debe ingresar una palabra para que inicie la búsqueda.");

		return false;

	}


	//var checkOK = "._-áéíóúÁÉÍÓÚçÇãÃõÕüÜàÀêÊ~`@!#$%^&*()-_=+[]{}''|\/<>,.;:\"";
	var checkOK = "._-~`@!#$%^&*()-_=+[]{}'|\/<>,.;:\"";

	var checkStr = estevalor.value;

	var decPoints = 0;

	var allNum = "";


	for ( i = 0;  i < checkStr.length;  i++ ) {

		ch = checkStr.charAt(i);

		for ( j = 0;  j < checkOK.length;  j++ ) {

			if ( ch == checkOK.charAt(j) ) {

				break;
				
			}
			
		}


		if ( j < checkOK.length ) {

			alert("Ingrese una palabra válida.");

			return false;

		}

		allNum+= ch;

	}


	return true;

}



