function SetFocus(f_pos,c_pos){
	document.forms[f_pos].elements[c_pos].focus();
}
/***************************************************************************
	FUNÇÃO QUE SETA O FOCO DO TECLADO NO CAMPO SELECIONADO, RECEBE COMO 
	PARAMETROS O INDICE OU O NOME (NÃO TESTEI COM O NOME) DO FORMULARIO
	E DO CAMPO DESEJADO.
		CHAMADO À FUNÇÃO:
			<script>SetFocus('2','1');</script>
		LEGENDA: f_pos => POSIÇÃO DO FORMULÁRIO | ÍNDICE DO FORM
				 c_pos => POSIÇÃO DO CAMPO | ÍNDICE DO CAMPO
	ATENÇÃO! COLOCAR ESTE CHAMADO DE FUNÇÃO NO FINAL DO CÓDIGO, POIS SE
	O BROWSER AINDA NÃO TIVER RENDERIZADO O FORM OU O CAMPO ELE FALHARÁ
***************************************************************************/
function ResetFormulario(f_pos){
	if (confirm('Esta ação irá retornar o formulário ao seu estado inicial.\n Tem certeza que deseja prosseguir?')){
		document.forms[f_pos].reset();
	}
}
/***************************************************************************
	FUNÇÃO QUE "RESETA" O FORMULARIO, SOLICITANDO CONFIRMAÇÃO DA AÇÃO
	ANTES DE EFETIVÁ-LA.
		CHAMADO À FUNÇÃO:
			(...)onClick="ResetFormulario('2')"
		LEGENDA: f_pos => POSIÇÃO DO FORM | ÍNDICE DO FORM
***************************************************************************/

function SetaFoco(id){
	document.getElementById(id).focus();
}

/***************************************************************************
	FUNÇÃO QUE FAZ O SUBMIT DO FORMUÁRIO, DE ACORDO COM PARAMETROS
	PASSADO PRA ELA.
	1. DETECTA QUAL O FORMULARIO EM QUESTÃO PELO ID (TEM QUE DECLARAR ID)
	2. PEGA O ACTION (TEM QUE DECLARAR ACTION)
	3. CONCATENA QUERYSTRING NO ACTION
		FORMULÁRIO:
			 <form id="id_form"(...) action="arquivo.php?variavel=">
		CHAMADO À FUNÇÃO:
			(...)onClick="EnviaFormulario(form.id,'valor_querystring')"
		LEGENDA: id_form =>INDICE DO FORM	
***************************************************************************/
function EnviaFormulario(id_form,alvo){
//	alert(document.getElementById(id_form).action);
	if (!document.getElementById(id_form).action.match("link=p")){
	document.getElementById(id_form).action = document.getElementById(id_form).action+alvo;
	}
//	alert(document.getElementById(id_form).action);
	document.getElementById(id_form).submit();
}

/*************************************************************************
	FUNCAO QUE SO PERMITE DIGITAR NUMEROS NO CAMPO
	Fonte:
	http://www.freecode.com.br/forum/lofiversion/index.php/t5928.html
	Uso:
	onKeyPress="return soN(true,true)"
	
*************************************************************************/
function soN(esp,numbers,others,e){
	if(window.event)key=window.event.keyCode
	else if(e)key=e.which
	else return true
	S=(others)?others:''
	if(numbers)S+='0123456789'
	if(esp) { if(key==32)return true }
	if(key==null||key==0||key==8||key==9||key==27)return true
	else if(S.indexOf(String.fromCharCode(key))!=-1)return true
	else return false
}

function ValidaTocaSenha(formulario){
//	alert(formulario);
//	document.geElemetById[formulario].submit;
//	verifica se o campo senhaUsuario foi preenchido
	if(document.forms[0].senhaUsuario.value == ""){
		alert('Informe a sua senha atual!');
		document.forms[0].senhaUsuario.focus();
		return false;
	}
//	verifica se o campo novaSenha foi preenchido
	if(document.forms[0].novaSenha.value == ""){
		alert('Informe sua nova senha!');
		document.forms[0].novaSenha.focus();
		return false;
	}
//	verifica se o campo confirmaSenha foi preenchido
	if(document.forms[0].confirmaSenha.value == ""){
		alert('Confirme a nova senha!');
		document.forms[0].confirmaSenha.focus();
		return false;
	}
//	verifica se a nova senha confere com a confirmnação
	if(document.forms[0].novaSenha.value == document.forms[0].confirmaSenha.value){
		return true;
	}else{
		alert('A nova senha não confere com a confirmação!')
		document.forms[0].novaSenha.value = "";
		document.forms[0].confirmaSenha.value = "";
		document.forms[0].novaSenha.focus();
		return false;
	}
}


function Mostra(submenu){
	document.getElementById(submenu).style.visibility = 'visible';
}
function Oculta(submenu){
	document.getElementById(submenu).style.visibility = 'hidden';
}


/*********************************
		Usados pelo /adm
*********************************/
function ValidaNovaNoticia(){
//	verifica se o campo tituloNoticia foi preenchido
	if(document.forms[0].tituloNoticia.value == ""){
		alert('Informe o título da notícia!');
		document.forms[0].tituloNoticia.focus();
		return false;
	}
//	verifica se o campo tituloNoticia foi preenchido
	if(document.forms[0].textoNoticia.value == ""){
		alert('Entre com o texto da notícia!');
		document.forms[0].textoNoticia.focus();
		return false;
	}	
}

function ConfirmaExclusao(){
	if(confirm('Tem certeza que quer excluir este registro?\nEsta ação não pode ser desfeita.')){
		return true;
	}
	return false;
}

/***********************************
	Funcão que fecha a mensagem 
	de permissao negada
***********************************/
function FecharPermissaoNegada(){
	document.getElementById('permissaonegada').style.visibility = 'hidden';
}

/********************************
	Função que abre o pop
	up com o resultado das
	emquetes no administrativo
*********************************/
function ResultadoEnquete(cod){
	window.open('index.php?link=enquete&detalhe='+cod,'ResultadoEnquete','toolbar=no,location=no,menubar=no,scrollbars=no,resizable=no,width=300,height=145')
}
/********************************
	Função checa se o form
	de logon esta  sendo
	exibido na tela
*********************************/
function ChecaForm(id){
	if(document.forms[0].action.match("link=")){
		return 0;
	} else {
		return 1;
	}
}