function limpar(obj,texto)
{
	if ( !clicou )
	{
		obj.value = texto;
		clicou = true;
	}
}

function escrever(obj,texto)
{
	if ( clicou && obj.value == " " )
	{
		obj.value = texto;
		clicou = false;
	}
}

function validar_email(email)
{
	if ( !email )
	{
		return false;
	}
	else if ( email.indexOf("@") <= 2 || email.lastIndexOf(".") <= email.indexOf("@") + 2 || email.length <= 8 )
	{
		return false;
	}
	else
	{
		return true;
	}
}

function start()
{
	form_mail = document.getElementById('form_mail');
	email     = document.getElementById('email');
	busca     = document.getElementById('busca');
}

function enviar_mala()
{
	formulario = document.getElementById('mala');

	email_mala = document.getElementById('email_cad_mala');

	if ( validar_email(email_mala.value) )
		formulario.submit();
	else
		alert('Email invalido, tente novamente!');
}

function alerta_confirmacao( status , texto )
{
	if ( status == true )
		alert(texto);
}

function abrir_popup(url,largura,altura)
{
	window.open(url,'_blank','width=' + largura + ',height=' + altura + 'top=100,left=100,resizable=no,scrollbars=auto');
}

function indicar_site()
{
	ind_form = document.getElementById('indicar_site');
	email1 = document.getElementById('email');
	email2 = document.getElementById('email_dest');
	name1  = document.getElementById('nome1');
	name2  = document.getElementById('nome2');

	if (name1.value.length == 0 || name2.value.length == 0 || email1.value.length == 0 || email2.value.length == 0 )
	{
		alert("Preencha os campos para indicar o site!");
	}
	else
	{
		if ( validar_email( email1.value ) && validar_email( email2.value ) )
			ind_form.submit();
		else
			alert('Email invalido, tente novamente!');
	}
}

function enviar_fale_conosco()
{
	my_email = document.getElementById('meu_email');
	my_nome  = document.getElementById('meu_nome');
	my_message = document.getElementById('minha_msg');
	fale = document.getElementById('conosco');

	if ( my_nome.value.length == 0 || my_message.value.length == 0 || my_email.value.length == 0 )
	{
		alert( 'Preencha os campos para enviar a mensagem!' );
	}
	else if ( !validar_email( my_email.value ) )
	{
		alert( 'Email invalido, tente novamente!' );
	}
	else
	{
		fale.submit();
	}
}
