//Valida Email:
function ValidaEmail(email,f1,f2){
	if(ValorIndevido(email,"",f1))return true;
	var pArroba = email.value.indexOf("@");
	var pPonto = email.value.indexOf(".");
	var tEmail = email.value.length;
	if(pArroba <= 0 || pPonto < 0 || (pArroba + 1) == pPonto || (pPonto + 3) > tEmail){
		alert(f2);
		email.value = "";
		email.focus();
		return true;
	}
	return false;
}


//Valida Senha e Confirma�o:
function ValidaSenha(senha,cSenha, f1, f2, f3){
	if(ValorIndevido(senha,"",f1))return true;
	if(ValorIndevido(cSenha,"",f2))return true;
	if(cSenha.value != senha.value){
		alert(f3);
		cSenha.value = "";
		senha.value = "";
		senha.focus();
		return true;
	}
	return false;
}

//S�numero: <input name="SomenteNum" type="text" onkeypress="SoNum()">
function SoNum() {
	if((event.keyCode < 48) || (event.keyCode > 57))event.returnValue = false;
}

//Valida valor do campo
function ValorIndevido(FormCampo, Valor, Alert){
	if(FormCampo.value==Valor){
		alert(Alert);
		FormCampo.focus();
		return true;
	}
	return false;
}

function MascaraData (keypress, objeto){
// Fun�o que formata a digita�o de data
//---------------------------------------
	campo = eval (objeto);

	//Verifica se outro caractere alem de nmero foi digitado
	if (event.keyCode < "48" || event.keyCode > "57")
		event.keyCode =0;

	separador = '/';
	conjunto1 = 2;
	conjunto2 = 5;

	if (campo.value.length == conjunto1){
		campo.value = campo.value + separador;
	}
	if (campo.value.length == conjunto2){
		campo.value = campo.value + separador;
	}
}

function submeteTipoPub2(){
	tipo = document.frmTipopub.tipopub.value;
	if( tipo == "1" ){
		//mesmo de infancia - resenhaal
		document.frmTipopub.action = "inserir_resenha.php5";
		document.frmTipopub.submit();
		return;
	}/*else if( tipo == "5" ){
		//mesmo de infancia - resenhaal
		document.frmTipopub.action = "inserir_enlaces.php5";
		document.frmTipopub.submit();
		return;
	}*/
	document.frmTipopub.action = "inserir.php5?tipo="+tipo;
	document.frmTipopub.submit();
}

function submeteRecuperaSenha(){
	document.frmLogin.action = "http://www.redandi.org/recuperaSenha.php5";
	document.frmLogin.submit();
}

function submeteBoletins (){
	t = document.frmBoletins.tipopub.value;
	p = document.frmBoletins.paisrede.value;
	if(t == "1"){
		//mesmo de infancia - resenhaal
		tipo = "infancia";
	}else if(t == "2"){
		tipo = "huellas";
	}else if(t == "3"){
		tipo = "pabsoluta";
	}else if(t == "4"){
		tipo = "infancia";
	}
	document.frmBoletins.action = "boletim_"+tipo+"_envio.php5?pais="+p;
	document.frmBoletins.submit();
}

function submeteTipoPubArg (p, a){
		if(p == 1){
			t = document.frmTipopub.tipopub.value;
			if(t == "1"){
				//resenha am lat - mesmo de infancia - ninez
				tipo = "infancia";
			}else if(t == "2"){
				tipo = "huellas";
			}else if(t == "3"){
				tipo = "pabsoluta";
			}else if(t == "4"){
				tipo = "infancia";
			}
			document.frmTipopub.action = "pub_"+tipo+"_insert_form.php5?arg="+a;
		}else{
			document.frmTipopub.action = "#";
		}
		//if(document.frmPesquisar.Paises.value != "todos"){
		document.frmTipopub.submit();
		//}
}

function submetePaisRede (cbbox){
	t = cbbox.value;
	if(t == "1"){
		tipo = "argentina";
	}else if(t == "3"){
		tipo = "bolivia";
	}else if(t == "5"){
		tipo = "brasil";
	}else if(t == "7"){
		tipo = "costarica";
	}else if(t == "9"){
		tipo = "guatemala";
	}else if(t == "11"){
		tipo = "nicaragua";
	}else if(t == "14"){
		tipo = "paraguay";
	}else if(t == "16"){
		tipo = "venezuela";
	}else if(t == "41"){
		tipo = "ecuador";
	}else if(t == "6"){
		tipo = "colombia";
	}else if(t == "160"){
        tipo = "peru";
	}else if(t == "207"){
        tipo = "uruguay";
    }
	top.location.href = "./"+tipo+"/";
}

