﻿// MENU
function menu(){
	var dropDown = document.getElementById('menu_dropdown').getElementsByTagName('li');
		for (var i=0; i< dropDown.length; i++){
			if(dropDown[i].className=='submenu'){
				if(dropDown[i].getElementsByTagName('ul')[0] != null){
					dropDown[i].onmouseover=function(){
						this.getElementsByTagName('ul')[0].style.display='block';this.style.backgroundColor='#def';
					}
					dropDown[i].onmouseout=function(){
						this.getElementsByTagName('ul')[0].style.display='none';this.style.backgroundColor='#6699ff';
					}
				}
			}
		}
}  
// this function is need to work around 
// a bug in IE related to element attributes
function hasClass(obj) {
	var result = false;
	if (obj.getAttributeNode("class") != null) {
		result = obj.getAttributeNode("class").value;
	}
	return result;
}

function stripe(id) {

	// the flag we'll use to keep track of 
	// whether the current row is odd or even
	var even = false;

	// if arguments are provided to specify the colours
	// of the even & odd rows, then use the them;
	// otherwise use the following defaults:
	var evenColor = arguments[1] ? arguments[1] : "#fff";
	var oddColor = arguments[2] ? arguments[2] : "#eee";

	// obtain a reference to the desired table
	// if no such table exists, abort
	var table = document.getElementById(id);
	if (! table) { return; }

	// by definition, tables can have more than one tbody
	// element, so we'll have to get the list of child
	// &lt;tbody&gt;s 
	var tbodies = table.getElementsByTagName("tbody");

	// and iterate through them...
	for (var h = 0; h < tbodies.length; h++) {

		// find all the &lt;tr&gt; elements... 
		var trs = tbodies[h].getElementsByTagName("tr");

		// ... and iterate through them
		for (var i = 0; i < trs.length; i++) {

			// avoid rows that have a class attribute
			// or backgroundColor style
			if (!hasClass(trs[i]) && ! trs[i].style.backgroundColor) {

				// get all the cells in this row...
				var tds = trs[i].getElementsByTagName("td");

				// and iterate through them...
					for (var j = 0; j < tds.length; j++) {

					var mytd = tds[j];

					// avoid cells that have a class attribute
					// or backgroundColor style
					if (! hasClass(mytd) && ! mytd.style.backgroundColor) {

						mytd.style.backgroundColor = even ? evenColor : oddColor;

					}
				}
			}
			// flip from odd to even, or vice-versa
			even =  ! even;
		}
	}
}
// CONFIRMA SENHA
function ConfirmaSenha() {
	if(document.cadastro.senha.value != document.cadastro.confirma.value){
	   alert("As duas senhas não estão iguais. Tente novamente.");
	   document.cadastro.senha.value="";
	   document.cadastro.confirma.value="";
	   document.cadastro.senha.focus();
	}
}
		   
// VALIDA CADASTRO DE TORCEDORES
function validaTorcedores(){
	mensagem = null;
	errado  = 0;

	nome  = document.cadastro.nome.value;
	senha  = document.cadastro.senha.value;
	confirma  = document.cadastro.confirma.value;
	end  = document.cadastro.end.value;
	num  = document.cadastro.num.value;
	bairro  = document.cadastro.bairro.value;
	cidade  = document.cadastro.cidade.value;
	estado  = document.cadastro.estado.value;
	cep  = document.cadastro.cep.value;
	tel  = document.cadastro.tel.value;
	cel  = document.cadastro.cel.value;
	email  = document.cadastro.email.value;
	cpf  = document.cadastro.cpf.value;
	nascimento  = document.cadastro.nascimento.value;
	sexo  = document.cadastro.sexo.value;
	prof  = document.cadastro.prof.value;

	if(nome == ''){
		mensagem = 'Ocorreu um erro: O Nome não foi informado!';
		errado  = 1;
		cadastro.nome.focus();
		return false;
	}
	if(senha == ''){
		mensagem = 'Ocorreu um erro: A Senha não foi informada!';
		errado  = 1;
		cadastro.senha.focus();
		return false;
	}
	if(confirma == ''){
		mensagem = 'Ocorreu um erro: A Confirmação de Senha esta em branco!';
		errado  = 1;
		cadastro.confirma.focus();
		return false;
	}
	if(end == ''){
		mensagem = 'Ocorreu um erro: O Endereço não foi informado!';
		errado  = 1;
		cadastro.end.focus();
		return false;
	}
	if(num == ''){
		mensagem = 'Ocorreu um erro: O Número não foi informado!';
		errado  = 1;
		cadastro.num.focus();
		return false;
	}
	if(bairro == ''){
		mensagem = 'Ocorreu um erro: O Bairro não foi informado!';
		errado  = 1;
		cadastro.bairro.focus();
		return false;
	}
	if(cidade == ''){
		mensagem = 'Ocorreu um erro: A Cidade não foi informado!';
		errado  = 1;
		cadastro.cidade.focus();
		return false;
	}
	if(estado == ''){
		mensagem = 'Ocorreu um erro: O Estado não foi informado!';
		errado  = 1;
		cadastro.estado.focus();
		return false;
	}
	if(cep == ''){
		mensagem = 'Ocorreu um erro: O CEP não foi informado!';
		errado  = 1;
		cadastro.cep.focus();
		return false;
	}
	if(tel == ''){
		mensagem = 'Ocorreu um erro: O Tel não foi informado!';
		errado  = 1;
		cadastro.tel.focus();
		return false;
	}
	if(cel == ''){
		mensagem = 'Ocorreu um erro: O Cel não foi informado!';
		errado  = 1;
		cadastro.cel.focus();
		return false;
	}
	if(email == ''){
		mensagem = 'Ocorreu um erro: O E-mail não foi informado!';
		errado  = 1;
		cadastro.email.focus();
		return false;
	}
	if(cpf == ''){
		mensagem = 'Ocorreu um erro: O CPF não foi informado!';
		errado  = 1;
		cadastro.cpf.focus();
		return false;
	}
	if(nascimento == ''){
		mensagem = 'Ocorreu um erro: A Data de Nascimento não foi informado!';
		errado  = 1;
		cadastro.nascimento.focus();
		return false;
	}
	if(sexo == ''){
		mensagem = 'Ocorreu um erro: O Sexo não foi informado!';
		errado  = 1;
		cadastro.sexo.focus();
		return false;
	}
	if(prof == ''){
		mensagem = 'Ocorreu um erro: A Profissão não foi informado!';
		errado  = 1;
		cadastro.prof.focus();
		return false;
	}
	if(senha !== confirma){
		mensagem = 'Ocorreu um erro: A senha não confere!';
		errado  = 1;
		cadastro.senha.value   = "";
		cadastro.confirma.value = "";
		cadastro.senha.focus();
		return false;
	}
	if(errado == 1){
		alert(mensagem);
		return false;
	}else{
		return true;
	}
}

// VALIDA MASCOTINHO
function validaMascotinho(){
	mensagem = null;
	errado  = 0;

	nomefilho  = document.cadmasc.nomefilho.value;
	nomepai  = document.cadmasc.nomepai.value;
	nomemae  = document.cadmasc.nomemae.value;
	rgfilho  = document.cadmasc.rgfilho.value;
	rgpai  = document.cadmasc.rgpai.value;
	rgmae  = document.cadmasc.rgmae.value;
	nascimento  = document.cadmasc.nascimento.value;
	tel  = document.cadmasc.tel.value;
	email  = document.cadmasc.email.value;
	
	if(nomefilho == ''){
		mensagem = 'Ocorreu um erro: O nome da criança não foi informado!';
		errado  = 1;
		cadmasc.nomefilho.focus();
		return false;
	}
	if(nomepai == ''){
		mensagem = 'Ocorreu um erro: A nome do pai não foi informada!';
		errado  = 1;
		cadmasc.nomepai.focus();
		return false;
	}
	if(nomemae == ''){
		mensagem = 'Ocorreu um erro: A nome da mãe não foi informada!';
		errado  = 1;
		cadmasc.confirma.focus();
		return false;
	}
	if(rgfilho == ''){
		mensagem = 'Ocorreu um erro: O RG da criança não foi informado!';
		errado  = 1;
		cadmasc.rgfilho.focus();
		return false;
	}
	if(rgpai == ''){
		mensagem = 'Ocorreu um erro: O RG do pai não foi informado!';
		errado  = 1;
		cadmasc.rgpai.focus();
		return false;
	}
	if(rgmae == ''){
		mensagem = 'Ocorreu um erro: O RG da mãe não foi informado!';
		errado  = 1;
		cadmasc.rgmae.focus();
		return false;
	}
	if(nascimento == ''){
		mensagem = 'Ocorreu um erro: A data de nascimento não foi informado!';
		errado  = 1;
		cadmasc.nascimento.focus();
		return false;
	}
	if(tel == ''){
		mensagem = 'Ocorreu um erro: A telefone não foi informado!';
		errado  = 1;
		cadmasc.tel.focus();
		return false;
	}
	if(email == ''){
		mensagem = 'Ocorreu um erro: O E-mail não foi informado!';
		errado  = 1;
		cadmasc.email.focus();
		return false;
	}
	if(errado == 1){
		alert(mensagem);
		return false;
	}else{
		return true;
		document.getElementById('pop').style.display='none';
	}
}