var reEmail1 = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
var reEmail2 = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
var reEmail3 = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
var reEmail = reEmail3;
var browserVersion = navigator.appVersion;
var browserName = navigator.appName;


function doEmail(pStr, pFmt)
{
	eval("reEmail = reEmail" + pFmt);
	if (reEmail.test(pStr)) {
		return "";
	} else if (pStr != null && pStr != "") {
		return (pStr + " NÃO é um endereço de e-mail válido.");
	}
} // doEmail

function updateCharCount(textareaId, spanId, maxSize) {
    	textarea = document.getElementById(textareaId);
    	if (textarea == null) {
      		return;
    	}
    	if (textarea.value.length > maxSize) {
		textarea.value = textarea.value.substring(0, maxSize);
	}
	document.getElementById(spanId).innerHTML = maxSize - textarea.value.length;
}

function openCaptcha(idComment){

	goshme.util.toogle('commentInserted',false);
	var nome 	 = document.getElementById("nomeComment").value;
	var email    = document.getElementById("emailComment").value;
	var emailConfirm = document.getElementById("emailCommentConfirm").value;
	
	if(emailConfirm != email){
		changeError('Os campos Email e Confirmar Email devem ser iguais.',idComment);
		return;
	}
	else{
		if(nome==''||email==''){
	   		changeError('Favor inserir todos os dados!',idComment);
	   		return;
	   	}
		else{
			if(doEmail(email,1) != ''){
		   		changeError(msg,idComment);
		   		return;
			}
			else{
				var cont     = document.getElementById("cont").value;
				cont = cont.replace(/[\n\r]/g, "<br />");
				cont = cont.replace(/\s+<br>/g, "<br />");
				cont = cont.replace(/<br>(<br>)+/g, "<br /><br />");
							    
			   	if(cont == ''){
			      changeError('Digite um texto no corpo do coment&aacute;rio!',idComment);
			   	  return;
			   	}
			   	else{
					var width = 180;
					var height = 210;
					var x = parseInt((screen.width-width)/2);
				  	var y = parseInt((screen.height-height)/2);
			  	 
					window.open('../../validCaptcha.jsp?id='+idComment, '', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width='+width+', height='+height+', top='+y+', left='+x);
				}	
			}
		}
	}
}

function iserirComentario(idComment){

	goshme.util.toogle('commentInserted',false);
	var nome 	 = document.getElementById("nomeComment").value;
	var email    = document.getElementById("emailComment").value;
	var respByMail = document.getElementById("respBymail");
	var newCommentBymail = document.getElementById("newCommentBymail");
	var emailConfirm = document.getElementById("emailCommentConfirm").value;
	
	var id_doc 	 = document.getElementById("id_doc");
	var artefato = document.getElementById("artefato");
	var cont     = document.getElementById("cont").value;
	var secao     = document.getElementById("secaoComment").value;
	
	cont = cont.replace(/%/g, "%25");
	cont = cont.replace(/[\n\r]/g, "<br />");
	cont = cont.replace(/\s+<br>/g, "<br />");
	cont = cont.replace(/<br>(<br>)+/g, "<br /><br />");
    
    var urlNoticia = document.location.href;
    
	var url = "../../ajax";
		var param = "id_doc="+id_doc.value;
		param += "&artefato="+artefato.value;
		param += "&cont="+  cont;
		param += "&secao="+  secao;
		param += "&nome="+  nome;
		param += "&idComment=" + idComment;
		param += "&email="+email;
		param += "&url="+urlNoticia;
		if(document.getElementById("id_pai") != null){
			param += "&id_pai="+document.getElementById("id_pai").value;
		}
		else{
			param += "&id_pai=-1";
		}
		if(document.getElementById("newsletterCB").checked){
			param += "&newsletter=true";
			if(document.getElementById("freqd").checked){
				param += "&freq=d";
			}
			if(document.getElementById("freqw").checked){
				param += "&freq=w";
			}
			if(document.getElementById("freqm").checked){
				param += "&freq=m";
			}
		}else{
			param += "&newsletter=false";
		}
		
		if(respByMail != null){
		param += "&notify="+respByMail.checked;
	}else{
		param += "&notify=false";
	}

		if(newCommentBymail != null){
		param += "&notifyNcomment="+newCommentBymail.checked;
	}else{
		param += "&notifyNcomment=false";
	}
		param += "&op=COMMENT";
		
		goshme.util.sendRequest( url, param,'POST');
	
	document.getElementById('charCount').innerHTML = 2048;
}

function createDiv(idComment, nome, data, comentario, secao, admin, id_pai, idDoc, email, artefato)
{
		var divTag = document.createElement("div");
		divTag.setAttribute('id','divCommentUser'+idComment);
		
		var divLinksComment = document.createElement("div");
		divLinksComment.setAttribute('id','linksComment'+idComment);
		divLinksComment.className = 'reportAbuse';

		if( browserName == "Microsoft Internet Explorer" ){
			divLinksComment.style.setAttribute('cssText', 'text-align:right;', 0);
		}
		else{
			divLinksComment.setAttribute('style','text-align:right;');
		}
		
		var conteudo = "";
		if(id_pai != -1){
			conteudo += "<span class='reportAbuse' style='color: #990000;'>Coment&aacute;rio inserido com sucesso!</span><br />";
		}
		conteudo += "<p class='data'><b>"+ nome +"</b> - "+data+"</p><p class='commentDesc' id='commentUser"+idComment+"'>"+comentario+"</p>";
		conteudo += "<div id='alertCommentUser"+idComment+"'></div>";

		divTag.innerHTML = conteudo;

		var conteudoLinks = "";
		if(id_pai != -1){
		
			if( browserName == "Microsoft Internet Explorer" && browserVersion.indexOf("MSIE 6") != -1 ){
				conteudoLinks += "<a id='replyComment"+id_pai+"' rel='nofollow' href='javascript:reloadToReply(\"?id="+id_pai+"\")' class='blue'>Responder</a>";
			}else{
				conteudoLinks += "<a id='replyComment"+id_pai+"' rel='nofollow' href='javascript:showReplyDiv(\""+id_pai+"\",\""+secao+"\",\""+email+"\",\""+nome+"\",\""+idDoc+"\",\""+artefato+"\")' class='blue'>Responder</a>";
			}
			conteudoLinks += "&nbsp;&nbsp;|&nbsp; <a href=\"javascript:reportAbuse('"+id_pai+"','"+secao+"','sim','nao')\"  rel='nofollow' class='blue' id='reportAbuse"+id_pai+"' >Abuso?</a>";
			if(admin=='1'){
				conteudoLinks += "&nbsp;|&nbsp; <a id='alert"+id_pai+"' href='javascript:void(0)' rel=\"nofollow\" onclick=\"removeConfirm('"+id_pai+"','"+secao+"', 'sim','nao')\" >Remover</a>";
			}
			divLinksComment.innerHTML = conteudoLinks;
			if(admin=='1'){
				respDivLink = divLinksComment;
				divLinksComment.setAttribute('id','linksComment'+id_pai);
				respDivLink.innerHTML = "<a id='alert"+idComment+"' href='javascript:removeConfirm(\""+idComment+"\",\""+secao+"\", \"sim\",\"nao\")' rel='nofollow' >Remover</a>";
				divTag.appendChild(respDivLink);
			}
			divTag.className = 'grayline reply';
			divComentario = document.getElementById('divCommentUser'+id_pai);
			divLinksCommentOld = document.getElementById('linksComment'+id_pai);
			divLinksComment.setAttribute('id',divLinksCommentOld.getAttribute('id'));
			divLinksCommentOld.parentNode.removeChild(divLinksCommentOld);
			divComentario.appendChild(divTag);
			divLinksComment.innerHtml = conteudoLinks;
			divComentario.appendChild(divLinksComment);
		}
		else{
			if( browserName == "Microsoft Internet Explorer" && browserVersion.indexOf("MSIE 6") != -1 ){
				conteudoLinks += "<a id='replyComment"+idComment+"' rel='nofollow' href='javascript:reloadToReply(\"?id="+idComment+"\")' class='blue'>Responder</a>";
			}else{
				conteudoLinks += "<a id='replyComment"+idComment+"' rel='nofollow' href='javascript:void(0)' class='blue' onclick='showReplyDiv(\""+idComment+"\",\""+secao+"\",\""+email+"\",\""+nome+"\",\""+idDoc+"\",\""+artefato+"\")'>Responder</a>";
			}
			conteudoLinks += "&nbsp;&nbsp;|&nbsp; <a href='javascript:void(0)' rel='nofollow' class='blue' id='reportAbuse"+idComment+"' onclick=\"reportAbuse('"+idComment+"','"+secao+"','sim','nao')\" >Abuso?</a>";
			if(admin=='1'){
				conteudoLinks += "&nbsp;|&nbsp; <a id='alert"+idComment+"' href='javascript:void(0)' class='blue' rel='nofollow' onclick=\"removeConfirm('"+idComment+"','"+secao+"', 'sim','nao')\" >Remover</a>";
			}
			divLinksComment.innerHTML = conteudoLinks;
			divTag.className = 'grayline';
			divComentario = document.getElementById('comentarios');
			divTag.appendChild(divLinksComment);
			divComentario.appendChild(divTag);
		}

		document.getElementById("cont").value='';

	}


function changeError(error,id){
	
	goshme.util.toogle('divErro'+id, true);
	document.getElementById('msgErro'+id).innerHTML=error;
	document.getElementById('charCount').innerHTML = (2048-document.getElementById("cont").value.length);
}

function moreComment(offset , numItens , doc , artefato, offsetAdd, showAll){


	var url = "../../ajax";
		var param = "offset="+offset;
		param += "&numItens="+numItens;
		param += "&id_doc="+doc;
		param += "&offsetAdd="+offsetAdd;
		param += "&artefato="+artefato;
		param += "&showAll="+showAll;
		param += "&op=MORE_COMMENT";
	goshme.util.sendRequest( url, param,'POST');
    
    return false;
}


function removeConfirm(idComentario, secao, mostra, confirm){
		var idlink = 'alert'+idComentario;
		if (mostra=='sim'){
			var y = getPosicaoElemY(idlink);
			var x = getPosicaoElemX(idlink)-(180-58);
			
			var conteudo = '<div id="confirm_remove" name="confirm_remove" style="z-index: 1000; display: block; width: 150px; background: #FFFFFF; position: absolute; top: '+y+'px; left:'+x+'px; border: 1px solid green; padding: 10px;">\n'; 
			conteudo += '\t<div align="right">\n';
			conteudo += '\t\t<a href="javascript:void(0)" rel="nofollow" style="color: green;" onclick="removeConfirm(\''+idComentario+'\',\''+secao+'\',\'nao\',\'nao\')">|X|</a>\n';
			conteudo += '\t</div>\n';
			conteudo += '\t<strong>Remover Comentário</strong>\n';
			conteudo += '\t<p>Tem certeza que deseja remover este comentário?</p>\n';
			conteudo += '\t<form action="" id="report_abuse" style="text-align: center;">\n';
			conteudo += '\t\t<input type="button"  value="Sim"  onclick="removeConfirm(\''+idComentario+'\',\''+secao+'\',\'nao\',\'sim\')" />\n';
			conteudo += '\t\t<input type="button" value="Nao" onclick="removeConfirm(\''+idComentario+'\',\''+secao+'\',\'nao\',\'nao\')" />\n';
			conteudo += '\t</form>\n';
			conteudo += '</div>\n';
		
			divComment = document.getElementById('alertCommentUser'+idComentario);
			divComment.innerHTML = conteudo;
			
		}
		if(confirm == 'sim'){
			delComment(idComentario);
		}
		if(mostra == 'nao' && confirm == 'nao'){
				var divReport = document.getElementById('alertCommentUser'+idComentario);
				divParent = document.getElementById('divCommentUser'+idComentario);
				divParent.removeChild(divReport);
				var newDiv = document.createElement("div");
				newDiv.setAttribute('id','alertCommentUser'+idComentario);
				divReport = newDiv;
				divParent.appendChild(divReport);
		}
}

function delComment(idComment){
	
	var divComment = document.getElementById("divCommentUser"+idComment);
	var urlNoticia = document.location.href;
	    
	var url = "../../ajax";
		var param = "idComment="+idComment;
		param += "&op=DELETE";
		goshme.util.sendRequest( url, param,'POST');
	divComment.parentNode.removeChild(divComment);
	updateNumComment('remove');
}

function reportAbuse(idComentario, secao, mostra, confirm){

		var idlink = 'reportAbuse'+idComentario;
		if (mostra=='sim'){
			var y = getPosicaoElemY(idlink);
			var x = getPosicaoElemX(idlink)-(220-63);

			var conteudo = '<div id="confirm_report" name="confirm_report" style="z-index: 1000; display: block; width: 220px; background: #FFFFFF; position: absolute; top: '+y+'px; left:'+x+'px; border: 1px solid green; padding: 10px;">\n'; 
			conteudo += '\t<div align="right">\n';
			conteudo += '\t\t<a href="javascript:void(0)" rel="nofollow" style="color: green;" onclick="reportAbuse(\''+idComentario+'\',\''+secao+'\',\'nao\',\'nao\')">|X|</a>\n';
			conteudo += '\t</div>\n';
			conteudo += '\t<strong>Comunicar abuso no comentário</strong>\n';
			conteudo += '\t<p>Para nos informar sobre conteúdo ofensivo neste comentário clique em confirmar.</p>\n';
			conteudo += '\t<form action="" id="report_abuse" style="text-align: center;">\n';
			conteudo += '\t\t<input type="button"  value="Confirmar"  onclick="reportAbuse(\''+idComentario+'\',\''+secao+'\',\'nao\',\'sim\')" />\n';
			conteudo += '\t\t<input type="button" value="Cancelar" onclick="reportAbuse(\''+idComentario+'\',\''+secao+'\',\'nao\',\'nao\')" />\n';
			conteudo += '\t</form>\n';
			conteudo += '</div>\n';
			
			divComment = document.getElementById('alertCommentUser'+idComentario);
			divComment.innerHTML = conteudo;
		} 
		var divReport = document.getElementById('alertCommentUser'+idComentario);
		if(confirm == 'sim'){
			sendAbuse(idComentario,secao);
			divParent = document.getElementById('divCommentUser'+idComentario);
			divParent.removeChild(divReport);
		}
		if (mostra == 'nao' && confirm == 'nao'){
				divParent = document.getElementById('divCommentUser'+idComentario);
				divParent.removeChild(divReport);
				var newDiv = document.createElement("div");
				newDiv.setAttribute('id','alertCommentUser'+idComentario);
				divReport = newDiv;
				divParent.appendChild(divReport);
		}
}

function sendAbuse(idComentario, secao){
	urlNoticia = document.location.href;
	commentUser = goshme.util.getElement("commentUser"+idComentario).innerHTML;
	
	var url = "../../ajax";
		var param = "url="+urlNoticia;
		param += "&commentUser="+commentUser;
		param += "&secao="+secao;
		param += "&op=REPORT_ABUSE";
 	goshme.util.sendRequest( url, param,'POST');
	
	goshme.util.toogle('reportAbuse'+idComentario,false);
}

function getPosicaoElemX(idlink){
    var offsetTrail = document.getElementById(idlink);
    var offsetLeft = 0;
    var pos;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
    }
	pos = offsetLeft;
    return pos;
    
}	
function getPosicaoElemY(idlink){
    var offsetTrail = document.getElementById(idlink);
    var offsetTop = 0;
    var pos;
    while (offsetTrail) {
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetTop += document.body.topMargin;
    }
    pos = offsetTop;
    return pos; 
}

function updateNumComment(op){
	var numComment	 = document.getElementById("numComment").innerHTML;
	numComment = numComment.replace(/^\s*/, "").replace(/\s*$/, "");
	if(op == 'add'){
		var num = parseInt(numComment)+1;
		document.getElementById("numComment").innerHTML = " "+num+" ";
		if(num > 1)
			document.getElementById("plural").innerHTML = "s";
	}
	if(op == 'remove'){
		var num = parseInt(numComment)-1;
		document.getElementById("numComment").innerHTML = " "+num+" ";
		if(num <= 1)
			document.getElementById("plural").innerHTML = "";
	}
}

function retFalse(){
	return false;
}

function showNewsletterDiv(){
	if(document.getElementById("newsletterCB").checked == true){
		goshme.util.toogle('newsletterDiv',true);
	}
	else{
		goshme.util.toogle('newsletterDiv',false);
	}
}

function showReplyDiv(idComment, secao, email, nome, idDoc, artefato){

	closeReply('replyDiv');

	var replyDiv = document.createElement('div');
	if( browserName == "Microsoft Internet Explorer" ){
		replyDiv.style.setAttribute('cssText', 'border: 2px solid #D1D1D1; padding: 8px; background-color:#D3D3D3; margin-left:20px;', 0);
		replyDiv.id = 'replyDiv';
	}
	else{
		replyDiv.setAttribute('id','replyDiv');
		replyDiv.setAttribute('style','border: 2px solid #D1D1D1; padding: 8px; background-color:#D3D3D3; margin-left:20px;');
	}
	content ='	<span style="font-size:100%; text-align: left;"><b>Responder comentario</b></span>'+
				'	<form id="comment_formmain_comment2" name="comment_formmain_comment2" onsubmit="return false" method="post" action="">' +
				'		<input type="hidden" name="id_doc" id="id_doc" value="'+idDoc+'">' +
				'		<input type="hidden" name="id_pai" id="id_pai" value="'+idComment+'">' +
				'		<input type="hidden" name="artefato" id="artefato" value="'+artefato+'">' +
				'		<input type="hidden" name="secaoComment" id="secaoComment" value="'+secao+'">' +
				'' +	
				'		<table>' +
				'			<tr>' +
				'				<td colspan="2">' +
				'					<div id="divErro'+idComment+'" style="display: none; border: 1px solid #F5F5F5; margin: 2px; background: #FFFFDF;">' +
				'						<div id="msgErro'+idComment+'">' +
				'						</div>' +
				'						<input type="button" onclick="goshme.util.toogle(\'divErro'+idComment+'\', false)" value="Ocultar">' +
				'					</div>' +
				'				</td>' +
				'			</tr>';
	if(email != null && email != '' && nome != null && nome != ''){
		content += '				<input type="hidden" name="nome"  id="nomeComment" value="'+nome+'">' +
					'				<input type="hidden" name="email" id="emailComment" value="'+email+'">';
					'				<input type="hidden" name="emailCommentConfirm" id="emailCommentConfirm" value="'+email+'">';
	}
	else{					
		content += '			<tr>' +
					'				<td align="right">' +
					'					<b>Nombre</b>' +
					'				</td>' +
					'				<td align="left">' +
					'					&nbsp;&nbsp;<input type="text" id="nomeComment" maxlength="50" name="nome" value="" size="30">' +
					'				</td>' +
					'			</tr>' +
					'			<tr>' +
					'				<td align="right">' +
					'					<b>Correo Electrónico</b>' +
					'				</td>' +
					'				<td align="left">' +
					'					&nbsp;&nbsp;<input type="text" id="emailComment" size="30" maxlength="210" name="email" value="">' +
					'				</td>' +
					'			</tr>' +
					'			<tr>' +
					'				<td align="right">' +
					'					<b>Confirmar correo electrónico</b>' +
					'				</td>' +
					'				<td align="left">' +
					'					&nbsp;&nbsp;<input type="text" id="emailCommentConfirm" size="30" maxlength="210" name="emailConfirm" value="">' +
					'				</td>' +
					'			</tr>';	
	}
	content += '			<tr>' +
				'				<td colspan="2">' +
				'					<textarea cols="50" rows="6" style="margin-botton:2px;" name="cont" id="cont" onKeyUp="updateCharCount(\'cont\', \'charCount\', 2048)"></textarea><br />' +	
				'					Introducir más&nbsp;<b><span id="charCount"></span></b>&nbsp;caracteres sin etiquetas HTML.<br />' +
				'				</td>' +
				'			</tr>' +
				'			<tr>' +
				'				<td colspan="2">'+
	            '					<p style="margin-bottom: 5px;"><input type="checkbox" id="respBymail" checked="checked"/><label> Notificarme por correo electrónico si mi comentario es respondida por otro usuario.</label></p>' +
	            '					<p style="margin-bottom: 5px;"><input type="checkbox" id="newCommentBymail"/><label>  Notificarme por correo electrónico sobre cualquier comentario nuevo.</label></p>' +
	            '					<p style="margin-bottom: 5px;"><input type="checkbox" id="newsletterCB" checked="checked" onchange="showNewsletterDiv()" onclick="showNewsletterDiv()"/><label> Enviarme las noticias más importantes por correo electrónico. ';
	if(secao=="noticias"){
		content += "jur&iacute;dicas";
	}else{
		content += "pol&iacute;ticas";
	}
	content +=  '					mais importantes por e-mail.</label></p>' +
				'					<div id="newsletterDiv" style="display: none; margin-left: 15px; margin-bottom: 5px;">' +
	            '						<p style="margin-bottom: 5px; margin-left: 2px;"><label>' +
				'					<input type="checkbox" id="freqd" name="freq" value="d" checked="checked" />' +
				'					Diariamente <br /><span style="margin-left: 15px; color: #666666;">(resumo do dia)</span></label></p>' +
				'					<p style="margin-bottom: 5px; margin-left: 2px;"><label>' +
				'					<input type="checkbox" id="freqw" name="freq" value="w"  />' +
				'					Semanalmente <br /><span style="margin-left: 15px; color: #666666;">(resumo da semana)</span></label></p>' +
				'					<p style="margin-left: 2px;"><label>' +
				'					<input type="checkbox" id="freqm" name="freq" value="m"  />' +
				'					Mensalmente <br /><span style="margin-left: 15px; color: #666666;">(resumo do mês)</span></label></p>' +
			    '					</div>' +
				'					<div id="desComment">' +
				'						<input type="button" onclick="openCaptcha('+idComment+')" name="submit" value="Enviar">' +
				'					</div>' +
				'					</td>' +
				'			</tr>' +
				'		</table>' +
				'		<p style="text-align: right;"><a class="blue" rel="nofollow" href="javascript:closeReply(\'replyDiv\')" title="Fechar">Cancelar |X|</a></p>' +
				'	</form>';
	replyDiv.innerHTML = content;
	var divComment = document.getElementById('divCommentUser'+idComment);
	divComment.appendChild(replyDiv);

}

function closeReply(name){
	divReply = document.getElementById(name);
	if(divReply != null){
		divReply.parentNode.removeChild(divReply);
	}
}

function reloadToReply(element){
	url = window.location.href.replace(/(#comment)|(\?\S+)/,'');
	window.location = url + element;
}

function openNewComment(id,idDoc,secao,artefato,name,email){
	closeReply('replyDiv');
	if(id == null && document.getElementById('insertComment') == null){
		newCommentDiv = document.getElementById('commentInsert');
		newCommentDiv.className = "";
		newCommentDiv.style.display = "block";
		newCommentDivText = '	<div id="insertComment" onclick="closeReply(\'replyDiv\');">';
		newCommentDivText += '		<div id="commentInserted" class="reportAbuse" style="color: #990000; display: none;">';
		newCommentDivText += '			Comentário inserido com sucesso!';
		newCommentDivText += '		</div>';
		newCommentDivText += '		<span style="font-size:115%;"><b>Añadir nuevo comentario</b></span>';
		newCommentDivText += '		<form id="comment_formmain_comment" name="comment_formmain_comment" onsubmit="return false" method="post" action="" >';
		newCommentDivText += '			<input type="hidden" name="id_doc" id="id_doc" value="'+idDoc+'">';
		newCommentDivText += '			<input type="hidden" name="artefato" id="artefato" value="'+artefato+'">';
		newCommentDivText += '			<input type="hidden" name="id_pai" id="id_pai" value="-1">';
		newCommentDivText += '			<input type="hidden" name="secaoComment" id="secaoComment" value="'+secao+'">';
		newCommentDivText += '			<table>';
		newCommentDivText += '				<tr>';
		newCommentDivText += '					<td colspan="2">';
		newCommentDivText += '						<div id="divErro0" style="display: none; border: 1px solid #F5F5F5; margin: 2px; background: #FFFFDF;">';
		newCommentDivText += '							<div id=\'msgErro0\'>';
		newCommentDivText += '							</div>';
		newCommentDivText += '							<input type=\'button\' onclick="goshme.util.toogle(\'divErro0\', false)" value="Ocultar">';
		newCommentDivText += '						</div>';
		newCommentDivText += '					</td>';
		newCommentDivText += '				</tr>';
		if(email != null && email != '' && nome != null && nome != ''){
			newCommentDivText += '			<input type="hidden" name="nome"  id="nomeComment" value="${pageContext.request.userPrincipal.name}">';
			newCommentDivText += '			<input type="hidden" name="email" id="emailComment" value="${pageContext.request.userPrincipal.email}">';
			newCommentDivText += '			<input type="hidden" name="emailCommentConfirm" id="emailCommentConfirm" value="${pageContext.request.userPrincipal.email}">';
		}
		else{
			newCommentDivText += '	<tr>';
			newCommentDivText += '		<td align="right">';
			newCommentDivText += '			<b>Nombre</b>';
			newCommentDivText += '		</td>';
			newCommentDivText += '		<td align="left">';
			newCommentDivText += '			&nbsp;&nbsp;<input type="text" id="nomeComment" maxlength="50" name="nome" value="" size="30">';
			newCommentDivText += '		</td>';
			newCommentDivText += '	</tr>';
			newCommentDivText += '	<tr>';
			newCommentDivText += '		<td align="right"><b>Correo electrónico</b></td>';
			newCommentDivText += '		<td align="left">';
			newCommentDivText += '			&nbsp;&nbsp;<input type=\'text\' id="emailComment" size="30" maxlength="210" name="email" value="">';
			newCommentDivText += '		</td>';
			newCommentDivText += '	</tr>';
			newCommentDivText += '	<tr>';
			newCommentDivText += '		<td align="right">';
			newCommentDivText += '			<b>Confirmar correo electrónico</b>';
			newCommentDivText += '		</td>';
			newCommentDivText += '		<td align="left">';
			newCommentDivText += '			&nbsp;&nbsp;<input type=\'text\' id="emailCommentConfirm" size="30" maxlength="210" name="emailConfirm" value="">';
			newCommentDivText += '		</td>';
			newCommentDivText += '	</tr>';
		}
		newCommentDivText += '			<tr>';
		newCommentDivText += '				<td colspan="2">';
		newCommentDivText += '					<textarea cols="50" rows="6" style="margin-botton:2px;" name="cont" id="cont" onKeyUp="updateCharCount(\'cont\', \'charCount\', 2048)"></textarea><br />';
		newCommentDivText += '					Introducir más&nbsp;<b><span id="charCount"></span></b>&nbsp;caracteres sin etiquetas HTML.<br /><br />';
		newCommentDivText += '				</td>';
		newCommentDivText += '			</tr>';
		newCommentDivText += '			<tr>';
		newCommentDivText += '				<td colspan="2">';
		newCommentDivText += '		           <p style="margin-bottom: 5px;"><input type="checkbox" id="respBymail" checked="checked"/><label> Notificarme por correo electrónico si mi comentario es respondida por otro usuario.</label></p>';
		newCommentDivText += '		           <p style="margin-bottom: 5px;"><input type="checkbox" id="newCommentBymail"/><label> Notificarme por correo electrónico sobre cualquier comentario nuevo.</label></p>';
		newCommentDivText += '		           <p style="margin-bottom: 5px;"><input type="checkbox" id="newsletterCB" checked="checked" onchange="showNewsletterDiv()" onclick="showNewsletterDiv()"/><label> Enviarme las noticias más importantes por correo electrónico.'; 
	    newCommentDivText += '		           </label></p>';
		newCommentDivText += '		           <div id="newsletterDiv" style="display: none; margin-left: 15px; margin-bottom: 5px;">';
		newCommentDivText += '		            <p style="margin-bottom: 5px; margin-left: 2px;"><label>';
		newCommentDivText += '					<input type="checkbox" id="freqd" name="freq" value="d" checked="checked" />';
		newCommentDivText += '					Diariamente <br /><span style="margin-left: 15px; color: #666666;">(resumo do dia)</span></label></p>';
		newCommentDivText += '					<p style="margin-bottom: 5px; margin-left: 2px;"><label>';
		newCommentDivText += '					<input type="checkbox" id="freqw" name="freq" value="w"  />';
		newCommentDivText += '					Semanalmente <br /><span style="margin-left: 15px; color: #666666;">(resumo da semana)</span></label></p>';
		newCommentDivText += '					<p style="margin-left: 2px;"><label>';
		newCommentDivText += '					<input type="checkbox" id="freqm" name="freq" value="m"  />';
		newCommentDivText += '					Mensalmente <br /><span style="margin-left: 15px; color: #666666;">(resumo do mês)</span></label></p>';
		newCommentDivText += '				   </div>';
		newCommentDivText += '					<div id=\'desComment\'>';
		newCommentDivText += '						<input type="button" onclick="openCaptcha(\'0\')" name="submit" value="Enviar">';
		newCommentDivText += '					</div>';
		newCommentDivText += '				</td>';
		newCommentDivText += '			</tr>';
		newCommentDivText += '		</table>';
		newCommentDivText += '	</form>';
		newCommentDivText += '</div><br />';
		//newCommentDivText += '<script type="text/javascript">
		//newCommentDivText += '		goshme.util.toogle(\'confirmAbuse\', false);
		//newCommentDivText += '		updateCharCount(\'cont\', \'charCount\', 2048);
		//newCommentDivText += '		document.getElementById("cont").value = "";
		//newCommentDivText += '</script>
		newCommentDiv.innerHTML = newCommentDivText;
	}
	if(id != null){
		reloadToReply('#comment');
	}
}