function update(id) { id=escape(id);$.post(document.location.protocol+'//'+document.domain+'/utils',{p_id:id});}

function update_comment(data){
	if(data.length >0) {
		$arr=data.split(';');
		$('#nota_'+$arr[0]).html($arr[1]);
		if ($arr[2]=='S')
			mostrar($arr[0]);
		else
			ocultar($arr[0]);
	}
}

function bajar(id) { $.get(document.location.protocol+'//'+document.domain+'//comentarios/down/'+id, '', update_comment);} 
function subir(id) { $.get(document.location.protocol+'//'+document.domain+'/comentarios/up/'+id, '', update_comment);}

function mostrar(id) {
	$('#comment_hiddem_'+id).hide();
	$('#comment_header_'+id).show();
	$('#commet_body_'+id).show();
}

function ocultar(id) {
	$('#comment_hiddem_'+id).hide();
	$('#comment_header_'+id).show();
	$('#commet_body_'+id).show();
}

function validarEmail(valor) { 	return ( /^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/.test(valor));}

function ValidarComment(){
	if (document.frm_comment.nombre.value=='')		{ alert('Debe ingresar Nombre');				document.frm_comment.nombre.focus();	return false;}
	if (document.frm_comment.email.value=='')		{ alert('Debe ingresar direccion de Correo');	document.frm_comment.email.focus();		return false;}
	if (!validarEmail(document.frm_comment.email.value)) { alert('Debe ingresar una direccion de Correo Valida');	document.frm_comment.email.focus();		return false;}
	if (document.frm_comment.comment.value=='')		{ alert('Debe ingresar comentario');			document.frm_comment.comment.focus();	return false;}

    texto=document.frm_comment.comment.value;
	sw=false;msgError='';numLetras=texto.length;numMayusculas=0;

	for (i=0;i<numLetras;i++) if (texto.charAt(i)>='A' && texto.charAt(i)<='Z')	numMayusculas++;
    
	if (numLetras>11 && numMayusculas>numLetras/4) {sw=true; msgError="Shift overload";}
	else {
		textoLower=' '+texto.toLowerCase();
		seed = new Array('wenas','wapo','wapa','weno','fabor','kiero','plis ','pliss','plisss','grasias','antebraso',' i ','kuando',' ke ',' k ',' q ',' kon ',' d ',' pq',' xq','aaaa','eeee','iiii','oooo','uuuu','jajajajajaja','hahahaha','jejejejejejejeje','!!!!','????','....','?!?!?!?!?!?!','!?!?!?!?!?!?!','dddd','ffff','gggg','jjjj','llll','mmmm','nnnn','rrrr','xxxxx','zzzz','ssss','asdasd');
		for (i=0;i<seed.length;i++) if (textoLower.indexOf(seed[i])!=-1){sw=true; msgError=seed[i];	break;	}	
	}
	if (sw){	
		alert ('ALERT: Anti Filter FAIL!\n\n>>Offending Command: \''+msgError+'\'\n\nRevise su mensaje y vuelva a intentarlo, por favor.\n\nSi el problema persiste, puede solucionarlo accediendo a:\nwww.RAE.es\n');
		document.frm_comment.comment.focus();	
		return false;
    }
	document.getElementById("bt_submit_comment").value = "Enviando...";document.getElementById("bt_submit_comment").disabled = true;
	document.frm_comment.submit();
    return true;
}

