$(document).ready( function() {
   setupFavoritePostControls();
});


function setupFavoritePostControls()
{
   $.post(
           templateUri + "/ajax/favorite_post.php",
           { 
              action: 'check',
              fave:   post_ID
           },
           function(data) {
              var postquery = eval( '(' + data +')' );

              if (postquery['result']) {
                 $('#isfavoritepost').show();
                 $('#setfavoritepost').hide();
                 $('#unsetfavoritepost').show();
              }
              else {
                 $('#isfavoritepost').hide();
                 $('#setfavoritepost').show();
                 $('#unsetfavoritepost').hide();
              }
           }
        );
}



function setFavoritePost()
{
   $.post(
           templateUri + "/ajax/favorite_post.php",
           { 
              action: 'set',
              fave:   post_ID
           },
           function(data) {
              setupFavoritePostControls();
           }
        );
}


function unsetFavoritePost()
{
   $.post(
           templateUri + "/ajax/favorite_post.php",
           { 
              action: 'unset',
              fave:   post_ID
           },
           function(data) {
              setupFavoritePostControls();
           }
        );
}





