
function checkChars(o) {
	if(o.value.length==1) {
		if(o.value.charAt(0) == " ") o.value="";
	}
	if(o.value.length>1) { 
		for(var i=0; i<=o.value.length; i++) {				
			if(o.value.charAt(i)==" " && o.value.charAt(i-1)==" ") {
					o.value = o.value.substring(0, o.value.length-1); 
			}
		}
	}	
}
function has2Chars(o) {
	if(o.value.length < 2){
		alert('Por favor, escriba alguna palabra-clave');
		o.focus();
		return false;
	}
	else return true;
}

function DoSearch(formname) {
	d = eval(formname);
	var x= d.text.value;
	x = x.replace(/^\s*(.*)/, "$1");
	x = x.replace(/(.*?)\s*$/, "$1");
}
//##########################   Validação das Buscas       ########################
//Função padrão de validação de busca.
function validaBusca(idbox){
	var box=document.getElementById(idbox);
	box.value = trim(box.value);
	if(box.value==''){
		alert('Por favor, introduzca un producto o servicio para realizar la búsqueda.');
		return false;
	}else
		return true;
}
//Expressão regular para retirar e validar os espaços em branco.
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
//################################################################################