function AbreDiv(obj, param){	
	
	var div;
	div = obj;
	
	if (document.getElementById(div).style.display == "none")
	{
		document.getElementById(div).style.display = "block";
	}
	else
	{
		document.getElementById(div).style.display = "none";
   	}
 	
}


function redim(iframe)
{
	if(navigator.appName=="Microsoft Internet Explorer")
		var altura = parseInt(document.body.scrollHeight);
	else
		var altura = parseInt(document.body.offsetHeight);

	parent.document.getElementById(iframe).style.height = altura + 'px';
}



// ------------ Conta caracteres
function Conta(formulario){
	var form = document.forms[formulario];
	total = form.mensagem.value.length;
	form.mensagem.focus();
	if(total <= 3000){
		form.total.value = 'Máximo de 3000 caracteres. '+ total +' caracteres já digitados'
	}
	else{
		form.total.value = 'Máximo de 3000 caracteres. 3000 caracteres já digitados'
		form.mensagem.value = form.msg.value.substring(0,3000);
		alert('Excedido o número máximo de caracteres.');
		return;
	}
}


function validaFaleConosco(){
					
		var form = document.forms['FaleConosco']
					
		if (form.nome.value == '' || form.nome.value.length < 5){
			alert('Preencha corretamente o campo nome.');
			form.nome.focus();
			return;
		}
		
		if (form.telefone.value == ''){
			alert('Preencha corretamente o campo Telefone.');
			form.telefone.focus();
			return;
		}
		
		
		if (form.email.value == '' || form.email.value.indexOf(".") < 2 || form.email.value.indexOf("@") < 2){
			alert('Preencha corretamente o campo e-mail.');
			form.email.focus();
			return;
		}
		
		
		if (form.mensagem.value == ''){
			alert('Preencha corretamente o campo mensagem.');
			form.mensagem.focus();
			return;
		}
					
		form.target = '_top';
		form.action = 'enviar.asp';
		form.submit();
								
		alert('Mensagem enviada com sucesso!');
		form.reset();
}

