// JavaScript Document
function validateUnsubscribe() {
	var email = document.forms["formUnsubscribe"].emailUnsubscribe.value;
	if(email == "") {
		alert("E-Mail obrigatório.");
		return false;
	}
	else {
		var regex = /\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/gi;
		if (email.match(regex))
			return true;
		else {
			alert("E-Mail inválido.");
			return false;
		}
	}
}


function validateSubscribe(url) {

	var emailValue = document.forms["formNotes"].emailComm.value;
	var nomeValue = document.forms["formNotes"].nameComm.value;
	
	var name=document.forms["formNotes"].nameComm.value.length;
	var email=document.forms["formNotes"].emailComm.value.length;
	var comment=document.forms["formNotes"].comment.value.length;
	var tot=name+email+comment;
	var maluco=document.getElementById('email').value=((tot) % 3)+tot;
	
	if(emailValue == "" || nomeValue == "") {
		alert("Nome e E-Mail obrigatórios.");
		if(nomeValue == ""){
			document.forms["formNotes"].nameComm.focus();
		}
		else{
			document.forms["formNotes"].emailComm.focus();
		}
		return false;
	}
	else {
		var expressao=new RegExp("^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$");
		if (expressao.test(emailValue)){
			document.getElementById('barra_rolagem').style.display='block';
			//document.getElementById('barra_rolagem').innerHTML='<img src="'+ url +'layout/loading5.gif"/>';
			return true;
		}
		else {
			alert("E-Mail inválido.");
			document.forms["formNotes"].emailComm.focus();
			return false;
		}
	}	
}

function recomment(parent,html)
{
	if ((parent != ""))
	{
		html="<input type=\"hidden\" name=\"parentPid\" value=\""+parent+"\">"+html;
		html+="<BR>" + "<a href=\"#ancora_conteudo\" onClick=\"recomment('','&nbsp;');\">Clique caso queira comentar o conteúdo, e não mais o comentário</a>" + "<BR><BR><BR>";
		//location.hash="#ancora_conteudo";
	}
	document.getElementById("parent").innerHTML=html;
}

function open_pop (el) {
	var w = window.open(el.getAttribute('href'), '','status=yes,scrollbars=yes,resizable=yes', 'width=780,height=600');
	return !w;
}
