function validadata(Data,Campodata){
if (Data == "")
   {
   return false;
   }
Data_valida = true
if (Data.length > 10)
   {
   Data_valida = false;
   }
if (!isNaN(Data))
   {
   Data_valida = false;
   }
for (i=0;i<=Data.length;i++)
   {
   if (isNaN(Data.charAt(i)))
      {
      Separador = Data.charAt(i)
      if (Separador != "/")
         {
         Data_valida = false;
         }
      Dia = Data.substring(0,Data.indexOf(Separador));
      Mes = Data.substring(eval(Data.indexOf(Separador) + 1),Data.lastIndexOf(Separador));
      Ano = Data.substring(eval(Data.lastIndexOf(Separador) + 1),Data.length);
      } //End if
   } // End For
   
if (isNaN(Dia))
   {
   Data_valida = false; 
   }
if (Dia.length < 1 || Dia.length > 2)
   {
   Data_valida = false; 
   }
if (isNaN(Mes))
   {
   Data_valida = false; 
   }
if (Mes.length < 1 || Mes.length > 2 )
   {
   Data_valida = false; 
   }
if (isNaN(Ano))
   {
   Data_valida = false;
   }
if (Ano.length < 2 || Ano.length > 4)
   {
   Data_valida = false; 
   }
if (Dia < 1 || Dia > 31 || Mes < 1 || Mes > 12)
   {
   Data_valida = false; 
   }
if (Data_valida==false) 
   {
   alert(Campodata);
   return false;
   }
}

function changeURL(nome) 
{ 
 strWannaChange = "Têm certeza que deseja excluir "+nome+"?" 
return(confirm(strWannaChange)) ;
}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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=args[i+1]; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must have a valid e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must have a number.\n';
        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+' must have a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('Erro:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function atualiza()
{
window.open("emails.asp","corpo");
this.window.close();
}

function cur_val_cad() {
	cpf				=	document.form.cpf.value;
	nome			=	document.form.nome.value;
	email			=	document.form.email.value;
	senha			=	document.form.senha.value;
	nascimento		=	document.form.nascimento.value;
	endereco		=	document.form.endereco.value;
	bairro			=	document.form.bairro.value;
	cidade			=	document.form.cidade.value;
	pais			=	document.form.pais.value;
	nacionalidade	=	document.form.nacionalidade.value;


	if(!testaCPF(cpf)){
		alert('O campo CPF deve ser válido.');
		cur_muda_td('db');
		return false;
	}
	
	if(nome.length<3 || nome.length>100 ){
		alert('O campo NOME deve ser preenchido.');
		cur_muda_td('db');
		return false;
	}	
	
	if(!testaEmail(email)){
		alert('O campo E-MAIL deve ser válido.');
		cur_muda_td('db');
		return false;
	}
	
	if(senha.length<5 || senha.length>15 ){
		alert('O campo SENHA deve ser preenchido.');
		cur_muda_td('db');
		return false;
	}

	if(!testaData(nascimento)){
		alert('O campo NASCIMENTO deve ser válido.');
		cur_muda_td('dp');
		return false;
	}
	
	if(endereco.length<5 || endereco.length>200 ){
		alert('O campo ENDEREÇO deve ser preenchido.');
		cur_muda_td('dp');
		return false;
	}
	
	if(bairro.length<5 || bairro.length>50 ){
		alert('O campo BAIRRO deve ser preenchido.');
		cur_muda_td('dp');
		return false;
	}	
	
	if(cidade.length<5 || cidade.length>50 ){
		alert('O campo CIDADE deve ser preenchido.');
		cur_muda_td('dp');
		return false;
	}	
	
	if(pais.length<5 || pais.length>50 ){
		alert('O campo PAÍS deve ser preenchido.');
		cur_muda_td('dp');
		return false;
	}	
	
	if(nacionalidade.length<5 || nacionalidade.length>50 ){
		alert('O campo NACIONALIDADE deve ser preenchido.');
		cur_muda_td('dp');
		return false;
	}	
}


function cur_muda_td(qual) {
    todas	=	new Array("db", "dp", "fe", "id", "ex", "ep", "ic");

	td		=	"td_"+qual;
	fs		=	"fs_"+qual;

	document.getElementById(td).className		=	"cur-link-escolhido";
	document.getElementById(fs).style.display	=	"block";

	for(i=0;i<todas.length;i++){
			td_laco	=	"td_"+todas[i];
			fs_laco	=	"fs_"+todas[i];
		if(td != td_laco){
			document.getElementById(td_laco).className		=	"cur-link-sem-foco";
			document.getElementById(fs_laco).style.display	=	"none";
		}
	}

}



function vg_senha_perdida()
{
	email	=	window.prompt('Para recuperar sua senha digite seu E-mail:','');

	if(email != null)
	{
		xmlhttp	=	mount_XMLHttp();
		url	=	"../ajax/vg.senhaperdida.php?email="+email;
		xmlhttp.open("GET", url,true);
	
		xmlhttp.onreadystatechange=function() {
		
			if(xmlhttp.readyState==4){
				alert(xmlhttp.responseText);
			}
		}
	
	xmlhttp.send(null);
	}
}


function ar_val_upd()
{
nome	=	document.form.nome.value;
email	=	document.form.email.value;
senha	=	document.form.senha.value;
senha2	=	document.form.senha2.value;

	if(nome.length<3 || nome.length>100){
		alert('Preencha o campo nome corretamente.');
		document.form.nome.focus();
		return false;
	}
	
	if(!testaEmail(email)){
		alert('Preencha o campo e-mail corretamente.');
		document.form.email.focus();
		return false;
	}

if(document.form.muda_senha.checked)
{
	if(senha.length<5 || senha.length>15){
		alert('Preencha o campo senha corretamente.');
		document.form.senha.focus();
		return false;
	}

	if(senha != senha2){
		alert('Os campos de senha não conferem.');
		document.form.senha.value	=	"";
		document.form.senha2.value	=	"";
		document.form.senha.focus();
		return false;
	}

}

return true;
}



function ar_habilita_senha()
{
	if(document.form.muda_senha.checked)
	{
		document.form.senha.disabled	=	false;
		document.form.senha2.disabled	=	false;
	}else{
		document.form.senha.value		=	"";
		document.form.senha2.value		=	"";
		document.form.senha.disabled	=	true;
		document.form.senha2.disabled	=	true;
	}
}



function ar_senha_perdida()
{
	email	=	window.prompt('Para recuperar sua senha digite seu E-mail:','');

	if(email != null)
	{
		xmlhttp	=	mount_XMLHttp();
		url	=	"../ajax/ar.senhaperdida.php?email="+email;
		xmlhttp.open("GET", url,true);
	
		xmlhttp.onreadystatechange=function() {
		
			if(xmlhttp.readyState==4){
				alert(xmlhttp.responseText);
			}
		}
	
	xmlhttp.send(null);
	}
}


function forum_chk_login()
{
email	=	document.form.email.value;
xmlhttp	=	mount_XMLHttp();
url		=	"../ajax/forum.chk_login.php?email="+email;

xmlhttp.open("GET", url,true);

xmlhttp.onreadystatechange=function() {

	if(xmlhttp.readyState==4){
		retorno		=	xmlhttp.responseText;
		if(retorno=="N"){
			alert('E-mail inválido ou em uso. Tente outro.');
			document.form.email.select();
		}
	}
}
xmlhttp.send(null);
}



function forum_senha_perdida()
{
	email	=	window.prompt('Para recuperar sua senha digite seu E-mail:','');

	if(email != null)
	{
		xmlhttp	=	mount_XMLHttp();
		url	=	"../ajax/forum.senhaperdida.php?email="+email;
		xmlhttp.open("GET", url,true);
	
		xmlhttp.onreadystatechange=function() {
		
			if(xmlhttp.readyState==4){
				alert(xmlhttp.responseText);
			}
		}
	
	xmlhttp.send(null);
	}
}




function enq_vota()
{
	resposta="";
	
	for (i=0; i<document.form_enquete.voto.length; i++) {
		if (document.form_enquete.voto[i].checked) {
			marcado		=	i;
			resposta	=	document.form_enquete.voto[i].value;
		}
	}

if(resposta==""){
	alert('Selecione uma opção.');
}else{
	pop_up_center('../internas/pop.enquete.php?voto='+resposta, 550, 330, 'yes');
}


}


function pop_up_center(local, w, h, scrol)
{
instan	=	local.replace(/\./g,"");
instan	=	instan.replace(/\?/g,"");
instan	=	instan.replace(/\//g,"");
instan	=	instan.replace(/=/g,"");
instan	=	instan.replace(/;/g,"");

largura = screen.width;
altura 	= screen.height;
XX 		= (largura-w)/2;
YY		= (altura-h)/2;
janela = window.open(local,'POP_UP'+instan,'width='+w+',height='+h+',left='+XX+',top='+YY+',scrollbars='+scrol+',status=no,resizable=yes, toolbar=no,directories=no,menubar=no');
janela.focus();
}


function mount_XMLHttp()
{
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}
return xmlhttp;
}


function _go(selObj)
{
valor = selObj.options[selObj.selectedIndex].value;
	if(valor != "#"){
		self.location = valor;
	}
}

function excluir(){
	return confirm('Confirma remoção do item?');
}

function imprime_flash_embed(arquivo, largura, altura, wmode) {
    document.write("<embed src=\""+arquivo+"\" width=\""+largura+"\" height=\""+altura+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" wmode=\""+wmode+"\"></embed>");
}

function addToFavorites(pageName){
	if(window.external){
		window.external.AddFavorite(window.location,pageName);
	}else{
		window.sidebar.addPanel(pageName,location.href,"");
	}
}

function squirrelmail_loginpage_onload() {
document.forms[0].js_autodetect_results.value = '1';
var textElements = 0;
for (i = 0; i < document.forms[0].elements.length; i++) {
  if (document.forms[0].elements[i].type == "text" || document.forms[0].elements[i].type == "password") {
	textElements++;
	if (textElements == 1) {
	  document.forms[0].elements[i].focus();
	  break;
	}
  }
}
}
