function submitform() {
	document.form.submit();
}

function submitform2() {
	document.form2.submit();
}

function checkIt(evt) {
	evt = (evt) ? evt : window.event
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
		status = "Este campo aceita somente número."
		return false
	}
	status = ""
	return true
}

//VERIFICA O CPF, INCLUSIVE NUMEROS IGUAIS
/*function checkCPF(whatForm, whatInput, errorMessage){
  var tmpCPF = whatForm.elements[whatInput];
  var numcpf = tmpCPF.value;*/
function checkCPF(){
  var tmpCPF = document.form.cpf;
  var numcpf = document.form.cpf.value;

  x = 0;
  soma = 0;
  dig1 = 0;
  dig2 = 0;
  texto = "";
  numcpf1 = "";
  len = numcpf.length;
  x = len -1;
  for (var i=0; i <= len - 3; i++) {
    y = numcpf.substring(i,i+1);
    soma = soma + ( y * x);
    x = x - 1;
    texto = texto + y;
  }
  dig1 = 11 - (soma % 11);
  if (dig1 == 10) dig1=0 ;
  if (dig1 == 11) dig1=0 ;
    numcpf1 = numcpf.substring(0,len - 2) + dig1 ;
    x = 11; soma=0;
  for (var i=0; i <= len - 2; i++) {
    soma = soma + (numcpf1.substring(i,i+1) * x);
    x = x - 1;
  }
  dig2= 11 - (soma % 11);
  if (dig2 == 10) dig2=0;
  if (dig2 == 11) dig2=0;
  if ((dig1 + "" + dig2) == numcpf.substring(len,len-2)) {
    if(numcpf % 11111111111 == 0){
		window.showModalDialog("box_msg.asp?gerro=CPF Inválido ou nulo.","Window1", "menubar=no,dialogWidth:300px; dialogHeight:320px,toolbar=no");
      //showWarning(errorMessage, tmpCPF);
      document.form.cpf.focus();
    return false;
    }
    return true;
  }
  //showWarning(errorMessage, tmpCPF);
  window.showModalDialog("box_msg.asp?gerro=CPF Inválido ou nulo.","Window1", "menubar=no,dialogWidth:300px; dialogHeight:320px,toolbar=no");
  document.form.cpf.focus();
  return false;
}


//-----------------------------------------------------------------

function verifica_campos_pag1() {
    var gerro = 0;
	
	if (document.form.nome.value == ""){
		alert("Preencha o campo 'Nome'.");
		var gerro = 1;
		document.form.nome.focus();
		return false;
	}
	
	if (document.form.email.value < 1){
		alert("Preencha o campo 'E-Mail'.");
		var gerro = 1;
		document.form.email.focus();
		return false;
	}

	var  exp = /^([0-9,a-z,A-Z]+)([.,_]([0-9,a-z,A-Z,_]+))*[@]([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$/;
	if (!exp.test(document.form.email.value)) {
		alert("E-mail inválido!");
		var gerro = 1;
		document.form.email.focus();
		return false;
	}

	if (document.form.cpf.value == ""){
	alert("Preencha o campo 'CPF'.");
		document.form.cpf.focus();
		var gerro = 1;
		return false;
	}

	if (!checkCPF(document.form.cpf, 'CPF inválido.')){
		alert("'CPF' inválido.");
		var gerro = 1;
		document.form.cpf.focus();
		return false;
	}

	if (document.form.nome.value.length < 3){
		alert("O campo 'Nome' não está preenchido corretamente!");
		var gerro = 1;
		document.form.nome.focus();
		return false;
	}

	if (document.form.sexo.value == "-1"){
		alert("Selecione o campo 'Sexo'.");
		var gerro = 1;
		document.form.sexo.focus();
		return false;
	}

	if (document.form.endereco.value == ""){
		alert("Preencha o campo 'Endereço'.");
		var gerro = 1;
		document.form.endereco.focus();
		return false;
	}

	if (document.form.endereco.value.length < 3){
		alert("O campo 'Endereço' não está preenchido corretamente!");
		var gerro = 1;
		document.form.endereco.focus();
		return false;
	}

	if (document.form.cidade.value == ""){
		alert("Preencha o campo 'Cidade'.");
		var gerro = 1;
		document.form.cidade.focus();
		return false;
	}

	if (document.form.cidade.value.length < 3){
		alert("O campo 'Cidade' não está preenchido corretamente!");
		var gerro = 1;
		document.form.cidade.focus();
		return false;
	}

	if (document.form.uf.value == "-1"){
		alert("Selecione o campo 'UF'.");
		var gerro = 1;
		document.form.uf.focus();
		return false;
	}


	if (gerro == 0) {
		document.form.submit();
	}
	
return true;
}



function formataCEP(campo) {
	var valor
	valor = campo.value.replace('-','');
	 if(valor.length >= 5){
		campo.value = valor.substr(0,5) + "-" + valor.substr(5,3) ;

	}else{
		campo.value = valor;
	}
}

<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' Email Inválido.<br>';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' Campo só aceita números.<br>';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' Campo só aceita números de '+min+' a '+max+'.<br>';
    } } } else if (test.charAt(0) == 'R') errors += '- Campo '+nm+' Está vazio.<br>'; }
  } if (errors) window.open('box_msg.asp?gerro='+errors+'', 'Window1', 'menubar=no,width=300,height=300,toolbar=no');
  document.MM_returnValue = (errors == '');
}

var max=200;  		// 50  = max characters

function count_justificativa(f) {
	var txt=f.justificativa.value;
	var nb=txt.length;
	if (nb>max) { 
		window.open("box_msg.asp?gerro=Você só pode digitar<BR>500 caracteres neste campo.","Window1", "menubar=no,width=300,height=300,toolbar=no");
		f.justificativa.value=txt.substring(0,max);
		nb=max;
	}
}

var max=500;

function count_situada(f) {
	var txt=f.situada.value;
	var nb=txt.length;
	if (nb>max) { 
		window.open("box_msg.asp?gerro=Você só pode digitar<BR>500 caracteres neste campo.","Window1", "menubar=no,width=300,height=300,toolbar=no");
		f.situada.value=txt.substring(0,max);
		nb=max;
	}
}

function count_apresentacao(f) {
	var txt=f.apresentacao.value;
	var nb=txt.length;
	if (nb>max) { 
		window.open("box_msg.asp?gerro=Você só pode digitar<BR>500 caracteres neste campo.","Window1", "menubar=no,width=300,height=300,toolbar=no");
		f.apresentacao.value=txt.substring(0,max);
		nb=max;
	}
}

function count_descricao(f) {
	var txt=f.descricao.value;
	var nb=txt.length;
	if (nb>max) { 
		window.open("box_msg.asp?gerro=Você só pode digitar<BR>500 caracteres neste campo.","Window1", "menubar=no,width=300,height=300,toolbar=no");
		f.descricao.value=txt.substring(0,max);
		nb=max;
	}
}

function count_recursos(f) {
	var txt=f.recursos.value;
	var nb=txt.length;
	if (nb>max) { 
		window.open("box_msg.asp?gerro=Você só pode digitar<BR>500 caracteres neste campo.","Window1", "menubar=no,width=300,height=300,toolbar=no");
		f.recursos.value=txt.substring(0,max);
		nb=max;
	}
}

function count_resultados(f) {
	var txt=f.resultados.value;
	var nb=txt.length;
	if (nb>max) { 
		window.open("box_msg.asp?gerro=Você só pode digitar<BR>500 caracteres neste campo.","Window1", "menubar=no,width=300,height=300,toolbar=no");
		f.resultados.value=txt.substring(0,max);
		nb=max;
	}
}

function count_replica(f) {
	var txt=f.replica.value;
	var nb=txt.length;
	if (nb>max) { 
		window.open("box_msg.asp?gerro=Você só pode digitar<BR>500 caracteres neste campo.","Window1", "menubar=no,width=300,height=300,toolbar=no");
		f.replica.value=txt.substring(0,max);
		nb=max;
	}
}

function count_dicas(f) {
	var txt=f.dicas.value;
	var nb=txt.length;
	if (nb>max) { 
		window.open("box_msg.asp?gerro=Você só pode digitar<BR>500 caracteres neste campo.","Window1", "menubar=no,width=300,height=300,toolbar=no");
		f.dicas.value=txt.substring(0,max);
		nb=max;
	}
}
//-->

