<!--

	function validaFormSeguros()
	{	
			var msg_erro_form_nome = "Por favor informe seu nome ccorretamente.";
			var msg_erro_form_nome_invalido = "O campo nome deve conter apenas letras.";			
			var	msg_erro_form_nome_condutor_invalido = "O campo nome do condutor deve conter apenas letras.";			  			
			var	msg_erro_form_nome_demais_condutores_invalido = "O campo nome dos demais condutores deve conter apenas letras.";			  					

			var msg_erro_tel_comercial_invalido = "Por favor informe o telefone comercial corretamente. Exemplo:(21) 2222-3333.";
			var msg_erro_tel_residencial_invalido = "Por favor informe o telefone residencial corretamente. Exemplo:(21) 2222-3333.";
			var msg_erro_tel_celular_invalido = "Por favor informe o telefone celular corretamente. Exemplo:(21) 2222-3333.";			
			var msg_erro_form_nascimento = "Por favor informe corretamente a sua data de nascimento. Exemplo: 01/12/2001.";
			var msg_erro_form_habilitacao = "Por favor informe corretamente a data de sua primeira Habilitação. ex: 01/12/2001.";
			var msg_erro_form_email = "Por favor preencha corretamente seu e-mail.";
			var msg_erro_form_fabricante = "Por favor informe corretamente o fabricante do veículo.";
			var msg_erro_form_modelo = "Por favor informe corretamente o modelo do veículo.";
			var msg_erro_form_anofabricacao =  "Por favor informe corretamente o ano de fabricação do veículo.";
			var msg_erro_form_anomodelo = "Por favor informe corretamente o ano do modelo do veículo.";
			var msg_erro_form_cep = "Por favor informe corretamente o CEP. Exemplo: 11222-333";

			if (document.form_seguros._01Nome.value.length < 2 )
			{	document.form_seguros._01Nome.focus();
				alert (msg_erro_form_nome);
				return false;		
			}			
			
			if ( check_HasNumeric(document.form_seguros._01Nome.value) )
			{  document.form_seguros._01Nome.focus();
				alert (msg_erro_form_nome_invalido);
				return false;							
			}// end if 
			
			
			if ( document.form_seguros._05DataNascimento.value.length < 10 || !check_date(document.form_seguros._05DataNascimento)  )	
			{
				document.form_seguros._05DataNascimento.focus();
				document.form_seguros._05DataNascimento.select();
				alert (msg_erro_form_nascimento);
				return false;			
			}// end if 
			
			if ( (document.form_seguros._06DataHabilitacao.value.length < 10) || !check_date(document.form_seguros._06DataHabilitacao )  )	
			{
				document.form_seguros._06DataHabilitacao.focus();
				document.form_seguros._06DataHabilitacao.select();
				alert (msg_erro_form_habilitacao);
				return false;			
			}// end if 			

			
			
			if ( ( document.form_seguros._07TelComercial.value.length > 0 ) && (!check_IsNumeric2(document.form_seguros._07TelComercial.value)) )
     		 {
					 document.form_seguros._07TelComercial.focus();
					alert (msg_erro_tel_comercial_invalido);
					return false;							
				// end if 
			}
			
			if ( (document.form_seguros._08TelResidencial.value.length > 0 )&& (!check_IsNumeric2(document.form_seguros._08TelResidencial.value) )) 
			{
					document.form_seguros._08TelResidencial.focus();
					alert (msg_erro_tel_residencial_invalido);
					return false;							

			}// end if 
			
			if ( (document.form_seguros._09Celular.value.length > 0 )&& (!check_IsNumeric2(document.form_seguros._09Celular.value) ))
			{
					  document.form_seguros._09Celular.focus();
					  alert (msg_erro_tel_celular_invalido);
					  return false;							

			}// end if 			
			
			
			if (document.form_seguros._10eMail.value.length < 4 || !checkEmail(document.form_seguros._10eMail.value) )
			{	document.form_seguros._10eMail.focus();
				document.form_seguros._10eMail.select();
				alert (msg_erro_form_email);
				return false;		
			}// end if
			
			if (!check_CEP(document.form_seguros._14Cep) )
			{	document.form_seguros._14Cep.focus();
				document.form_seguros._14Cep.select();
				alert(msg_erro_form_cep);
				return false;		
			}// end if										

			
			if (document.form_seguros._15Fabricante.value.length < 2  )
			{	document.form_seguros._15Fabricante.focus();
				document.form_seguros._15Fabricante.select();
				alert (msg_erro_form_fabricante);
				return false;		
			}// end if
			
			if (document.form_seguros._16Modelo.value.length < 2 )
			{	document.form_seguros._16Modelo.focus();
				document.form_seguros._16Modelo.select();
				alert (msg_erro_form_modelo);
				return false;		
			}// end if	
			
			if (document.form_seguros._18AnoFabricacao.value.length < 4 || !check_IsNumeric(document.form_seguros._18AnoFabricacao.value) )
			{	document.form_seguros._18AnoFabricacao.focus();
				document.form_seguros._18AnoFabricacao.select();
				alert (msg_erro_form_anofabricacao);
				return false;		
			}// end if	
		
			if (document.form_seguros._19AnoModelo.value.length < 4|| !check_IsNumeric(document.form_seguros._19AnoModelo.value) )
			{	document.form_seguros._19AnoModelo.focus();
				document.form_seguros._19AnoModelo.select();
				alert (msg_erro_form_anomodelo);
				return false;		
			}// end if				
			
			
			if ( ( document.form_seguros._46NomeCondutor.value.length > 0 ) && (check_HasNumeric(document.form_seguros._46NomeCondutor.value)) )
     		 {
					 document.form_seguros._46NomeCondutor.focus();
					alert (msg_erro_form_nome_condutor_invalido );
					return false;							
				// end if 
			}
			
		if ( ( document.form_seguros._54NomeDemaisCondutores.value.length > 0 ) && (check_HasNumeric(document.form_seguros._54NomeDemaisCondutores.value)) )
     		 {
					 document.form_seguros._54NomeDemaisCondutores.focus();
					alert (msg_erro_form_nome_demais_condutores_invalido);
					return false;							
				// end if 
			}

			
			// Tudo OK 
			return true;
			
	}// end validaFormSeguros()	
	


	function check_IsNumeric(strString)
    {
	   var strValidChars = "0123456789";
	   var strChar;
	   var blnResult = true;

	   if (strString.length == 0) return false;

		//  test strString consists of valid characters listed above
	   for (i = 0; i < strString.length && blnResult == true; i++)
	   {
	      strChar = strString.charAt(i);
    	  if (strValidChars.indexOf(strChar) == -1)
          {
	         blnResult = false;
    	  }// END IF 
	    }// END FOR 
		
	   return blnResult;	   
   }// END check_IsNumeric
   

	function check_IsNumeric2(strString)
    {
	   var strValidChars = "0123456789-()";
	   var strChar;
	   var blnResult = true;

	   if (strString.length == 0) return false;

		//  test strString consists of valid characters listed above
	   for (i = 0; i < strString.length && blnResult == true; i++)
	   {
	      strChar = strString.charAt(i);
    	  if (strValidChars.indexOf(strChar) == -1)
          {
	         blnResult = false;
    	  }// END IF 
	    }// END FOR 
		
	   return blnResult;	   
   }// END check_IsNumeric2
   
   
   	function check_HasNumeric(strString)
    {
	   var numericChars = "0123456789-()";
	   var strChar;
	   var blnResult = false;

		if (strString.length == 0) return false;

		//  test strString consists of valid characters listed above
	   for (i = 0; i < strString.length && blnResult == false; i++)
	   {
	      strChar = strString.charAt(i);
    	  if (numericChars.indexOf(strChar) != -1)
          {
	         blnResult = true;
    	  }// END IF 
	    }// END FOR 
		
	   return blnResult;	   

	   
   }// END check_IsNumeric


	function check_date(field){
			var checkstr = "0123456789";
			var DateField = field;
			var Datevalue = "";
			var DateTemp = "";
			var seperator = "/";
			var day;
			var month;
			var year;
			var leap = 0;
			var err = 0;
			var i;
			   err = 0;
			   DateValue = DateField.value;
			   /* Delete all chars except 0..9 */
			   for (i = 0; i < DateValue.length; i++) {
				  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
					 DateTemp = DateTemp + DateValue.substr(i,1);
				  }
			   }// end for 
			   
			   DateValue = DateTemp;
			
			   /* Always change date to 8 digits - string*/
			   /* if year is entered as 2-digit / always assume 20xx */
			   if (DateValue.length == 6) {
				  DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
			   if (DateValue.length != 8) {
				  err = 19;}
			   /* year is wrong if year = 0000 */
			   year = DateValue.substr(4,4);
			   if (year == 0) {
				  err = 20;
			   }
			   /* Validation of month*/
			   month = DateValue.substr(2,2);
			   if ((month < 1) || (month > 12)) {
				  err = 21;
			   }
			   /* Validation of day*/
			   day = DateValue.substr(0,2);
			   if (day < 1) {
				 err = 22;
			   }
			   /* Validation leap-year / february / day */
			   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
				  leap = 1;
			   }
			   if ((month == 2) && (leap == 1) && (day > 29)) {
				  err = 23;
			   }
			   if ((month == 2) && (leap != 1) && (day > 28)) {
				  err = 24;
			   }
			   /* Validation of other months */
			   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
				  err = 25;
			   }
			   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
				  err = 26;
			   }
			   /* if 00 ist entered, no error, deleting the entry */
			   if ((day == 0) && (month == 0) && (year == 00)) {
				  err = 0; day = ""; month = ""; year = ""; seperator = "";
			   }
			   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
			   if (err == 0) 
			   {
				  DateField.value = day + seperator + month + seperator + year;
				  return true;
			   }else{ 
				return false;  
			   }// end else 
	}// end check_date(field)
	

	// valida o CEP    
   function check_CEP(field) {
		var valid = "0123456789-";
		var hyphencount = 0;
		
		if (field.value.length!=9) {
			return false;
		}// end if 

		for (var i=0; i < field.length; i++) {			
			temp = "" + field.substring(i, i+1);
			
			if (temp == "-") hyphencount++;
			
			if (valid.indexOf(temp) == "-1")
			{
				return false;
			}// end if 	   
			
		}// end for 		
		
		if (field.value.indexOf("-") != 5)
		{		
			return false;			
		}// end if 
		
		
		return true;		
		
	}// end check_CEP
	
	function checkEmail(EmailAddr)
	{
		 return (EmailAddr.indexOf(".") > 2) && (EmailAddr.indexOf("@") > 0);
	}// end checkEmail	
	

 //-->
