// ©2007 Computech - Desenvolvido por BRIVIA

// Constultar o Dominio
function constultarDominio()
{	
	document.getElementById('iframePosts').style.display = ""; 
	
    dominio = document.getElementById('strDominio').value;	
	
	if (dominio == "")
	{
		alert("Informe o domínio desejado.");	
		document.getElementById('strDominio').focus();
	}else
	{
		complemento = document.getElementById('strDominioCom').value;	
		parent.iframePosts.location.href = "busca-dominio2.php?strDominio="+dominio+"&strDominioCom="+complemento;
	}
}

// Fechar Form de Contato
function FechaContato()
{
	top.document.getElementById('FechaContato').style.display = "none"; 
}
// Select em div
function SetaPosicaoSelectDiv(div_texto, div_id)
{
	// devolve opção ao select qndo selecionada uma nova 
	posicao_salva = document.getElementById('intCategoria').value;
	if (posicao_salva != "")
	{
		document.getElementById('sel_'+posicao_salva).style.display = "block"; 
	}
	// posicona item no select
	document.getElementById('sel_topo').innerHTML = div_texto;
    document.getElementById('intCategoria').value = div_id;	
	document.getElementById('sel_'+div_id).style.display = 'none';
	
}
// Select em div do Dominio
function SetaPosicaoSelectDivDominio(div_texto)
{
	// devolve opção ao select qndo selecionada uma nova 
	posicao_salva = document.getElementById('strDominioCom').value;
	if (posicao_salva != "")
	{
		document.getElementById('sel_'+posicao_salva).style.display = "block"; 
	}
	// posicona item no select
	document.getElementById('sel_topo').innerHTML = div_texto;
    document.getElementById('strDominioCom').value = div_texto;	
	document.getElementById('sel_'+div_texto).style.display = 'none';
	
}
// Posição do erro do contato
function SetaPosicaoErro(id_div,tipo_erro)
{
	if (tipo_erro == 'E')
	{	
		document.getElementById('ico_'+id_div).src = "img/erro.jpg";
	}
	else
	if	(tipo_erro == 'C')
	{
		document.getElementById('ico_'+id_div).src = "img/ok.jpg";
	}		
}

// Solicitação
function enviaSolicitacao()
{
	with(document.formContato)
	{
		if (tipo.value == '')
			SetaPosicaoErro('tipo', 'E')
		else
			SetaPosicaoErro('tipo', 'C')

		if (dominio.value == '')
			SetaPosicaoErro('dominio', 'E')
		else
			SetaPosicaoErro('dominio', 'C')			
			
		if (dia_mensal.value == '')
			SetaPosicaoErro('dia_mensal', 'E')
		else
			SetaPosicaoErro('dia_mensal', 'C')
			
			
		if (razao_social.value == '')
			SetaPosicaoErro('razao_social', 'E')
		else
			SetaPosicaoErro('razao_social', 'C')
		
		if (email.value.indexOf('@') < 1 || email.value.indexOf('.') < 1)
			SetaPosicaoErro('email', 'E')
		else
			SetaPosicaoErro('email', 'C')
			
		if (contato.value == '')
			SetaPosicaoErro('contato', 'E')
		else
			SetaPosicaoErro('contato', 'C')
			
			
		if (endereco.value == '')
			SetaPosicaoErro('endereco', 'E')
		else
			SetaPosicaoErro('endereco', 'C')
			
			
		if (bairro.value == '')
			SetaPosicaoErro('bairro', 'E')
		else
			SetaPosicaoErro('bairro', 'C')
			
		
		if (cidade.value == '')
			SetaPosicaoErro('cidade', 'E')
		else
			SetaPosicaoErro('cidade', 'C')
			
		if (cep.value == '')
			SetaPosicaoErro('cep', 'E')
		else
			SetaPosicaoErro('cep', 'C')

		if (telefone.value == '')
			SetaPosicaoErro('telefone', 'E')
		else
			SetaPosicaoErro('telefone', 'C')	

		if (cnpj.value == '')
			SetaPosicaoErro('cnpj', 'E')
		else
			SetaPosicaoErro('cnpj', 'C')

		if (inscricao_estadual.value == '')
			SetaPosicaoErro('inscricao_estadual', 'E')
		else
			SetaPosicaoErro('inscricao_estadual', 'C')						
			
		if (observacao.value == '')
			SetaPosicaoErro('observacao', 'E')
		else
			SetaPosicaoErro('observacao', 'C')				
		
		return true;
	}
}

// Contato
function enviaContato()
{
	with(document.formContato)
	{
		if (strNome.value == '')
			SetaPosicaoErro('strNome', 'E')
		else
			SetaPosicaoErro('strNome', 'C')
			
			
		if (strSetor.value == '')
			SetaPosicaoErro('strSetor', 'E')
		else
			SetaPosicaoErro('strSetor', 'C')
			
			
		if (strEmail.value == '')
			SetaPosicaoErro('strEmail', 'E')
		else
			SetaPosicaoErro('strEmail', 'C')
		
		if (strEmail.value.indexOf('@') < 1 || strEmail.value.indexOf('.') < 1)
			SetaPosicaoErro('strEmail', 'E')
		else
			SetaPosicaoErro('strEmail', 'C')
			
		if (strTelefone.value == '')
			SetaPosicaoErro('strTelefone', 'E')
		else
			SetaPosicaoErro('strTelefone', 'C')
			
			
		if (strEndereco.value == '')
			SetaPosicaoErro('strEndereco', 'E')
		else
			SetaPosicaoErro('strEndereco', 'C')
			
			
		if (strCidade.value == '')
			SetaPosicaoErro('strCidade', 'E')
		else
			SetaPosicaoErro('strCidade', 'C')
			
		
		if (txtMensagem.value == '')
			SetaPosicaoErro('txtMensagem', 'E')
		else
			SetaPosicaoErro('txtMensagem', 'C')
		
		return true;
	}
}

// Indicando uma Notícia
function enviaIndique()
{
	with(document.formIndique)
	{
		if (strNome.value == '')
			return alerta("Informe o seu nome.", strNome);
		else
		if (strEmail.value == '')
			return alerta("Informe o seu e-mail.", strEmail);
		else
		if (strEmail.value.indexOf('@') < 1 || strEmail.value.indexOf('.') < 1)
			return alerta('Informe um e-mail válido.', strEmail);
		else
		if (strIndicNome.value == '')
			return alerta("Informe o nome do seu amigo.", strIndicNome);
		else
		if (strIndicEmail.value == '')
			return alerta("Informe o e-mail do seu amigo.", strIndicEmail);
		else
		if (strIndicEmail.value.indexOf('@') < 1 || strIndicEmail.value.indexOf('.') < 1)
			return alerta('Informe um e-mail válido.', strIndicEmail);
		else
			return true;
	}
}

function barNav() {
	if(document.getElementById('Nav')){
		var box = document.getElementById('Nav');
		var lis = box.getElementsByTagName('li');
		for(var i=0; i < lis.length; i++) {
			lis[i].onmouseover=function(){ 
				var div = this.lastChild;
				if(div.className == "Menu-flutuante") {
					div.className='Menu-flutuante dblock';
				}else if(div.className == "Menu-flutuante2"){
					div.className='Menu-flutuante2 dblock';
				}
			}
			lis[i].onmouseout=function(){
				var div = this.lastChild;
				if(div.className == "Menu-flutuante dblock") {
					div.className='Menu-flutuante';
				}else if(div.className == "Menu-flutuante2 dblock"){
					div.className='Menu-flutuante2';
				}
			}
		}
	}
}
function Select(tipo) {

	if (!tipo)
	{
	
		// HOME
		if(document.getElementById('home-busca'))
		{
			var box = document.getElementById('home-busca');
		// CONTATO
		}
		else if(document.getElementById('Cols-Dir-Fale'))
		{
			var box = document.getElementById('Cols-Dir-Fale');
		// NOTÍCIA
		}
		else if(document.getElementById('Box-Conteudo'))
		{
			var box = document.getElementById('Box-Conteudo');
		}
		else if(document.getElementById('Box-Conteudo-Select'))
		{
			var box = document.getElementById('Box-Conteudo-Select');
		}
		else
		{ 
			var box = null;
		}
	
	}
	else
	{
		var box = document.getElementById(tipo);
	}
	
	if(box)
	{
	
		var divs = box.getElementsByTagName('div');
		for(var i=0; i < divs.length; i++)
		{
			divs[i].onmouseover=function()
			{
				var div = this.lastChild;
							
				if(div.className == "select1-Aberto")
				{
					div.className='select1-AbertoBlock';
				}
				else if(div.className == "Select-Aberto03")
				{
					div.className='.Select-AbertoBlock03';
				}
				else if(div.className == "Select-Aberto02")
				{
					div.className = "Select-AbertoBlock02";
				}
				else if(div.className == "Select-Aberto")
				{
					div.className = "Select-AbertoBlock";
				}				
			}
			divs[i].onmouseout=function()
			{ 	
				var div = this.lastChild;
				if(div.className == "select1-AbertoBlock")
				{
					div.className='select1-Aberto';
				}
				else if(div.className == ".Select-AbertoBlock03")
				{
					div.className='Select-Aberto03';
				}
				else if(div.className == "Select-AbertoBlock02")
				{
					div.className = "Select-Aberto02";
				}	
				else if(div.className == "Select-AbertoBlock")
				{
					div.className = "Select-Aberto";
				}								
			}
		}
	}
}

function iniciar() {
	barNav();
	Select();
}
window.onload = iniciar;



//////////////////////////////////////////////////////////////////////////////////////

// Carregamento de páginas
function carregaPagina(pagina, alvo, funcao, mensagem)
{
	if (mensagem == "")
	{
		mensagem = "<img src=..\indicator.gif>";	
	}
	
	jah(pagina, alvo, funcao, mensagem);
}

function getTopo()
{
	void(document.body.scrollTop = 400);
}

// Ampliação de produtos sem Pop-Up
function showDivPop(pagina)
{
	posicaoVertical = document.body.scrollTop + 10;

	document.getElementById('divpop').style.top = posicaoVertical;
	document.getElementById('divpop').style.display = '';
	
	jah(pagina,'c_divpop','','');	
}

function hideDivPop()
{
	document.getElementById('divpop').style.display = 'none';
}

// Alertas (mensagens)
function alerta(msg, obj, foco, topo)
{
	alert(msg);
	if (!foco)
		obj.focus();
	if (topo)
		document.location = '#' + topo;
	return false;
}

//Cor fundo.
function setaCorFundo(codigo_hex)
{
	document.getElementById('corpoSite').style.backgroundImage = '';	
	document.getElementById('corpoSite').style.backgroundColor = codigo_hex;	
}

function setaImgFundo(arquivo)
{
	imagem = new String('url(_img/fundo/'+arquivo+')');

	document.getElementById('corpoSite').style.backgroundColor = '';	
	document.getElementById('corpoSite').style.backgroundImage = imagem;	
}

//"PopUp" em DIV
function showPopUp(pagina, msg)
{
	document.getElementById('divPopUp').style.display = '';
	
	if (msg) { mensagem = msg; } else { mensagem = ''; }
	
	jah(pagina,'divConteudoPopUp','',mensagem);
}

function hidePopUp()
{
	document.getElementById('divPopUp').style.display = 'none';
}

// Envia Opiniao
function enviaOpiniao()
{
	with(document.formOpiniao)
	{
		if (!valor.checked)
			return alerta("Informe sua escolha.", valor);
		else
			return true;
	}
}

function contaAcesso(secao)
{
	document.getElementById('iframePosts').src='_registra_acessos.php?secao='+secao;
}

//Troca imagem
function getTrocaImagem(intOpcao, intId)
{
	jah('destaque-imagem-print.php?intOpcao='+intOpcao+'&intId='+intId, 'home-banner', '', '<font face="Arial, Helvetica, sans-serif" color="#666666">Carregando Aguarde...</font>');
}
