// FUNÇÃO PARA BUSCA NO GOOGLE
function Google() {
	document.frmGoogle.submit();
}

// FUNÇÃO PARA TORNAR UM CONTEÚDO VISÍVEL
function mostrarConteudo(id){
	document.getElementById(id).style.display = 'block';
}

//FUNÇÃO PARA TORNAR UM CONTEÚDO OCULTO
function esconderConteudo(id){
	document.getElementById(id).style.display = 'none';
}

// FUNÇÃO PARA TROCAR UM CONTEÚDO VISIVEL POR OUTRO CONTEUDO
var visivel = '';
function trocarConteudo(id){
	if(visivel.length > 0) 
		esconderConteudo(visivel);
	mostrarConteudo(id);
	visivel = id;
}


//Redimensiona a div
function exibirConteudo(idConteudo){
	var d = document.getElementById(idConteudo);
	if(d.style.display != 'block'){
		d.style.display = 'block';
		
		if(d.hF)
			d.style.height = d.hF + 'px';
		
		d.hF = d.offsetHeight;
		d.style.height = '1px';
		
		var c = d.innerHTML;
		d.innerHTML = '';					
		expandir(idConteudo, d.hF, escape(c));	
	}			
}

function expandir(id, hF, conteudo){
	var d = document.getElementById(id);
	var h = parseInt(d.style.height);
	if(h < hF){
		d.style.height = (h + 15) + 'px';
		setTimeout('expandir("'+id+'",'+hF+', "'+ conteudo+'")', 0);

	}else{
		d.innerHTML = unescape(conteudo);
	}
}

function ocultarConteudo(idConteudo){
	var d = document.getElementById(idConteudo);
	
	d.style.height = d.hF + 'px';
	
	var c = d.innerHTML;
	d.innerHTML = '';
	
	diminuir(idConteudo, escape(c));
}

function diminuir(id, conteudo){
	var d = document.getElementById(id);
	var h = parseInt(d.style.height);
	if(h > 20){
		d.style.height = (h - 20) + 'px';
		setTimeout("diminuir('"+id+"', '"+conteudo+"')", 1);
	}else{
		d.style.display = 'none';
		d.style.height = d.hF + 'px';
		d.innerHTML = unescape(conteudo);		
	}
}

// FUNÇÃO DE VALIDAÇÃO DE FORMULÁRIO DE FALE CONOSCO
function validaCampos() {
	var ok = true;
	var str = "";
	var count = 0;
	
	if (document.form.nome.value == "") {
		count ++;
		str += count + ". O campo Nome deve ser preenchido.\n";
		ok = false;
	}
	
	if (document.form.email.value == "") {
		count ++;
		str += count + ". O campo E-mail deve ser preenchido.\n";
		ok = false;
	}
	
	if (document.form.assunto.value == "") {
		count ++;
		str += count + ". O campo Assunto deve ser preenchido.\n";
		ok = false;
	}
	
	if (document.form.mensagem.value == "") {
		count ++;
		str += count + ". O campo Mensagem deve ser preenchido.\n";
		ok = false;
	}
	
	if (ok == true) {
		alert("Dados enviados com sucesso!");
		document.form.submit();
	} else {
		if (count == 1) {
			alert(str = "Ateno ocorreu " + count + " erro!\n\n" + str);
		} else {
			alert(str = "Ateno ocorreram " + count + " erros!\n\n" + str);
		}
	}
}

// FUNÇÃO PARA VALIDAR E-MAILS
function validarEmail(campo) { 
	var goodEmail = campo.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi); 
	if (goodEmail) { 
		return true; 
	} else { 
		return false; 
	} 
}

// FUNÇÃO PARA SOMENTE NÚMEROS
function soNumeros(evt) {
	var tecla; 
	if (evt.keyCode) 
		tecla = evt.keyCode; 
	else tecla = evt.which; 
	if (tecla < 48 || tecla > 57) { 
		if (evt.keyCode) 
			evt.returnValue = false; 
		else 
			evt.preventDefault(); 
	} 
}

// FUNÇÃO PARA MONTAR FLASH
function flash(movie, id, width, height, wmode, FlashVars){  
   	var swf  = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="' + id + '"'
       + 'width="'+ width +'" height="'+ height +'"'
       + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
       + '<param name="movie" value="'+ movie +'" /><param name="quality" value="high" /><param name="devicefont" value="true" /><param name="wmode" value="'+ wmode +'" /><param name="FlashVars" value="'+ FlashVars +'" />'
       + '<embed src="'+ movie +'" quality="high" devicefont="true" '
       + 'width="'+ width +'" height="'+ height +'" align="middle"'
       + 'play="true"'
       + 'loop="false"'
       + 'quality="high"'
       + 'wmode="'+ wmode +'"'
       + 'allowScriptAccess="sameDomain"'
       + 'type="application/x-shockwave-flash"'
       + 'FlashVars="'+ FlashVars +'"'
       + 'pluginspage="http://www.macromedia.com/go/getflashplayer"'
       + '><\/embed>'
       + '<\/object>';
   	document.write(swf);
}

//Mostro a hora atual no topo
function mostraHoras(){
	var hora = new Date();
	document.getElementById("horas").value = hora.getHours() + ":" + hora.getMinutes() + ":" + hora.getSeconds();
}
