jQuery(function($){
$("#data").mask("99/99/9999");
$("#telefone").mask("(99) 9999-9999");
$("#telefone2").mask("(99) 9999-9999");
$("#celular").mask("99-9999999");
$("#ano").mask("9999");
$("#formato").mask("99x99");
});

function mail() {
	if (document.getElementById('mail_usu').value.indexOf("@",0) == -1){
		document.getElementById('mail_usu').style.backgroundColor = '#FFFF00';
		document.getElementById('mail_invalido').style.display = 'block';
    }
	else
	{
		document.getElementById('mail_usu').style.backgroundColor = '#FFFFFF';
		document.getElementById('mail_invalido').style.display = 'none';
	}
}

function outros() {

	var chk = document.getElementById('chkoutros');
	var txtoutros = document.getElementById('txtoutros');
	
	if (chk.checked) {
		txtoutros.readOnly = false;
		txtoutros.style.backgroundColor = '#FFFFFF';
		txtoutros.value = 'DIGITE AQUI SEU INTERESSE';
		quantidade = 1;
		}
		else
		{
		txtoutros.readOnly = true;
		txtoutros.style.backgroundColor = '#CCCCCC';
		txtoutros.value = "";
		}
}

var quantidade = 1;

function limpar() {
	var txtoutros = document.getElementById('txtoutros');
	
	if (quantidade == 1) {
		txtoutros.value = "";
		quantidade = 2;
		}
}

function validareg() {
	var nome = document.getElementById('nome_usu');
	var senha = document.getElementById('senha_usu');
	var mail = document.getElementById('mail_usu');
	var data = document.getElementById('data');
	var estados = document.getElementById('estados_usu');
	var cidades = document.getElementById('cidades_usu');
	var profissao = document.getElementById('profissao_usu');
	var termos = document.getElementById('termos');
	
	if (nome.value == "") {
		window.alert("O campo Usuário não foi preenchido");
		nome.focus();
		return false;
	}
	
	if (senha.value == "") {
		window.alert("O campo Senha não foi preenchido");
		senha.focus();
		return false;
	}
	
	if (mail.value.indexOf("@",0) == -1){
		window.alert("E-Mail inválido");
		mail.focus();
		return false;
    }
	
	if (mail.value == "") {
		window.alert("O campo E-Mail não foi preenchido");
		mail.focus();
		return false;
	}
	
	if (data.value == "") {
		window.alert("O campo Data de Nascimento não foi preenchido");
		data.focus();
		return false;
	}
	
	if (estados.value == "0") {
		window.alert("Você deve escolher um Estado");
		estados.focus();
		return false;
	}
	
	if (cidades.value == "0") {
		window.alert("Você deve escolher uma Cidade");
		cidades.focus();
		return false;
	}
	
	if (profissao.value == "0") {
		window.alert("Você deve escolher uma Profissão");
		profissao.focus();
		return false;
	}
	
	if (termos.checked) {
	}
	else
	{
		termos.focus();
		return false;
	}
}

function validartexto() {
	var texto = document.getElementById('txtcomentario');
	
	if (texto.value == "") {
		window.alert("O comentário está vazio");
		texto.focus();
		return false;
	}
}

var contador = 0;
var min = 0;
var hour = 0;

function conta() {
//Essas variáveis modificam as propriedades de qquer objeto html, assim como cria objetos html
//document.getElementById('segundo').innerHTML=segundo;
//document.getElementById('minuto').innerHTML=minuto_final;
//document.getElementById('hora').innerHTML=hour_final;

	if (contador !=60){
		if (contador < 9) {
		contador = contador+1;
		document.getElementById('segundo').value = "0" + contador;
		setTimeout("conta()", 1000);
		}
		else
		{
		contador = contador+1;
		document.getElementById('segundo').value = contador;
		setTimeout("conta()", 1000);
		}
	}
	else
	{
		contador = 0;
		
		if (min < 9) {
		min = min + 1;
		document.getElementById('minuto').value = "0" + min;
		}
		else
		{
		min = min + 1;
		document.getElementById('minuto').value = min;
		}
		
		if (min == 60) {
			if (hour < 9) {
			hour = hour + 1;
			document.getElementById('hora').value = "0" + hour;
			min = 0;
			}
			else
			{
			hour = hour + 1;
			document.getElementById('hora').value = hour;
			min = 0;
			}
		}
		setTimeout("conta()", 1000);
	}		
}

/*var variavalores = 0;

function conta_update() {
	if (variavalores == 0) {
		var segnovo = document.getElementById('segundo').value;
		var minnovo = document.getElementById('minuto').value;
		var hornovo = document.getElementById('hora').value;
		var segundo = parseInt(segnovo);
		var minuto = parseInt(minnovo);
		var hora = parseInt(hornovo);
	}
	
	if (segundo !=60){
		if (segundo < 9) {
		segundo = segundo+1;
		document.getElementById('segundo').value = "0" + segundo;
		setTimeout("conta_update()", 1);
		}
		else
		{
		segundo = segundo+1;
		document.getElementById('segundo').value = segundo;
		//window.alert(segundo);
		setTimeout("conta_update()", 1);
		}
	}
	else
	{
		segundo = 0;
		
		if (minuto < 9) {
		minuto = minuto + 1;
		document.getElementById('minuto').value = "0" + minuto;
		}
		else
		{
		minuto = minuto + 1;
		document.getElementById('minuto').value = minuto;
		}
		
		if (minuto == 60) {
			if (hora < 9) {
			hora = hora + 1;
			document.getElementById('hora').value = "0" + hora;
			hora = 0;
			}
			else
			{
			hora = hora + 1;
			document.getElementById('hora').value = hora;
			minuto = 0;
			}
		}
		setTimeout("conta_update()", 1);
	}
}*/

//link q guarda o segredo: http://www.orkut.com.br/Main#CommMsgs.aspx?cmm=87180&tid=2523644460122403192&kw=this+style
var icone_mais_menos = 0;

function abrefechaprova(pObj) {
	if (pObj.style.display == 'none') {
		//this.style.backgroundImage = 'url(imagens/menos.jpg)';
		pObj.style.display = 'block';
		icone_mais_menos = 1;
	}
	else
	{
		//pObj.getElementsByTagName('ul')[0].style.display = 'none';
		//this.style.backgroundImage = 'url(imagens/mais.jpg)';
		pObj.style.display = 'none';
		icone_mais_menos = 0;
	}
}

function maismenos(pObj) {
	if (icone_mais_menos == '1') {
		pObj.style.backgroundImage = 'url(imagens/menos.jpg)';
	}
	else
	{
		pObj.style.backgroundImage = 'url(imagens/mais.jpg)';
	}
}

function indicador(pObj) {
	if (icone_mais_menos == '1') {
		pObj.src = 'imagens/indica_dicionario_aberto.gif';
	}
	else
	{
		pObj.src = 'imagens/indica_dicionario.gif';
	}
}

function valida_comentario_enquete() {
	var comentario_enquete = document.getElementById('txt_comentario_enquete');
	if (comentario_enquete.value=="") {
	    window.alert("A caixa de comentário está vazia");
		comentario_enquete.focus();
		return false;
	}
}

function abrir_espaco() {
	var mensagem = document.getElementById('mensagem_topico');
	var topico = document.getElementById('topico_mensagem');
	
	if (mensagem.style.display == 'none') {
		topico.style.display = 'block';
		mensagem.style.display = 'block';
	}
	else
	{
		topico.style.display = 'none';
		mensagem.style.display = 'none';
	}
}



function validar_msg_forum() {
	var titulo = document.getElementById('txttitulotopico');
	var descricao = document.getElementById('msgcorpotopico');
	
	if (titulo.value=="") {
	    window.alert("Preencha os dados corretamente");
		titulo.focus();
		return false;
	}
	
	if (descricao.value=="") {
	    window.alert("Preencha os dados corretamente");
		descricao.focus();
		return false;
	}
}

function validar_resp_forum() {
	var topico_mensagem = document.getElementById('msgcorpotopico');
	
	if (topico_mensagem.value=="") {
	    window.alert("Preencha os dados corretamente");
		topico_mensagem.focus();
		return false;
	}
}

function validarcontato() {
	var nome = document.getElementById('nome_contato');
	var mail = document.getElementById('mail_contato');
	var mensagem = document.getElementById('mensagem_contato');
	
	if (nome.value == "") {
		window.alert('A caixa de Nome é obrigatória');
		nome.focus();
		return false;
	}
	
	if (mensagem.value == "") {
		window.alert('A caixa de E-mail é obrigatória');
		mail.focus();
		return false;
	}
	
	if (mail.value.indexOf("@",0) == -1) {
		window.alert('E-Mail Inválido');
		mensagem.focus();
		return false;
	}
	
}