function abreTour(theURL){
 w = screen.width - 10;
 h = screen.height - 66;
 var popup = window.open(theURL, 'tour', 'left=0, top=0, width=' + w + ',height=' + h);
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ipx(url)
{
janela=window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=260')
}

function ficha(url)
{
janela=window.open(url,'','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=383,height=400')
}

function msl(divTo) {// Show Hide Changer

  if (document.getElementById(divTo).style.display == 'block') { 
  	document.getElementById(divTo).style.display = 'none';
  }
}
function esl(divTo) {//  Hide Changer

  if (document.getElementById(divTo).style.display == 'none') { 
  	document.getElementById(divTo).style.display = 'block';
  }
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}


function Restaura( ) {
	MM_swapImage('mes_1','',menu1,1);
	MM_swapImage('mes_2','',menu2,1);
	MM_swapImage('mes_3','',menu3,1);
	MM_swapImage('mes_4','',menu4,1);
	MM_swapImage('mes_5','',menu5,1);
	MM_swapImage('mes_6','',menu6,1);
	MM_swapImage('mes_7','',menu7,1);
	MM_swapImage('mes_8','',menu8,1);
	MM_swapImage('mes_9','',menu9,1);
	MM_swapImage('mes_10','',menu10,1);
	MM_swapImage('mes_11','',menu11,1);
	MM_swapImage('mes_12','',menu12,1);
}

function mostra_layer(id) {
	for(var i = 0; i < 12; i++ ) {
		MM_showHideLayers("foto"+i,'','hidden');
		msl("texto"+i);
		MM_showHideLayers("texto"+i,'','hidden');
		menu1 = "img/br_1.gif";
		menu2 = "img/br_2.gif";
		menu3 = "img/br_3.gif";
		menu4 = "img/br_4.gif";
		menu5 = "img/br_5.gif";
		menu6 = "img/br_6.gif";
		menu7 = "img/br_7.gif";
		menu8 = "img/br_8.gif";
		menu9 = "img/br_9.gif";
		menu10 = "img/br_10.gif";
		menu11 = "img/br_11.gif";
		menu12 = "img/br_12.gif";
	}
	if ( id == "0" ) {
		menu1 = "img/br_1_f2.gif";
	}
	else if ( id == "1" ) {
		menu2 = "img/br_2_f2.gif";
	}
	else if ( id == "2" ) {
		menu3 = "img/br_3_f2.gif";
	}
	else if ( id == "3" ) {
		menu4 = "img/br_4_f2.gif";
	}
	else if ( id == "4" ) {
		menu5 = "img/br_5_f2.gif";
	}
	else if ( id == "5" ) {
		menu6 = "img/br_6_f2.gif";
	}
	else if ( id == "6" ) {
		menu7 = "img/br_7_f2.gif";
	}
	else if ( id == "7" ) {
		menu8 = "img/br_8_f2.gif";
	}
	else if ( id == "8" ) {
		menu9 = "img/br_9_f2.gif";
	}
	else if ( id == "9" ) {
		menu10 = "img/br_10_f2.gif";
	}
	else if ( id == "10" ) {
		menu11 = "img/br_11_f2.gif";
	}
	else {
		menu12 = "img/br_12_f2.gif";
	}
	Restaura( );
	MM_showHideLayers("foto"+id,'','show');
	esl("texto"+id);
	MM_showHideLayers("texto"+id,'','show');
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
//-->

function tabFicador()
	{
	this.checaTab = taber_ChecaTab;
	this.marcaPos = taber_MarcaPosTab;

	this.posTab = 0;
	function taber_MarcaPosTab( pos )
		{
		this.posTab = pos;
		}

	function taber_ChecaTab( campo )
		{
		if( campo.value.length == 2 )
			{
			this.posTab++;
			if( this.posTab < campo.form.elements.length  )
				{
				campo.form.elements[this.posTab].focus();
				}
			}
		}

	}
var oTaber = new tabFicador();

function tabAno()
	{
	this.checaTab = taber_ChecaTab;
	this.marcaPos = taber_MarcaPosTab;

	this.posTab = 0;
	function taber_MarcaPosTab( pos )
		{
		this.posTab = pos;
		}

	function taber_ChecaTab( campo )
		{
		if( campo.value.length == 4 )
			{
			this.posTab++;
			if( this.posTab < campo.form.elements.length  )
				{
				campo.form.elements[this.posTab].focus();
				}
			}
		}

	}
var oAno = new tabAno();



function NewWindow(mypage,myname,w,h,scroll){

LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;

TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',unresizable'

win = window.open(mypage,myname,settings)

if(win.window.focus){win.window.focus();}

}

function FormataData(campo, event) {
	var posNumeros = "01346789";
	var posEspacos = "25";
	var strNumeros = '0123456789';

	if ((event.keyCode == 8) || (event.keyCode == 46))
		return false;

	for (i = 0; i < campo.value.length; i++)
		if ((posNumeros.indexOf(i) != -1) && (strNumeros.indexOf(campo.value.substr(i, 1)) == -1)) {
			campo.value = campo.value.substr(0, i);
			return false;
		} else if ((posEspacos.indexOf(i) != -1) && (campo.value.substr(i, 1) != '/')) {
			campo.value = campo.value.substr(0, i);
			return false;
	}

	if (campo.value.length > 10)
		campo.value = campo.value.substr(0, 10);

	if ((campo.value.length == 2) || (campo.value.length == 5))
		campo.value = campo.value + "/";
}

function ValidaData(valor) {
	if (valor.length == 0)
		return true;
	else if (valor.length != 10)
		return false;

	var dia = valor.substr(0, 2);
	var mes = valor.substr(3, 2);
	var ano = valor.substr(6, 4);

	if (!ValidaInteiro(dia)) return false;
	if (!ValidaInteiro(mes)) return false;
	if (!ValidaInteiro(ano)) return false;

	if (mes > 12 || mes < 1) return false;
	if (dia < 1) return false;
	if (ano < 1) return false;
	if ((mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12) && dia > 31) return false;
	if ((mes == 4 || mes == 6 || mes == 9 || mes == 11) && dia > 30) return false;
	if (mes == 2 && (((ano % 4) == 0 && (ano % 100) != 0) || (ano % 400) == 0) && dia > 29) return false;
	if (mes == 2 && !(((ano % 4) == 0 && (ano % 100) != 0) || (ano % 400) == 0)  && dia > 28) return false;
	return true;
}

function ValidaInteiro(valor) {
	var strNumeros = '0123456789';

	for (i = 0; i < valor.length; i++)
		if ((strNumeros.indexOf(valor.substr(i, 1)) == -1) && !((i == 0) && (valor.substr(i, 1) == '-')))
				return false;
	return true;
}

function ValidaDados(form) {
	if ( form.data_ini.value !="" && !ValidaData(form.data_ini.value)) {
		alert("Por favor, coloque uma data válida para o início do período. (ex 02/12/2001)");
		form.data_ini.focus();
		return false;
	}
	if ( form.data_fim.value !="" && !ValidaData(form.data_fim.value)) {
		alert("Por favor, coloque uma data válida para o término do período. (ex 02/12/2001)");
		form.data_fim.focus();
		return false;
	}
	return true;
}

function valida_amigo(form) {
	if ( form.nome.value == "" ) {
		alert("Por favor, digite o seu nome.");
		form.nome.focus();
		return false;
	}
	if ( form.email.value == "" ) {
		alert("Por favor, digite o seu e-mail.");
		form.email.focus();
		return false;
	}
	if ( !valida_mail(form.email.value) ) {
		alert("Por favor, um e-mail válido.");
		form.email.focus();
		return false;
	}
	if ( form.amigo.value == "" ) {
		alert("Por favor, digite o nome do seu amigo.");
		form.amigo.focus();
		return false;
	}
	if ( form.email_amigo.value == "" ) {
		alert("Por favor, digite o e-mail do seu amigo.");
		form.email_amigo.focus();
		return false;
	}
	if ( !valida_mail(form.email_amigo.value) ) {
		alert("Por favor, um e-mail válido, para o seu amigo.");
		form.email_amigo.focus();
		return false;
	}
	return true;
}

function valida_mail(valor) {
	prim = valor.indexOf("@")
	if(prim < 1) return false;
	if(valor.indexOf("@",prim + 1) != -1) return false
	if(valor.indexOf(".") < 1) return false;
	if(valor.indexOf("zipmeil.com") > 0) return false;
	if(valor.indexOf("hotmeil.com") > 0) return false;
	if(valor.indexOf(".@") > 0) return false;
	if(valor.indexOf("@.") > 0) return false;
	if(valor.indexOf(".com.br.") > 0) return false;
	if(valor.indexOf("/") > 0) return false;
	if(valor.indexOf("[") > 0) return false;
	if(valor.indexOf("]") > 0) return false;
	if(valor.indexOf("(") > 0) return false;
	if(valor.indexOf(")") > 0) return false;
	if(valor.indexOf("..") > 0) return false;
	if(valor.indexOf(",") > 0) return false;
	return true;

}

function valida_newsletter(form) {
	if ( form.nome.value == "" ) {
		alert("Por favor, digite o seu nome.");
		form.nome.focus();
		return false;
	}
	if ( form.email.value == "" ) {
		alert("Por favor, digite o seu e-mail.");
		form.email.focus();
		return false;
	}
	if ( !valida_mail(form.email.value) ) {
		alert("Por favor, um e-mail válido.");
		form.email.focus();
		return false;
	}
	if ( form.acao.value == "" ) {
		alert("Por favor, informe se você quer inscrever ou sair.");
		form.acao.focus();
		return false;
	}
	NewWindow('send_news.asp?Nome='+form.nome.value+'&Email='+form.email.value+'&Acao='+form.acao.value,'popNews','200','302','no');	
	form.nome.value = "";
	form.email.value = "";
	form.acao.selectedIndex = 0;
	return false;
}

function valida_fale( form1 ) {
	if ( form1.nome.value == "" ) {
		alert("Por favor, digite o seu nome.");
		form1.nome.focus();
		return false;
	}/*
	if ( form1.retorno.value == "" ) {
		alert("Por favor, escolha a forma de retorno.");
		return false;
	}*/
	if ( form1.email.value == "" ) {
		alert("Por favor, digite o seu e-mail para retorno.");
		form1.email.focus();
		return false;
	}
	if ( !valida_mail(form1.email.value) ) {
		alert("Por favor, um e-mail.");
		form1.email.focus();
		return false;
	}/*
	if ( form1.retorno.value == "por telefone" && form1.telefone.value == "" ) {
		alert("Por favor, digite o seu telefone para retorno.");
		form1.telefone.focus();
		return false;
	}*/
	if ( form1.comentario.value == "" ) {
		alert("Por favor, digite o comentário.");
		form1.comentario.focus();
		return false;
	}
	return true;
}

function valida_cadastro( form ) {
	if ( form.nome.value == "" ) {
		alert("Por favor, digite o seu nome.");
		form.nome.focus();
		return false;
	}
	if ( form.email.value == "" ) {
		alert("Por favor, digite o seu e-mail.");
		form.email.focus();
		return false;
	}
	if ( !valida_mail(form.email.value) ) {
		alert("Por favor, um e-mail válido.");
		form.email.focus();
		return false;
	}
	if ( form.ddd.value == "" ) {
		alert("Por favor, digite o ddd do seu telefone.");
		form.ddd.focus();
		return false;
	}
	if ( form.telefone.value == "" ) {
		alert("Por favor, digite o seu telefone.");
		form.telefone.focus();
		return false;
	}
	if (form.sexo.value=="") {
		alert("Por favor, informe o seu sexo.");
		form.sexo.focus();
		return false;
	}
	if (form.nascimento.value=="") {
		alert("Por favor, digite a sua data de nascimento.");
		form.nascimento.focus();
		return false;
	}
	if ( !ValidaData(form.nascimento.value)) {
		alert("Por favor, coloque uma data válida para a sua data de nascimento. (ex 02/12/2001)");
		form.nascimento.focus();
		return false;
	}
	var flag_preferencia = true;
	var flag_preferencia_outros = false;

	if ( form.item('preferencia').length > 1 ) {
		for (var i = 0 ; i < form.item('preferencia').length ; i++) {
			if (form.item('preferencia')[i].checked == true) {
				flag_preferencia = false;
				if (i==14)
					flag_preferencia_outros = true;
			}
		}
	}
	else {
		if (form.item('preferencia').checked == true)
			flag_preferencia = false;
		if (form.item('preferencia').value == "15")
			flag_preferencia_outros = true;
	}
	
	
	if( flag_preferencia ){
		alert("Por favor, escolha pelo menos uma preferência.");
		form.preferencia[0].focus();
		return false;
	}
	
	if( flag_preferencia_outros && form.outras.value=="" ){
		alert("Por favor, especifique as outras preferência.");
		form.outras.focus();
		return false;
	}
	if (form.cidade.value==""){
		alert("Por favor, digite a cidade.");
		form.cidade.focus();
		return false;
	}
	if (form.estado.value==""){
		alert("Por favor, informe o estado.");
		form.estado.focus();
		return false;
	}
	return true;
}


function FormataData(campo, event) {
	var posNumeros = "01346789";
	var posEspacos = "25";
	var strNumeros = '0123456789';

	if ((event.keyCode == 8) || (event.keyCode == 46))
		return false;

	for (i = 0; i < campo.value.length; i++)
		if ((posNumeros.indexOf(i) != -1) && (strNumeros.indexOf(campo.value.substr(i, 1)) == -1)) {
			campo.value = campo.value.substr(0, i);
			return false;
		} else if ((posEspacos.indexOf(i) != -1) && (campo.value.substr(i, 1) != '/')) {
			campo.value = campo.value.substr(0, i);
			return false;
	}

	if (campo.value.length > 10)
		campo.value = campo.value.substr(0, 10);

	if ((campo.value.length == 2) || (campo.value.length == 5))
		campo.value = campo.value + "/";
}

function ValidaData(valor) {
	if (valor.length == 0)
		return true;
	else if (valor.length != 10)
		return false;

	var dia = valor.substr(0, 2);
	var mes = valor.substr(3, 2);
	var ano = valor.substr(6, 4);

	if (!ValidaInteiro(dia)) return false;
	if (!ValidaInteiro(mes)) return false;
	if (!ValidaInteiro(ano)) return false;

	if (mes > 12 || mes < 1) return false;
	if (dia < 1) return false;
	if (ano < 1) return false;
	if ((mes == 1 || mes == 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12) && dia > 31) return false;
	if ((mes == 4 || mes == 6 || mes == 9 || mes == 11) && dia > 30) return false;
	if (mes == 2 && ano % 4 && dia > 29) return false;
	if (mes == 2 && !(ano % 4) != 0 && dia > 28) return false;
	return true;
}

function FormataInteiro(campo, event) {
	var strNumeros = '0123456789';

	for (i = 0; i < campo.value.length; i++)
		if ((strNumeros.indexOf(campo.value.substr(i, 1)) == -1) && !((i == 0) && (campo.value.substr(i, 1) == '-'))) {
			campo.value = campo.value.substr(0, i);
			return false;
		}
}

function ValidaInteiro(valor) {
	var strNumeros = '0123456789';

	for (i = 0; i < valor.length; i++)
		if ((strNumeros.indexOf(valor.substr(i, 1)) == -1) && !((i == 0) && (valor.substr(i, 1) == '-')))
				return false;
	return true;
}

function valida_cadastro_aniversario(form){
	if (form.nome.value==""){
		alert("Por favor, digite seu nome");
		form.nome.focus();
		return false;
	}
	if (form.sobrenome.value==""){
		alert("Por favor, digite seu sobrenome");
		form.sobrenome.focus();
		return false;
	}
	if (form.apelido.value==""){
		alert("Por favor, digite como deseja ser chamado(a)");
		form.apelido.focus();
		return false;
	}
	if (form.email.value==""){
		alert("Por favor, digite seu e-mail");
		form.email.focus();
		return false;
	}
	if (!valida_mail(form.email.value)){
		alert("Por favor, digite um email válido.");
		form.email.focus();
		return false;
	}
	if (form.senha.value=="" || form.senha.length<6){
		alert("Por favor, digite sua senha.");
		form.senha.focus();
		return false;
	}
	if (form.senha.value!=form.repete_senha.value){
		alert("Por favor, digite sua senha corretamente.");
		form.repete_senha.value='';
		form.repete_senha.focus();
		return false;
	}
	if (form.sexo.value==""){
		alert("Por favor, escolha o seu sexo.");
		form.sexo.focus();
		return false;
	}
	if (form.cpf.value==""){
		alert("Por favor, digite sua identidade.");
		form.cpf.focus();
		return false;
	}
	if (form.nascimento.value==""){
		alert("Por favor, digite sua data de nascimento.");
		form.nascimento.focus();
		return false;
	}
	if (!ValidaData(form.nascimento.value)){
		alert("Por favor, digite uma data de nascimento válida.");
		form.nascimento.value='';
		form.nascimento.focus();
		return false;
	}
	if (form.endereco.value==""){
		alert("Por favor, digite seu endereco.");
		form.endereco.focus();
		return false;
	}
	if (form.cep.value==""){
		alert("Por favor, digite seu CEP.");
		form.cep.focus();
		return false;
	}
	if (form.bairro.value==""){
		alert("Por favor, digite seu bairro.");
		form.bairro.focus();
		return false;
	}
	if (form.numero.value==""){
		alert("Por favor, digite seu numero.");
		form.numero.focus();
		return false;
	}

	if (form.tel.value==""){
		alert("Por favor, digite seu telefone.");
		form.tel.focus();
		return false;
	}
	if (form.cidade.value==""){
		alert("Por favor, digite sua cidade.");
		form.cidade.focus();
		return false;
	}
	if (form.uf.value==""){
		alert("Por favor, escolha seu estado.");
		form.uf.focus();
		return false;
	}
	if (form.visitas.value==""){
		alert("Por favor, escolha quantas vezes ja foi ao Marista Hall.");
		form.visitas.focus();
		return false;
	}
	var flag_preferencia = true;
	var flag_preferencia_outros = false;

	if ( form.preferencia.length > 1 ) {
		for (var i = 0 ; i < form.preferencia.length ; i++) {
			if (form.preferencia[i].checked == true) {
				flag_preferencia = false;
				if (i==14)
					flag_preferencia_outros = true;
			}
		}
	}
	else {
		if (form.preferencia.checked == true)
			flag_preferencia = false;
		if (form.preferencia.value == "15")
			flag_preferencia_outros = true;
	}
	
	
	if( flag_preferencia){
		alert("Por favor, escolha pelo menos uma preferência.");
		form.preferencia[0].focus();
		return false;
	}
	
	if( flag_preferencia_outros && form.outras.value=="" ){
		alert("Por favor, especifique as outras preferência.");
		form.outras.focus();
		return false;
	}

	if (form.qual.value==""){
		alert("Por favor, digite qual espaço de eventos, shows e cultura que completa 01 ano.");
		form.qual.focus();
		return false;
	}
	if (form.renda.value==""){
		alert("Por favor, selecione qual a faixa de renda da sua família.");
		form.renda.focus();
		return false;
	}
	if (form.news.checked != true){
		alert("Por favor, selecione a opção que aceita receber informações e promoções do Marista Hal.");
		form.news.focus();
		return false;
	}
	return true;
}

function valida_cadastro_aniversario_email(form){
	if (form.email.value==""){
		alert("Por favor, digite seu e-mail");
		form.email.focus();
		return false;
	}
	if (!valida_mail(form.email.value)){
		alert("Por favor, digite um email válido.");
		form.email.focus();
		return false;
	}
}

function valida_login_aniversario(form){
	if (form.email.value==""){
		alert("Por favor, digite seu email.");
		form.email.focus();
		return false;
	}
	if (!valida_mail(form.email.value)){
		alert("Por favor, digite um email válido.");
		form.email.focus();
		return false;
	}
	if (form.senha.value==""){
		alert("Por favor, digite sua senha.");
		form.senha.focus();
		return false;
	}
//	alert("ok");
	return true;
}

function valida_indique_aniversario(form){
	if (form.nome.value==""){
		alert("Por favor, digite o nome do seu amigo.");
		form.nome.focus();
		return false;
	}
	if (form.email.value==""){
		alert("Por favor, digite seu email.");
		form.email.focus();
		return false;
	}
	if (!valida_mail(form.email.value)){
		alert("Por favor, digite um email válido.");
		form.email.focus();
		return false;
	}

	return true;
}

function valida_indique_aniversario_varios(form){
	if (form.indicar.checked==false){
		for (i=0;i<form.nome.length ;i++ ){
			if (form.nome[i].value!="" && form.email[i].value!=""){
				if (!valida_mail(form.email[i].value)){
					alert("Por favor, digite um email válido.");
					form.email[i].focus();
					return false;
				}else{
					return true;
				}
			}
		}
		alert("Por favor, digite o nome e o email de algum amigo.");
		return false;
	}else{
		return true;
	}
}

checkTAB=true;
function SHOW(quem, tammax) {
 if ( (quem.value.length == tammax) && (checkTAB) ) {
  var i=0,j=0, indice=-1;
  for (i=0; i<document.forms.length; i++) {
   for (j=0; j<document.forms[i].elements.length; j++) {
    if (document.forms[i].elements[j].name == quem.name) {
     indice=i;
     break;
    }
   }
   if (indice != -1)
           break;
  }
  for (i=0; i<=document.forms[indice].elements.length; i++) {
   if (document.forms[indice].elements[i].name == quem.name) {
    while ( (document.forms[indice].elements[(i+1)].type == "hidden") &&
      (i < document.forms[indice].elements.length) ) {
       i++;
    }
    document.forms[indice].elements[(i+1)].focus();
    checkTAB=false;
    break;
   }
  }
 }
}


function breakTAB(quem)
{
   checkTAB=false;
}


function verifTAB()
{
   checkTAB=true;
}

function esqueci(form){
	if (form.email.value==""){
		alert("Por favor, digite seu email.");
		form.email.focus();
	}else{
		if (!valida_mail(form.email.value)){
			alert("Por favor, digite um email válido.");
			form.email.focus();
		}else{
			if (confirm("Você receberá sua senha no seu email.")){
				form.action = "esqueci.asp";
				form.submit();
			}
		}
	}
}

function out(v_acao) {
//	alert(v_acao);
	if (v_acao == "Sim"){
		MM_swapImage('check','','img/bt_ckeck02.gif',1);
	}else{
		MM_swapImgRestore();
	}
}

function popup(URL,w,h,nome) {
	largura = w;
	altura = h;
	X = (screen.availWidth - largura) / 2;
//	X = "0";
	Y = (screen.availHeight - altura) / 2;
//	Y = "0";
		window.open(URL,nome,'width=' + largura + ',height=' + altura + ',top=' + Y + ',left=' + X + ',screenX=' + X + ',screenY=' + Y );
}
function popup_regulamento(URL,w,h,nome) {
	largura = w;
	altura = h;
	X = (screen.availWidth - largura) / 2;
//	X = "0";
	Y = (screen.availHeight - altura) / 2;
//	Y = "0";
		window.open(URL,nome,'scrollbars=1,width=' + largura + ',height=' + altura + ',top=' + Y + ',left=' + X + ',screenX=' + X + ',screenY=' + Y );
}
function validaCPF_CNPJ(campo) {
 
AuxCPFCGC = campo.value;
var checkOK = "0123456789";

if (campo.value == "" || campo.value == null ){
	return true;
}
 
 if (AuxCPFCGC.length != 11 && AuxCPFCGC.length != 14)
  {
    alert("CNPJ deve conter 14 dígitos! CPF deve ter 11 dígitos!");
    campo.focus();
    return(false);
  }
 
  for (i = 1; i <= AuxCPFCGC.length ; i++) 
  {
    if (AuxCPFCGC.substring(i-1,i) == " ")
    {
      campo.focus();   
      alert("O campo CPF/CNPJ não pode conter espaços!");
      return(false);
    }
  }

var checkStr = AuxCPFCGC;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    allNum += ch;
  }
  if (!allValid)
  {
    alert("O CPF/CNPJ deve conter apenas números.");
    campo.focus();
    return(false);
  }
 
  if (AuxCPFCGC.length == 11)
  {
    if (!CPF_OK(AuxCPFCGC))
    {
      campo.focus();
      alert("Número de CPF testado e entendido como inválido!");
      return(false);
    }
 if (AuxCPFCGC == '99999999999')
    {
      campo.focus();
      alert("Número de CPF testado e entendido como inválido!");
      return(false);
    }
  }
  else if(AuxCPFCGC.length == 14)
  { 
    if (!CGC_OK(AuxCPFCGC))
    {
      campo.focus();
      alert("Número de CNPJ testado e entendido como inválido!");
      return(false);
    }
  }
top.validacpf.location = "validaemail.asp?cpf="+campo.value;
//alert("passo");
return(true);
}


function CPF_OK(Numero_CPF) 
{
  var Parcela;
  var Quociente;
  var Resto;
  var Soma;
  var Fator;
  var I;
  var C1;
  var C2;
  var dv1;
  var dv2;
    
  //Verificação dos dois digitos finais em relação ao número completo
  C1 = parseInt(Numero_CPF.substring(9, 10));  //10º caracter = primeiro dígito verificador
  C2 = parseInt(Numero_CPF.substring(10, 11)); //11º caracter = segundo dígito verificador
    
  //Verificação do primeiro dígito (C1)
  Soma = 0;
  Parcela = 0;
  Fator = 0;
 
  for(I=1; I<=9; I++)
  {
    Fator = I + 1;
 
    Parcela = Fator * parseInt(Numero_CPF.substring(9 - I, 9 - I + 1));
    Soma = Soma + Parcela;
  } //fechando o "for".
    
  dv1 = (Soma % 11); 
  dv1 = 11 - dv1;
 
  if(dv1 >9 )
  {
    dv1 = 0;
  }
    
  if(C1 != dv1)
  {
    return false;
  }
    
  //Verificação do segundo dígito (C2)
  Soma = 0;
  Parcela = 0;
  Fator = 0;
 
  for(I=1; I<=10; I++)
  {
    Fator = I + 1;
  
    Parcela = Fator * parseInt(Numero_CPF.substring(10 - I, 10 - I + 1));
    Soma = Soma + Parcela;
  }
  
  dv2 = (Soma % 11);
  dv2 = 11 - dv2;
  
  if(dv2 > 9)
  {
    dv2 = 0;
  }
 
  if(C2 != dv2)
  {
    return false;
  }
return true;
}

function CGC_OK(Numero_CGC) 
{
  var Parcela;
  var Quociente;
  var Resto;
  var Soma;
  var Fator;
  var I;
  var C1;
  var C2;
  var dv1;
  var dv2;
    
  //Verificação dos dois digitos finais em relação ao número completo
  C1 = parseInt(Numero_CGC.substring(12, 13));  //13º caracter = primeiro dígito verificador
  C2 = parseInt(Numero_CGC.substring(13, 14));  //14º caracter = segundo dígito verificador
    
  //Verificação do primeiro dígito (C1)
  Soma = 0;
  Parcela = 0;
  Fator = 0;
 
  for(I=1; I<=12; I++)
  {
    if(I < 9)
    {
      Fator = I + 1;
 }
 else
 {
      Fator = I - 7;
    }
 
    Parcela = Fator * parseInt(Numero_CGC.substring(12 - I, 12 - I + 1));
    Soma = Soma + Parcela;
  } //fechando o "for".
    
  dv1 = (Soma % 11); 
  dv1 = 11 - dv1;
 
  if(dv1 > 9)
  {
    dv1 = 0;
  }
    
  if(C1 != dv1)
  {
    return false;
  }
    
  //Verificação do segundo dígito (C2)
  Soma = 0;
  Parcela = 0;
  Fator = 0;
 
  for(I=1; I<=13; I++)
  {
     if(I < 9)
     {
        Fator = I + 1;
     }   
     else
     {
       Fator = I - 7;
     }   
     Parcela = Fator * parseInt(Numero_CGC.substring(13 - I, 13 - I + 1));
     Soma = Soma + Parcela;
  }
  
  dv2 = (Soma % 11);
  dv2 = 11 - dv2;
  
  if(dv2 > 9)
  {
    dv2 = 0;
  }
 
  if(C2 != dv2)
  {
    return false;
  }
return true;
} 
function Valida_Saida(funcao,alerta,campo){
	if(campo.value!="" && campo.value != null ){
		if(!funcao){
			if (alerta!=""){
				alert(alerta);
			}
			campo.value = "";
			campo.focus();
			return true;
		}else{
			return true;
		}
	}else{
		return true;
	}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function popupganhadores(url)
{
janela=window.open(url,'popupganhadores','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=418,height=343,top=20,left=60')
}
function popupregulamento(url)
{
janela=window.open(url,'popupregulamento','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=400,top=60,left=60')
}
function orichas(url)
{
janela=window.open(url,'orichas','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=315,height=233,top=260,left=260')
}
function clipjotaquest(url)
{
janela=window.open(url,'clipjotaquest','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=500,height=251,top=260,left=260')
}
function imprime(url)
{
janela=window.open(url,'imprime','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=417,height=300,top=60,left=60')
}