function ltrim ( s )  { 
   return s.replace( /^\s*/, "" ) 
} 

function rtrim ( s )  { 
   return s.replace( /\s*$/, "" ); 
} 

function trim ( s ) { 
   return rtrim(ltrim(s)); 
} 

function testaVazio(elemento, texto) {
  str = trim(elemento.value);
  if ((str=="") || (str.length==0) || (str=="Null")) {
	alert("Informe "+ texto + ".");
	elemento.focus();
	return false;
  }
  return true;
}

function testaRadio(elemento,texto){
	var flag = ""
	if (elemento.length > 1) {
		for (i=0; i<elemento.length; i++) {
			if (elemento[i].checked) flag = true;
		}
	}

	if (flag != true) {
		alert("O campo "+texto+" não foi preenchido.");
		return false;
	}
	else return true;
}


function testaCheck(elemento, texto){
	var flag = ""
	if (elemento.length > 1) {
		for (i=0; i<elemento.length; i++) {
			if (elemento[i].checked) flag = true;
		}
	}

	if (flag != true) {
//		alert("Não foi selecionada nenhuma dica para impressão.");
		alert("O campo "+texto+" não foi preenchido.");
		return false;
	}
	else return true;
}

function testaVazioCombo(elemento,texto){
  str = elemento.options[elemento.selectedIndex].value;
  if ((str=="") || (str.length==0) || (str=="Null")) {
	alert("Informe "+ texto + ".");
	elemento.focus();
	return false;
  }
  return true;
}