function setAccionComentario(idComentario)
{
	$("#"+idComentario+"_corto").hide();
	$("#"+idComentario+"_largo").show();
}

function textarea () 
{
	var maximos = new Array ();
	$("textarea").attr("maxlength", function (i) {
		if (maximos[i] = this.getAttribute('maxlength')) {
			$(this).keypress(function(event) {
				return ((event.which == 8) || (event.which == 9) || (this.value.length < maximos[i]));
			});
		}
	});
}

function inicializar()
{
$(document).ready(function() {
  textarea();
    
     var options = { 
  	    beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
     }; 
    
    var v = $("#formulario").validate({
    		errorPlacement: function(label, element) {
    		label.insertAfter( element.prev().prev() );
    		},
    		submitHandler: function(form) {
 
				$(form).ajaxForm(options);
			}
		});
		});
		
  var secureKey = '<?=$_SESSION["secureKey"]?>';
}

function setVoto(tipo,msg,msgError,idBatalla)
{
    votado = $('#labelVotado').attr("votado");
	if (votado!=1)
	{
	 $.post("votar.php?votoT="+tipo+"&idBatalla="+idBatalla+"", function(data)
	 {
		 if (data==1)
		 {
			  valorActual = $("#contador_"+tipo).text();
			  valorActual=$("#contador_"+tipo).text(parseInt(valorActual)+1);
			  $("#img_"+tipo).hide("puff", {}, 600);
			  $("#img_"+tipo).show("puff", {}, 600);
		 }
		 else
		 {
	  		showDialog(msg,msgError);
	 	}
	 	$('#labelVotado').attr("votado","1");
	 	$('#labelVotado').text(msgError);
	 });
	 }
	 else
	 {
	  	$('#labelVotado').text(msgError);
	  	showDialog(msg,msgError);
 	 }

}

function showDialog(msg,title)
{
   $("<div id='dlg1'>"+msg+"</div>").dialog(
    {modal: true, 
    title:'Aviso',
    height:'auto',
    overlay:{background:'#000000', opacity:0.6}
    });
}		
	
function showRequest(formData, jqForm, options) 
{ 
    var result= $("#formulario").validate().form();
  	if (!result)
  	{
  		return false;
  	}
  	else
  	{
  	    $.blockUI({ message: '<h1><img src="images/busy.gif" /> </h1>' }); 
		return true;
	} 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  
{ 
  $('#comentarios').html(responseText);
  $("#formulario").resetForm();
  alert('Publicaremos su comentario una vez validado');
  $.unblockUI();
} 
	
// Funcionalidad de las listas
function inicializarLista()
{
}


