function formIndiqueEnviar(){
	if (document.getElementById("nome").value==""){
		alert("É necessário o preenchimento do campo SEU NOME!");
		document.getElementById("nome").focus();
		return false;
	}
	if (document.getElementById("email").value==""){
		alert("É necessário o preenchimento do campo SEU E-MAIL!");
		document.getElementById("email").focus();
		return false;
	}
	if (document.getElementById("email").value!="")	{
		qtdArroba = document.getElementById("email").value.split('@');
		if (document.getElementById("email").value.search("@") == -1 || document.getElementById("email").value.search("[.]") == -1 || document.getElementById("email").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
			alert("O preenchimento do SEU E-MAIL está incorreto!");
			document.getElementById("email").focus(); 
			return false;
		}
	}
	if (document.getElementById("nomeamigo").value==""){
		alert("É necessário o preenchimento do campo NOME DO AMIGO!");
		document.getElementById("nomeamigo").focus();
		return false;
	}
	if (document.getElementById("emailamigo").value==""){
		alert("É necessário o preenchimento do campo EMAIL DO AMIGO");
		document.getElementById("emailamigo").focus();
		return false;
	}
	if (document.getElementById("emailamigo").value!="")	{
		qtdArroba = document.getElementById("emailamigo").value.split('@');
		if (document.getElementById("emailamigo").value.search("@") == -1 || document.getElementById("emailamigo").value.search("[.]") == -1 || document.getElementById("emailamigo").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
			alert("O preenchimento do campo E-MAIL DO AMIGO está incorreto!");
			document.getElementById("emailamigo").focus(); 
			return false;
		}
	}
	document.getElementById("indicar").submit();
}
function linkOpen()
{
	var args = arguments;
	window.location=args[0]
}
function valida_tipo()
{
	var idForm = document.getElementById("frmUBS");
	if(idForm.cod_acess.value=="" || idForm.cod_acess.value==0)
	{
		alert('Necessário o preenchimento do Código de Acesso!');
		idForm.cod_acess.focus();
	}
	else
	{
		idForm.submit();
	}
}
function marca_radio(v) 
{ 
	if (document.escolha.elements[v].name == 'mes')
	{
		document.escolha.elements[v].checked = true;
	}
	else if (document.escolha.elements[v].name == 'quinzena')
	{
		document.escolha.elements[v].checked = true;
	}
}
function validar(form)
{
	if (!validar_grupo(form.mes))
	{
		alert("Selecione um Mês para marcação da consulta.");
		return false;
	} 

	if (!validar_grupo(form.quinzena))
	{
		alert("Selecione uma Quinzena para marcação da consulta.");
		return false;
	} 
	form.submit();
	return(true);
}
function validar_grupo(grupo)
{
	var Campo;
	Campo=false;
	for (i=0; i<grupo.length; i++)
	{
		if (grupo[i].checked)
		{
			Campo = true;
		}
	}
	return(Campo);
}

function valor_grupo(grupo)
{
	for (i=0; i<grupo.length; i++)
	{
		if (grupo[i].checked)
		{
			return(grupo[i].value);
		}
	}
}
function FrontPage_Form1_Validator(theForm)
{
	if (theForm.codigo.value == ""){
		alert("É necessário o preenchimento do campo CÓDIGO.");
		theForm.codigo.focus();
		return (false);
	}
	if (theForm.codigo.value.length < 1){
		alert("Please enter at least 1 characters in the \"codigo\" field.");
		theForm.codigo.focus();
		return (false);
	}
	var checkOK = "0123456789-.";
	var checkStr = theForm.codigo.value;
	var allValid = true;
	var validGroups = 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;
		}
		if (ch != ".")
			allNum += ch;
	}
	if (!allValid){
		alert("Digite apenas números no campo CÓDIGO.");
		theForm.codigo.focus();
		return (false);
	}
	return (true);
}
function mostraImagem(x){
	if (x == 1){
		document.getElementById("imagem1").style.display="block";
		document.getElementById("imagem2").style.display="none";
	}
	else if (x == 2){
		document.getElementById("imagem2").style.display="block";
		document.getElementById("imagem1").style.display="none";
	}
}
function abreLinkParent(pag)
{
	window.opener.document.location = pag;
	window.close();
}
function popup(url,altura,largura) {
    popupOpen = window.open(url,"janela01","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width="+largura+",height="+altura+",left="+(window.screen.width-largura)/2+", top="+(window.screen.height-altura)/2);
    popupOpen.focus();
}
function popupCurso() {
		window.open("../inscricaoCurso/inscricaoCurso.asp","incricaoCurso","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=320,height=260,left="+(window.screen.width-280)/2+", top="+(window.screen.height-300)/2);
    popupOpen.focus();
}
function mudaImagem(){
	var args = arguments;
	var src = args[0].src;
	if (src.search(/_pb/i)==66){
		src = src.replace(/_pb/gi, "_cl");
		args[0].src = src;
	}else {
		src = src.replace(/_cl/gi, "_pb");
		args[0].src = src;
	}
}


function formContato(){
	if (document.getElementById("comboTipo").value == 1){
		if (document.getElementById("nomeFaleConosco").value==""){
			alert("É necessário o preenchimento do campo SEU NOME!");
			document.getElementById("nomeFaleConosco").focus();
			return false;
		}
		if (document.getElementById("emailFaleConosco").value==""){
			alert("É necessário o preenchimento do campo SEU E-MAIL!");
			document.getElementById("emailFaleConosco").focus();
			return false;
		}
		if (document.getElementById("emailFaleConosco").value!="")	{
			qtdArroba = document.getElementById("emailFaleConosco").value.split('@');
			if (document.getElementById("emailFaleConosco").value.search("@") == -1 || document.getElementById("emailFaleConosco").value.search("[.]") == -1 || document.getElementById("emailFaleConosco").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
				alert("O preenchimento do SEU E-MAIL está incorreto!");
				document.getElementById("emailFaleConosco").focus(); 
				return false;
			}
		}
		if (document.getElementById("telefoneFaleConosco").value==""){
			alert("É necessário o preenchimento do campo TELEFONE!");
			document.getElementById("telefoneFaleConosco").focus();
			return false;
		}
		if (document.getElementById("assuntoFaleConosco").value==""){
			alert("É necessário o preenchimento do campo ASSUNTO!");
			document.getElementById("assuntoFaleConosco").focus();
			return false;
		}
		if (document.getElementById("mensagemFaleConosco").value==""){
			alert("É necessário o preenchimento do campo MENSAGEM!");
			document.getElementById("mensagemFaleConosco").focus();
			return false;
		}
		document.getElementById("formDoContato").submit();
	} else if (document.getElementById("comboTipo").value == 2) {
		if (document.getElementById("nomeIndique").value == ""){
			alert("É necessário o preenchimento do campo SEU NOME!");
			document.getElementById("nomeIndique").focus();
			return false;
		}
		if (document.getElementById("emailIndique").value==""){
			alert("É necessário o preenchimento do campo SEU E-MAIL!");
			document.getElementById("emailIndique").focus();
			return false;
		}
		if (document.getElementById("emailIndique").value!="")	{
			qtdArroba = document.getElementById("emailIndique").value.split('@');
			if (document.getElementById("emailIndique").value.search("@") == -1 || document.getElementById("emailIndique").value.search("[.]") == -1 || document.getElementById("emailIndique").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
				alert("O preenchimento do SEU E-MAIL está incorreto!");
				document.getElementById("emailIndique").focus(); 
				return false;
			}
		}
		if (document.getElementById("amigonomeIndique").value == ""){
			alert("É necessário o preenchimento do campo NOME DO SEU AMIGO!");
			document.getElementById("amigonomeIndique").focus();
			return false;
		}
		if (document.getElementById("amigoemailIndique").value==""){
			alert("É necessário o preenchimento do campo E-MAIL DO SEU AMIGO!");
			document.getElementById("amigoemailIndique").focus();
			return false;
		}
		if (document.getElementById("amigoemailIndique").value!="")	{
			qtdArroba = document.getElementById("amigoemailIndique").value.split('@');
			if (document.getElementById("amigoemailIndique").value.search("@") == -1 || document.getElementById("amigoemailIndique").value.search("[.]") == -1 || document.getElementById("amigoemailIndique").value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
				alert("O preenchimento do E-MAIL DO SEU AMIGO está incorreto!");
				document.getElementById("amigoemailIndique").focus(); 
				return false;
			}
		}
		document.getElementById("formDoIndique").submit();
	}
}
function showDivContato(){
	var args = arguments;
	if (args[0]==1){
		document.getElementById("blockIndique").style.display = "none";
		document.getElementById("blockFaleConosco").style.display = "block";
		document.getElementById("tituloContato").style.display = "none";
		document.getElementById("tituloFaleConosco").style.display = "block";
		document.getElementById("tituloIndique").style.display = "none";
	} else if (args[0]==2){
		document.getElementById("blockIndique").style.display = "block";
		document.getElementById("blockFaleConosco").style.display = "none";
		document.getElementById("tituloContato").style.display = "none";
		document.getElementById("tituloIndique").style.display = "block";
		document.getElementById("tituloFaleConosco").style.display = "none";
	}else {
		document.getElementById("blockIndique").style.display = "none";
		document.getElementById("blockFaleConosco").style.display = "none";
		document.getElementById("tituloContato").style.display = "block";
		document.getElementById("tituloIndique").style.display = "none";
		document.getElementById("tituloFaleConosco").style.display = "none";
	}
}

//////////////////////////////////////////////
/*
Nome da Função: validaForm
Parametros: form, arrCampos, arrMensagens
Descrição: Recebe um form, um array de campos e um array de mensagems.
Percorre o array de campos verificando se o mesmo está preenchido e caso 
não esteja ele exibe a mensagem.

Autor: Paulo Gentile
Data: 15/07/2008
Atualizado: Nunca
*/
/////////////////////////////////////////////
function validaForm(form, arrCampos, arrMensagens)
{	
	for(var i=0; arrCampos.length > i; i++)
	{
		switch(document.getElementById(arrCampos[i]).type)
		{
			case "text"	:
			case "textarea"	:
			case "password"	:
				if(document.getElementById(arrCampos[i]).value.length == 0)
				{
					document.getElementById(arrCampos[i]).focus();
					alert(arrMensagens[i]);
					return false;
				}
				break;
			case "hidden"	:
				if(document.getElementById(arrCampos[i]).value.length == 0)
				{
					alert(arrMensagens[i]);
					return false;
				}
				break;
			case "radio"	:
				var selecionado = false;
				
				for(var x=0; document.getElementsByName(arrCampos[i]).length > x; x++)
				{
					if(document.getElementsByName(arrCampos[i])[x].checked)
					{
						selecionado = true;
					}
				}
				
				if(!selecionado)
				{
					alert(arrMensagens[i]);
					return false;
				}
				break;
			case "select-one" :
				if(document.getElementById(arrCampos[i]).selectedIndex == 0)
				{
					document.getElementById(arrCampos[i]).focus();
					alert(arrMensagens[i]);
					return false;
				}
				break;
		}
	}
	
	document.getElementById(form).submit();
}
function limpaFrmEnviaRecado()
{
	document.getElementById("txtNome").value = "";	
	document.getElementById("txtEmail").value = "";
	document.getElementById("txtMensagem").value = "";	
	document.getElementById("txtNome").focus();
}
function validaFrmEnviaRecado(){
	var txtNome = document.getElementById("txtNome")
	var txtEmail = document.getElementById("txtEmail")
	var txtMensagem = document.getElementById("txtMensagem")
	
	if(txtNome.value == ""){
		alert("O Campo NOME é de Preenchimento Obrigatório");
		txtNome.focus();
		return false;
	}
	else{
		if(txtEmail.value == ""){
			alert("O Campo E-MAIL é de Preenchimento Obrigatório");
			txtEmail.focus();
			return false;
		}
		else{
			qtdArroba = txtEmail.value.split('@');
			if(txtEmail.value.search("@") == -1 || txtEmail.value.search("[.]") == -1 || txtEmail.value.search(" ") != -1 || qtdArroba.length !=2 || qtdArroba[0] == "" || qtdArroba[1] == "" || qtdArroba[1] == "."){ 
				alert("O Preenchimento do Campo E-MAIL Está Incorreto!"); 
				txtEmail.value = "";
				txtEmail.focus();
				return false;
			}
			else{
				if(txtMensagem.value == ""){
					alert("O Campo MENSAGEM é de Preenchimento Obrigatório!");
					txtMensagem.focus();
					return false;
				}
			}
		}
		document.getElementById("frmEnviaRecado").submit();
		return true;
	}
}
function validaLogin(){
	var txtLogin = document.getElementById("txtCodigo");
	var frmLogin = document.getElementById("frmLogin");
	if(txtLogin.value == ""){
		alert("Por Favor, Digite um CÓDIGO!");
		txtLogin.focus();
		return false;
	}
	frmLogin.submit();
	return true;
}
function abreJanela(url){
	window.open(url);
}