function AbreJanela_Center( file, window, larg, altura)
{
    msgWindow=open(file,window,'directories=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no,width=' + larg + ',height='  + altura);
    msgWindow.moveTo(screen.width/2-larg/2,screen.height/2-altura/2-20);
	msgWindow.focus();
}

function AbreJanelaCenterScroll( file, window, larg, altura)
{
    msgWindow=open(file,window,'directories=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=no,width=' + larg + ',height='  + altura);
    msgWindow.moveTo(screen.width/2-larg/2,screen.height/2-altura/2-20);
	msgWindow.focus();
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function instr(texto,c,posInicial)
{
	if (posInicial<0) posInicial=0;				
	for(var i=posInicial; i<texto.length;i++)
	{
		if(texto.charAt(i)==c) return i;
	}
	return -1;
} 

function fncValidaEmail(mail) {
	var ponto = 0;
	var arroba = 0;
	var letra = 0;
	var i = 0;
	var l = mail.length;
	var ch = 0;
	if (l < 10)
		return (false);
	for (i = 0; i < l; i++) {
		ch = mail.charCodeAt(i);
		if (ch == 46) {
			ponto += 1;
		} else {
			if (ch == 64) {
				arroba += 1;
			} else {
				if (((ch >= 65) && (ch <= 90)) || ((ch >= 97) && (ch <= 122))) {
					letra += 1;
				} else {
					if ((ch != 45) && (ch != 95)) {
						if ((ch < 48) || (ch > 57)) {
							return (false);
						}
					}
				}
			}
		}
	}
	if ((arroba == 1) && (ponto > 0) && (letra > 9)) {
		return (true);
	} else {
		return (false);
	}
}

function fncValidaNewsletter()
{
	if(!fncValidaEmail(document.getElementById('frm_newsletter').dc_email.value))
	{
		alert('Por favor, preencher um e-mail válido.');
		document.getElementById('frm_newsletter').dc_email.focus();
		return false;	
	}
}