function abre_pop(url,titulo,pop_size_w,pop_size_h, scroll){
	pop = window.open(url,titulo,"toolbar=no,location=no,address=no,directories=no,status=no,menubar=no,scrollbars="+scroll+",resizable=no,copyhistory=yes,maximized=yes,width="+pop_size_w+",height="+pop_size_h);

}
var intLimpaTexto = true;

function validaMail(mailField){
    var strMail = mailField.value;
	var Parte;
	var Partes;
	var Contador;
	var Temp;

	if(strMail.indexOf(" ") >= 0)
	{
		return false;
	} else {
		Contador = 0;
		Partes = strMail.split("@");
		for(var i=0; i<Partes.length; i++)
		{
			if(Partes[i] == "")
			{
			    return false;
			} else {
                Contador++;
			}
		}
		if (Contador != 2)
		{
			return false;
		}

		Contador = 0;
		Temp = Partes[1];
		if((Temp.charAt(0) == ".") || (Temp.charAt(Temp.length) == "."))
		{
			return false;
	    } else {
			Partes = Temp.split(".");
			for(var j=0; j<Partes.length; j++)
			{
				if(Partes[j] == "")
				{
					return false;
				} else {
					Contador++;
				}
			}
			if (Contador < 2)
			{
				return false;
			}
			return true;
		}
	}
}

function fnValidaForm () {
	if (document.frmMail.txtNewsEmail.value == "") {
		document.frmMail.txtNewsEmail.focus();
		alert('Por favor, digite seu E-mail!');
	} else {
		if (!validaMail(document.frmMail.txtNewsEmail)) {
			alert('Você deve preencher o campo "E-mail" corretamente!');
			document.frmMail.txtNewsEmail.focus();
		} else {
			fnSubmete("pops/newsletter_cadastro.asp?txtNewsEmail="+document.frmMail.txtNewsEmail.value);
		}
	}
}

function fnClear(){
	if (intLimpaTexto){
		document.frmMail.txtNewsEmail.value = "";
		intLimpaTexto = false;
	}
}

function fnSubmete (strUrl){
	abre_pop(strUrl,'popNewsletter',258,180);
}


// Fale Conosco
function fnFaleEnviar () {
	if (document.frmFale.txtNome.value == "") {
		document.frmFale.txtNome.focus();
		alert('O campo "Nome" é obrigatório!');
	} else {
		if (document.frmFale.txtEmail.value == "") {
			document.frmFale.txtEmail.focus();
			alert('O campo "E-mail" é obrigatório!');
		} else {
			if (!validaMail(document.frmFale.txtEmail)) {
				alert('Você deve preencher o campo "E-mail" corretamente!');
				document.frmFale.txtEmail.focus();
			} else {
				if (document.frmFale.txtAssunto.value == "") {
					document.frmFale.txtAssunto.focus();
					alert('O campo "Assunto" é obrigatório!');
				} else {
					if (document.frmFale.txtMensagem.value == "") {
						document.frmFale.txtMensagem.focus();
						alert('O campo "Mensagem" é obrigatório!');
					} else {
						//document.all.item("lnkSubmit").href='#';
						document.frmFale.submit();
					}
				}
			}
		}
	}
}

// Valida Formulário
function fnFaleLimpar () {
	document.frmFale.txtNome.value = "";
	document.frmFale.txtEmail.value = "";
	document.frmFale.txtAssunto.value = "";
	document.frmFale.txtMensagem.value = "";
}

// Pop de Fale Conosco
function fnFaleConosco () {
	abre_pop('http://www.rtproducoes.com/pops/faleconosco.asp','FaleConosco',405,516);
}