// JavaScript Document



function apagar_formulario()

{

		document.form_contato.reset();

}



function enviar_contato()

{

	with(document.form_contato)

	{

		if(nome.value == "" || nome.value == "nome")

		{

			alert("Digite seu nome!");

			nome.focus();

			return;

		}

		

		if(email.value == "" || email.value == "email")

		{

			alert("Digite seu email para contato!");

			email.focus();

			return;

		}

		

		if(email.value.indexOf("@") == -1 || email.value.indexOf(".") == -1)

		{

			alert("Email invalido! digite novamente.");

			email.focus();

			return;

		}

		

		document.form_contato.submit();

	}

}



function logar_aluno()

{

	with(document.login_aluno)

	{

		if(login.value == "" || login.value == 'Login do aluno')

		{

			alert('Digite o seu login!');

			login.focus();

			return;

		}

		

		if(senha.value == "" || senha.value == 'password123')

		{

			alert('Digite a senha correta!');

			senha.focus();

			return;

		}

		

		document.login_aluno.submit();

	}

}



function logar_cliente()

{

	with(document.login_cliente)

	{

		if(login.value == "" || login.value == 'Login do cliente')

		{

			alert('Digite o seu login!');

			login.focus();

			return;

		}

		

		if(senha.value == "" || senha.value == 'password123')

		{

			alert('Digite a senha correta!');

			senha.focus();

			return;

		}

		

		document.login_cliente.submit();

	}

}



function enviar_senha_lembrete()

{

	with(document.form_lembrar_senha)

	{

		if(email.value == "" || email.value == "email")

		{

			alert('Digite o email!');

			email.focus();

			return;

		}

		

		if(email.value.indexOf("@") == -1 || email.value.indexOf(".") == -1)

		{

			alert('Email invalido!');

			email.focus();

			return;

		}

			

		

		document.form_lembrar_senha.submit();

	}

}



function janela_popup(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}



function cadastrar_aluno()

{

	with(document.form_novo_aluno)

	{

		if( nome.value == "" ||  nome.value == "nome")

		{

			alert("Digite o seu nome!");

			nome.focus();

			return;

		}

		

		if( email.value == "" ||  email.value == "email (login)")

		{

			alert("Digite o seu email!");

			email.focus();

			return;

		}

		

		if( email.value.indexOf("@") == -1 ||  email.value.indexOf(".") == -1)

		{

			alert("O email esta incorreto! Digite novamente.");

			email.focus();

			return;

		}

		

		if( senha.value == "" ||  senha.value == "senha")

		{

			alert("Digite a senha");

			senha.focus();

			return;

		}

		

		if( senha2.value == "" ||  senha2.value == "repetir senha")

		{

			alert("Digite a senha novamente!");

			senha2.focus();

			return;

		}

		

		if( senha.value != senha2.value )

		{

			alert("Senhas diferentes! As senhas tem que ser iguais!");

			senha2.focus();

			return;

		}

		

		if( instituicao.value == "" )

		{

			alert("Escolha sua instituição!");

			instituicao.focus();

			return;

		}

		

		/*if( disciplina[1].value == "" )

		{

			alert("Escolha ao menos uma disciplina!");

			disciplina[1].focus();

			return;

		}

		

		if( instituicao.value == "" ||  nascimento.value == "nascimento")

		{

			alert("Digite a data de nascimento!");

			nascimento.focus();

			return;

		}*/

		

		

		document.form_novo_aluno.submit();

	}

}



function janela_popup(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);

}



function selectAll(on) {

  var allElts = document.forms['caixa_entrada'].elements;

  var i;

  for (i=0; i<allElts.length; i++) {

    var elt = allElts[i];

    if (elt.type == "checkbox") {

      elt.checked = on;

    }

  }

}



function apagar_selecionadas()

{

	var conf = confirm("Tem certeza que deseja excluir todas mensagens marcadas?");

	if(conf == true)

	{

		document.caixa_entrada.submit();

	}

	else

	{

		return;

	}

}



function cadastrar_mensagem()

{

	with(document.nova_mensagem)

	{

		if(assunto.value == "")

		{

			alert("Digite o assunto da mensagem!");

			assunto.focus();

			return;

		}

		

		if(destinatario.value == "")

		{

			alert("Escolha o destinatário!");

			destinatario.focus();

			return;

		}

		

		document.nova_mensagem.submit();

	}

}



function excluir_topico()

{

	var conf = confirm("Tem certeza que deseja excluir este topico?");

	if(conf == true)

	{

		submit();

	}

	else

	{

		return;

	}

}



function mostra_comentar_topico()

{

		

		var form_comentar = document.getElementById("form_comentar");

		var bt_abrir = document.getElementById("bt_abrir");

	

		

	   if( form_comentar.style.display == "none" )

	   {

			form_comentar.style.display = "block";

			bt_abrir.style.display = "none";

	   }



}



function cadastrar_coments_topico()

{

	with(document.form_comentar_topico)

	{

		if(comentario.value == "")

		{

			alert("Digite o texto da mensagem!");

			comentario.focus();

			return;

		}

		

		document.form_comentar_topico.submit();

	}

}



function excluir_comentario()

{

	var conf = confirm("Tem certeza que deseja excluir este comentario?");

	if(conf == true)

	{

		submit();

	}

	else

	{

		return;

	}

}



function atualizar_topico()

{

	with(document.atualizar_topico)

	{

	

		if(titulo.value == "")

		{

			alert("Digite o titulo do topico!");

			titulo.focus();

			return;

		}

		

		if(diciplina.value == "")

		{

			alert("Escolha a disciplina!");

			diciplina.focus();

			return;

		}

		

		var c = confirm("Tudo pronto a ser salvosssss?");

	

		if(c == true)

		{

			document.atualizar_topico.submit();

		}

		

		

	

	}

}



function cadastrar_topico()

{

	with(document.cadastrar_topico)

	{

	

		if(titulo.value == "")

		{

			alert("Digite o titulo do topico!");

			titulo.focus();

			return;

		}

		

		if(diciplina.value == "")

		{

			alert("Escolha a disciplina desse tópico!");

			diciplina.focus();

			return;

		}

		

		var c = confirm("Tudo pronto a ser salvo?");

	

		if(c == true)

		{

			document.cadastrar_topico.submit();

		}

		

		

	

	}

}



function get_hoteditor_data()

{

	setCodeOutput();

	var bbcode_output=document.getElementById("hoteditor_bbcode_ouput_editor").value;//Output to BBCode

	document.getElementById("bbcode_holder").value = bbcode_output;

	document.novo_registro.submit();

}


function excluir_mensagem()

{

	var conf = confirm("Tem certeza que deseja excluir essa mensagem?");

	if(conf == true)

	{

		submit();

	}

	else

	{

		return false;

	}

}

