<!--

	function validaFormPedAlgarea()
	{	
			var msg_erro_form_nome = "Por favor informe seu nome/razão corretamente.";
			//var msg_erro_form_codcli = "Por favor informe corretamente o codigo do cliente com 6 caracteres.";			
			var msg_erro_form_compr = "Por favor informe o comprador.";	
			var	msg_erro_form_CPF_CNPJ = "O campo CPF/CNPJ deve conter até 18 caracteres e apenas números e pontuação.";						
			var msg_erro_form_Inscr = "O campo Inscrição/ProdRural deve conter apenas números e pontuação.";
			var msg_erro_form_end = "Por favor informe o endereço.";
			var msg_erro_form_bairro = "Por favor informe o bairro.";
			var msg_erro_form_mun = "Por favor informe o município.";
			var msg_erro_form_estado = "Por favor informe o estado com 2 letras.";			
			var msg_erro_form_cep = "Por favor informe corretamente o CEP. Exemplo: 11222-333";
			var msg_erro_tel_comercial = "Por favor informe o telefone comercial corretamente. Exemplo:(21)4444-8877. Não coloque espaços";
			var msg_erro_form_email = "Por favor preencha corretamente seu e-mail.";
			var msg_erro_form_ped = "Por favor preencha TODOS os campos do pedido.";
			var msg_erro_form_repr = "Por favor informe o nome do Representante.";
			var msg_erro_form_pag = "Por favor informe a forma de pagamento.";
			
			if (document.form_ped_algarea._01Nome.value.length < 2 )
			{	document.form_ped_algarea._01Nome.focus();
				alert (msg_erro_form_nome);
				return false;		
			}		
					
			//if (document.form_ped_algarea._01aCodCli.value.length < 6 )
			//{	document.form_ped_algarea._01aCodCli.focus();
			//	alert (msg_erro_form_codcli);
			//	return false;		
			//}
			
			if (document.form_ped_algarea._02Comprador.value.length < 2 )
			{	document.form_ped_algarea._02Comprador.focus();
				alert (msg_erro_form_compr);
				return false;		
			}	
			
			if ( ( document.form_ped_algarea._03CPF_CNPJ.value.length > 18 ) || (!check_IsNumeric_3(document.form_ped_algarea._03CPF_CNPJ.value)) )
     		{
				document.form_ped_algarea._03CPF_CNPJ.focus();
				alert (msg_erro_form_CPF_CNPJ);
				return false;							
			}
		
			if ( ( document.form_ped_algarea._04Inscr.value.length < 4 ) || (!check_IsNumeric_3(document.form_ped_algarea._04Inscr.value)) )
     		{
				document.form_ped_algarea._04Inscr.focus();
				alert (msg_erro_form_Inscr);
				return false;							
			}
			
			if (document.form_ped_algarea._05Endereco.value.length < 2  )
			{	document.form_ped_algarea._05Endereco.focus();
				alert (msg_erro_form_end);
				return false;		
			}// end if
			
			if (document.form_ped_algarea._06Bairro.value.length < 2  )
			{	document.form_ped_algarea._06Bairro.focus();
				alert (msg_erro_form_bairro);
				return false;		
			}// end if
			
			if (document.form_ped_algarea._07Municipio.value.length < 2  )
			{	document.form_ped_algarea._07Municipio.focus();
				alert (msg_erro_form_mun);
				return false;		
			}// end if
			
			if (document.form_ped_algarea._08Estado.value.length < 2  )
			{	document.form_ped_algarea._08Estado.focus();
				alert (msg_erro_form_estado);
				return false;		
			}// end if

			if (!check_CEP(document.form_ped_algarea._09Cep) )
			{	document.form_ped_algarea._09Cep.focus();
				document.form_ped_algarea._09Cep.select();
				alert(msg_erro_form_cep);
				return false;		
			}// end if


			if ( ( document.form_ped_algarea._10TelComercial.value.length < 7 ) || (!check_IsNumeric_3(document.form_ped_algarea._10TelComercial.value)) )
     		{
				document.form_ped_algarea._10TelComercial.focus();
				alert (msg_erro_tel_comercial);
				return false;							
			}
			
									
			if (document.form_ped_algarea.email.value.length < 4 || !checkEmail(document.form_ped_algarea.email.value) )
			{	document.form_ped_algarea.email.focus();
				document.form_ped_algarea.email.select();
				alert (msg_erro_form_email);
				return false;
			}// end if
			
			if (document.form_ped_algarea._20End_Cobr.value.length < 2  )
			{	document.form_ped_algarea._20End_Cobr.focus();
				alert (msg_erro_form_end);
				return false;		
			}// end if
			
			if (document.form_ped_algarea._30End_Entr.value.length < 2  )
			{	document.form_ped_algarea._30End_Entr.focus();
				alert (msg_erro_form_end);
				return false;		
			}// end if
			
			if (document.form_ped_algarea._400CodSum.value.length < 1  )
			{	document.form_ped_algarea._400CodSum.focus();
				alert (msg_erro_form_ped);
				return false;		
			}
			
			if (document.form_ped_algarea._401QtdSum.value.length < 1  )
			{	document.form_ped_algarea._401QtdSum.focus();
				alert (msg_erro_form_ped);
				return false;		
			}
			
			if (document.form_ped_algarea._402PrUnitSum.value.length < 1  )
			{	document.form_ped_algarea._402PrUnitSum.focus();
				alert (msg_erro_form_ped);
				return false;		
			}
			
			if (document.form_ped_algarea._403PrTotSum.value.length < 1  )
			{	document.form_ped_algarea._403PrTotSum.focus();
				alert (msg_erro_form_ped);
				return false;		
			}
			
			if (document.form_ped_algarea._410CodCon.value.length < 1  )
			{	document.form_ped_algarea._410CodCon.focus();
				alert (msg_erro_form_ped);
				return false;		
			}
			
			if (document.form_ped_algarea._411QtdCon.value.length < 1  )
			{	document.form_ped_algarea._411QtdCon.focus();
				alert (msg_erro_form_ped);
				return false;		
			}
			
			if (document.form_ped_algarea._412PrUnitCon.value.length < 1  )
			{	document.form_ped_algarea._412PrUnitCon.focus();
				alert (msg_erro_form_ped);
				return false;		
			}
			
			if (document.form_ped_algarea._413PrTotCon.value.length < 1  )
			{	document.form_ped_algarea._413PrTotCon.focus();
				alert (msg_erro_form_ped);
				return false;		
			}
			
			if (document.form_ped_algarea._49Pag.value.length < 2 )
			{	document.form_ped_algarea._49Pag.focus();
				alert (msg_erro_form_pag);
				return false;		
			}
			
			if (document.form_ped_algarea._70Repr.value.length < 2 )
			{	document.form_ped_algarea._70Repr.focus();
				alert (msg_erro_form_repr);
				return false;		
			}
			
			
			// 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_IsNumeric_3(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_3
   
   
   	function check_HasNumeric_3(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(".") > 1) && (EmailAddr.indexOf("@") > 0);
	}// end checkEmail	
	

 //-->
