// JavaScript Document
function validaLogin() {
	if (document.frmLogin.tx_login.value == ""){
		alert("Insira seu login.");
		document.frmLogin.tx_login.focus();
		return false;
	}
	
	if (document.frmLogin.tx_senha.value == ""){
		alert("Insira sua senha.");
		document.frmLogin.tx_senha.focus();
		return false;
	}
	return true;
}

                     	 

function validaFale(){

	if (isEmpty(document.getElementById('txNome'))){      
		alert ('O campo Nome é obrigatório');   
		document.getElementById('txNome').focus();  
		return false; 							 
	}                                                


	if (isEmpty(document.getElementById('txEmail'))){      
		alert ('O campo E-mail é obrigatório');   
		document.getElementById('txEmail').focus();  
		return false; 							 
	}else if (!isEmail(document.getElementById('txEmail').value)){
		alert ('Insira um E-mail válido');   
		document.getElementById('txEmail').focus();  
		return false; 							 
	}


	if (isEmpty(document.getElementById('txAssunto'))){      
		alert ('O campo Assunto é obrigatório');   
		document.getElementById('txAssunto').focus();  
		return false; 							 
	}                                                


	if (isEmpty(document.getElementById('txMsg'))){      
		alert ('O campo Mensagem é obrigatório');   
		document.getElementById('txMsg').focus();  
		return false; 							 
	}                                                
}

function validaFormNoticia(){

    if (empty(document.getElementById('txTitulo'))){                       
        alert ('O campo Titulo é obrigatório');       
        document.getElementById('txTitulo').focus();      
        return false; 							                        
    }

    if (empty(document.getElementById('txAutor'))){                       
        alert ('O campo Autor é obrigatório');       
        document.getElementById('txAutor').focus();      
        return false; 							                        
    }

    if (empty(document.getElementById('txNoticia'))){                       
        alert ('O campo Notícia é obrigatório');       
        document.getElementById('txNoticia').focus();      
        return false; 							                        
    }

}

function validaFormNoticia(){

    if (empty(document.getElementById('txTitulo'))){                       
        alert ('O campo Titulo é obrigatório');       
        document.getElementById('txTitulo').focus();      
        return false; 							                        
    }


    if (empty(document.getElementById('txNoticia'))){                       
        alert ('O campo Notícia é obrigatório');       
        document.getElementById('txNoticia').focus();      
        return false; 							                        
    }

}

function validaLoginControle(){
	if (!isEmail(document.getElementById('txLogin').value)){                       
        alert ('O campo login deve ser um E-mail válido');       
        document.getElementById('txLogin').focus();      
        return false; 							                        
    }

    if (empty(document.getElementById('txSenha'))){                       
        alert ('O campo senha é obrigatório');       
        document.getElementById('txSenha').focus();      
        return false; 							                        
    }
}

/* Menu Principal - Js Nao Obstrutivo
------------------------------------------------------------------------

Utilização:
	1 - Na sua folha de css crie as classe fechado e aberto
		.fechado {
			display:none;
		}	
		.aberto {
			display:block;
		}
	
	2 - Crie seu menu e coloque nele a classe menuShowHide
		<ul class="menuShowHide">
			<li>
				<a href="" nclick="return ShowHide('sub1')">ITEM1</a>
				<ul id="sub1">
					<li>Sub Item</li>
					<li>Sub Item</li>
					<li>Sub Item</li>
					<li>Sub Item</li>
				</ul>
			</li>
			<li>
				<a href="" nclick="return ShowHide('sub2')">ITEM2</a>
				<ul id="sub1">
					<li>Sub Item</li>
					<li>Sub Item</li>
					<li>Sub Item</li>
					<li>Sub Item</li>
				</ul>
			</li>
			<li>Item 3</li>
			<li>Item 4</li>
			<li>Item 5</li>
		</ul>
	
	3 - Chame a funcao CloseAll() no evento Onload da pagina;
		<body onload="CloseAll()">

----------------------------------------------------------------------------*/


function CloseAll(){ // Fecha todos os itens do menu
	var uls=document.getElementsByTagName("ul") // Pega quantas tags <ul> tem na pagina

	for(i=0;i<uls.length;i++){
		if(uls[i].className=="menuShowHide"){ // Caso o UL seja da classe menuShowHide
			subs = uls[i].getElementsByTagName("ul"); // Detecta e fecha os submenus
			for (j=0;j<subs.length;j++){	
				subs[j].style.display = 'none';
			}
		}
	}
}   

// ShowHide
function ShowHide(ID){
	CloseAll();
	var obj = document.getElementById(ID);
	obj.style.display=(obj.style.display=="none")?"block":"none";
	return false
}
/*------------------------------------------------------------------------*/


function trocaTopo(bg){
	var obj = document.getElementById('topo');
	var obj2 = document.getElementById('imgDestaque');
	obj.style.background='url(/img/bg_topo_'+bg+'.jpg)';
	obj2.style.background='url(/img/bg_conteudo_'+bg+'.jpg)';
	
	return false
}