function showContenido(id)
{
    var img = $("#aShowContent"+id).css('background-image');
    
    if( img.indexOf('btnClose') > 0 )
        $("#aShowContent"+id).css({'background-image' : 'url(/BurgosAZ/public/images/btnOpen.jpg)'});
    else
        $("#aShowContent"+id).css({'background-image' : 'url(/BurgosAZ/public/images/btnClose.jpg)'});
        
    $("#pContenido"+id).slideToggle();
}

function publicar(value, post)
{  
    $("#spBotones"+post).fadeOut(700);
    $.get("index.php",
        { controlador: "posts", accion: "publicar", publicar: value, idPost: post },
        function(data){
            $("#spBotones"+post).fadeIn(700);
            setTimeout(function(){$("#spBotones"+post).html(data)},700);
            if( value == '1' )
                $('#spTitListAdmin'+post).css({'background-image' : 'url(/BurgosAZ/public/images/icoPublished.jpg)'});
            else
                $('#spTitListAdmin'+post).css({'background-image' : 'url(/BurgosAZ/public/images/icoNoPublished.jpg)'});
        }
    );
    
}

function borrar(post)
{
    if( confirm("¿Eliminar esta entrada? Esto no puede deshacerse."))
    {
        $("#dvPost"+post).fadeOut(700);
        $.get("index.php",
            { controlador: "posts", accion: "borrar", idPost: post },
            function(data){            
                // Mensaje de eliminado
                setTimeout(function(){$("#dvPost"+post).remove()},700);
            }
        );
    }
    
}

function calendario(id)
{
    $("#"+id).datepicker();
}

function showW(uri, txt)
{
    window.open('views/'+uri, txt, 'width=600, height=300, toolbar=no');
}

function edit(id)
{
    $("#pComm"+id).toggle();
    $("#editComm"+id).toggle();
    $("#btnEdit"+id).toggle();
    $("#btnSave"+id).toggle();
}

function save(value, post)
{  
    //$("#spBotones"+post).fadeOut(700);
    $.post("index.php?controlador=posts&accion=guardaComm",
        { texto: value, idPost: post },
        function(data){
      //      $("#spBotones"+post).fadeIn(700);
      //      setTimeout(function(){$("#spBotones"+post).html(data)},700);
      //      if( value == '1' )
      //          $('#spTitListAdmin'+post).css({'background-image' : 'url(/BurgosAZ/public/images/icoPublished.jpg)'});
      //      else
      //          $('#spTitListAdmin'+post).css({'background-image' : 'url(/BurgosAZ/public/images/icoNoPublished.jpg)'});
            $("#pComm"+post).html(data);
            edit(post);
        }
    );
    
}