function checkMail(email){
	  er = /^[a-zA-Z0-9][a-zA-Z0-9\._-]+@([a-zA-Z0-9\._-]+\.)[a-zA-Z-0-9]{2}/;
	  
	  if(er.exec(email.value))
			{
			  return true;
			} else {
			  window.alert('E-Mail Inválido.');
			  email.value="";
			  globalvar = email;
			  setTimeout("globalvar.focus()",250);
			}
}

function validarCPF(Objcpf)
{
	var numcpf = Objcpf.value;
	exp = /\.|\-/g;
    numcpf = numcpf.toString().replace(exp, "");
	
	x = 0;
	soma = 0;
	dig1 = 0;
	dig2 = 0;
	texto = "";
	numcpf1="";
	len = numcpf.length; x = len -1;
	// var numcpf = "12345678909";
	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;
	//alert ("Digito Verificador : " + dig1 + "" + dig2);
	if ((dig1 + "" + dig2) == numcpf.substring(len,len-2) && numcpf!="11111111111") {
		return true;
	}
	//return false;
	window.alert("CPF Inválido.");
	Objcpf.value="";
	globalvar = Objcpf;
	setTimeout("globalvar.focus()",250);
}

function FormataCpf(campo, teclapres)
{
	var tecla = teclapres.keyCode;
	var vr = new String(campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace("/", "");
	vr = vr.replace("-", "");
	tam = vr.length + 1;
	if (tecla != 14)
	{
		if (tam == 4)
			campo.value = vr.substr(0, 3) + '.';
		if (tam == 7)
			campo.value = vr.substr(0, 3) + '.' + vr.substr(3, 6) + '.';
		if (tam == 11)
			campo.value = vr.substr(0, 3) + '.' + vr.substr(3, 3) + '.' + vr.substr(7, 3) + '-' + vr.substr(11, 2);
	}
}

function SomenteNum(e){
   /*
 	 8 - backspace/ 46 - delete/ 9 - tab/ 37a40 - teclas de navegacao
   */
   var codigo = window.event ? e.keyCode : e.which;
   return ((codigo>=96&&codigo<=105)||(codigo>=48&&codigo<=57)||(codigo==8)||
       (codigo==46)||(codigo==9)||(codigo>=37&&codigo<=40))
}