// JavaScript Document
function isNumeric(sText) {
   var validChars = "0123456789.";
   var isNumber=true;
   var Char;
//   for (i = 0; i < sText.length && IsNumber == true; i++) 
   for (i=0; i<sText.length; i++)
      { 
      Char = sText.charAt(i); 
      if (validChars.indexOf(Char) == -1) 
         {
         isNumber = false;
         }
      }
   return isNumber;
}
//---------------------------------------------------------------------------------------
function checkOrcamentoForm(theForm) {
	var nome 			= theForm.nome.value;
	var telefone 	= theForm.telefone.value;
	var email 		= theForm.email.value;
	var orcamento	= theForm.orcamento.value;
	
	var msg = "";
	var objectToFocus;
	
	var retValue = true;
	if(nome=="") {
			msg = msg + ". falta o nome\n";
			objectToFocus = theForm.nome;
			retValue = false;
	}
	if(!isNumeric(telefone) || telefone=="") {
			msg = msg + ". falta nº de telefone / ou nº inválido \n";
			objectToFocus = theForm.telefone;
			retValue = false;
	}
	if(email=="") {
			msg = msg + ". falta o e-mail\n";
			objectToFocus = theForm.email;
			retValue = false;
	}
	if(orcamento=="") {
			msg = msg + ". faltam os dados do orçamento \n";
			objectToFocus = theForm.orcamento;
			retValue = false;
	}
	if(!retValue) {
		alert(msg);
		objectToFocus.focus();
	}
	return retValue;
}
//---------------------------------------------------------------------------------------
function checkAssistenciaForm(theForm) {
	var nome 			= theForm.nome.value;
	var telefone 	= theForm.telefone.value;
	var email 		= theForm.email.value;
	var descricao	= theForm.descricao.value;
	
	var msg = "";
	var objectToFocus;
	
	var retValue = true;
	if(nome=="") {
			msg = msg + ". falta o nome\n";
			objectToFocus = theForm.nome;
			retValue = false;
	}
	if(!isNumeric(telefone) || telefone=="") {
			msg = msg + ". falta nº de telefone / ou nº inválido \n";
			objectToFocus = theForm.telefone;
			retValue = false;
	}
	if(email=="") {
			msg = msg + ". falta o e-mail\n";
			objectToFocus = theForm.email;
			retValue = false;
	}
	if(descricao=="") {
			msg = msg + ". faltam os dados do avaria \n";
			objectToFocus = theForm.descricao;
			retValue = false;
	}
	if(!retValue) {
		alert(msg);
		objectToFocus.focus();
	}
	return retValue;
}
