function ignoreSpaces(string) {
var temp = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
temp += splitstring[i];
return temp;
}



// Capslock

function checkCapsLock( e ) {
	var myKeyCode=0;
	var myShiftKey=false;
	var myMsg='A tecla "CapsLock" (ou "Fixa") está habilitada.\n\nDesabilite-a para digitar seu login e senha em\nletras minúsculas e evitar erros de acesso.';

	// Internet Explorer 4+
	if ( document.all ) {
		myKeyCode=e.keyCode;
		myShiftKey=e.shiftKey;

	// Netscape 4
	} else if ( document.layers ) {
		myKeyCode=e.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	// Netscape 6
	} else if ( document.getElementById ) {
		myKeyCode=e.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	}

	// Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on
	if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
		alert( myMsg );

	// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on
	} else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
		alert( myMsg );

	}
}


// Funções do formulário de Contato
function IsSpace(field) {
	ic_spaces = false;
	for (pos = 0;pos < field.length;pos ++)
		if (field.charAt(pos) != " ")
			ic_spaces = true;

	if (!ic_spaces)
		return true;

	return false;
}


function validaEmail(email) {
	invalidChars = " /:,;"

	if (email == "") {						// preenchido
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	// caracteres válidos
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// "@"
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// 1 "@"
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					//  "." após "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// 2 caracteres após "."
		return false
	}
	return true
}

function ConsistefrmCadastro() {

if (IsSpace(document.frmCadastro.nome.value)) {
		alert("Informe seu nome");
		document.frmCadastro.nome.focus();
		return false;
	}

	sexoOption = -1
			for (i=0; i<frmCadastro.sexo.length; i++) {
				if (frmCadastro.sexo[i].checked) {
					sexoOption = i
				}
			}
			if (sexoOption == -1) {
				alert("Por favor, informe seu sexo")
				return false
			}


	escolherDia = frmCadastro.dia_nascimento.selectedIndex
		if (frmCadastro.dia_nascimento.options[escolherDia].value == "") {
		alert("Você precisa informar o dia do seu nascimento.")
		return false
			}
			
	escolherMes = frmCadastro.mes_nascimento.selectedIndex
		if (frmCadastro.mes_nascimento.options[escolherMes].value == "") {
		alert("Você precisa informar o mês em que nasceu.")
		return false
			}


	
if (IsSpace(document.frmCadastro.endereco.value)) {
		alert("Informe seu endereço residencial: rua, número e bairro");
		document.frmCadastro.endereco.focus();
		return false;
	}    
    
	if (IsSpace(document.frmCadastro.cidade.value)) {
		alert("Informe a cidade onde você mora");
		document.frmCadastro.cidade.focus();
		return false;
	}

    
    escolherEstado = frmCadastro.estado.selectedIndex
if (frmCadastro.pais.value == "Brasil" && frmCadastro.estado.options[escolherEstado].value == "") {
				alert("Você precisa indicar o estado aonde mora")

				return false
			}
	


	if (IsSpace(document.frmCadastro.cep.value)) {
		alert("Informe seu código postal");
		document.frmCadastro.cep.focus();
		return false;
	}
    
    if (IsSpace(document.frmCadastro.ddd.value)) {
		alert("Informe seu telefone");
		document.frmCadastro.ddd.focus();
		return false;
	}    
     
	if (IsSpace(document.frmCadastro.tel.value)) {
		alert("Informe seu telefone");
		document.frmCadastro.tel.focus();
		return false;
	}     
        
    
	if (!validaEmail(document.frmCadastro.email.value)) {
		alert("Você precisa digitar um e-mail válido.")
		document.frmCadastro.email.focus();
		return false
	}
    
    	if (IsSpace(document.frmCadastro.profissao.value)) {
		alert("Informe sua profissão");
		document.frmCadastro.profissao.focus();
		return false;
	}     

	if (IsSpace(document.frmCadastro.login.value)) {
		alert("Escolha seu nome de usuário.");
		document.frmCadastro.loginname.focus();
		return false;
	}	

	if (IsSpace(document.frmCadastro.password1.value)) {
		alert("Escolha uma senha.");
		document.frmCadastro.password1.focus();
		return false;
	}	

	if (IsSpace(document.frmCadastro.password2.value)) {
		alert("Favor confirmar sua senha.");
		document.frmCadastro.password2.focus();
		return false;
	}	
	



if (frmCadastro.agree.checked == "") {
		alert("Você está de acordo com o Estatudo da ABPC?");
		document.frmCadastro.agree.focus();
		return false;
	}
				

						
			
	return true;
}
