function displayCommentResponses(id, action) {
	var link = 'desple_' + id;
	if(action == null) action == "";

	var objId = 'respuestas_' + id;
	if ($(objId).style.display == 'none' || action == "show") {
		$(objId).style.display = '';	
		$(link).className = 'up';
	} else {
		$(objId).style.display = 'none';
		$(link).className = 'down';
	}		
}

var elForm = null;

function submitComment(form, id, tipochunk, parentComment, showform) {	
	var limit = 5
	if (parentComment == null) {
		var parent = "";
	} else {
		var parent = "/" + parentComment;
	}

	if (showform == null) {
		showform == "true";
	}	
		        $('loading' + parentComment).style.display = 'block';
		        $('captchaForm' + parentComment).style.display = 'none';
	
	adnCommand("/comments/newComment/" + id + parent, "POST" ,"nick=" + encodeURIComponent(form.nombre.value) + "&text=" + encodeURIComponent(form.text.value) + "&mail=" + encodeURIComponent(form.mail.value) + "&captcha=" + encodeURIComponent(form.captcha.value),
		   function (ret) {
			var drawComments = function (oXML) {
					 document.getElementById("comentarios").innerHTML=oXML.responseText;
					 oXML.responseText.parseScripts();
					 if(parentComment != "") { 
						 displayCommentResponses('comentario_' + parentComment);
						 location.href="#comment_" + parentComment;
					 } else {
						 location.href="#a_comentarios";
					 }
				 }
			
			if(ret["code"] == 0 ){
				getChunk("/comments/showComments/" + id + "/" + tipochunk + "/" + limit + "/" + showform + "/" + parent, "comentarios", drawComments);
				ncomments = $C("numComments");
				for(var i; i < ncomments; i++){
					ncomments[i].innerHTML = ret["data"];
				}
			} else {
			        $('loading' + parentComment).style.display = 'none';
			        $('captchaForm' + parentComment).style.display = 'block';
				alert(ret["message"])
			}	
		}, true);

	return false;
}


