// Valida campos vazios do formulario especificado, não valida check e radio;
//  colocar em cada campo que deve ser validado: obrigatorio="sim"
//  <INPUT id=text1 name=text1 obrigatorio="sim" >
//------------------------------------------------------------
//    function incluir()
//    {	if(verifica_vazio(document.form1))
//			{return;}
//	document.form1.action = "/asp/arquivo_destino.asp";
//	document.form1.submit();
//	}
//------------------------------------------------------------   
function tira_espaco(Texto){while(''+Texto.charAt(Texto.length-1)==' '){
	Texto=Texto.substring(0,Texto.length-1);}
	return(Texto.length);
	}

function verifica_vazio(form) 
{
	for (i=0; i <= form.elements.length - 1; i++) 
	{ 
		
		if ((eval("form.elements["+i+"].obrigatorio == 'sim'"))&&((tira_espaco(form.elements[i].value) == "0") || (form.elements[i].value == "")) ) 
		//if (tira_espaco(form.elements[i].value) == "0" || form.elements[i].value == "")
		{
			//alert(i);
			  if(!(form.elements[i].msg_campo) == ""){
				alert("Campo obrigatório "+form.elements[i].msg_campo+" não preenchido !");				  
			  }
			  else{
                alert("Campo obrigatório não preenchido !");
			  }
			  form.elements[i].focus();
			  return (true);
			  
		}
		
	}
	//return (false);
}
function checkempty(theform){
var returnval=true //by default, allow form submission
for (i=0; i<theform.elements.length; i++){
	if (theform.elements[i].type=="text" || theform.elements[i].type=="textarea"){
		if (theform.elements[i].value==""){ //if empty field
			alert("Please make sure all fields are entered") //alert error message
			returnval=false //disallow form submission
			break //end loop. No need to continue.
			}
		}
	}
	return returnval
}