// AJAX add/remove scripbook links.
function scrapbook(op, id, event)
{
    event.preventDefault();
    event.stopPropagation();
    $.post('/ajax/scrapbook.php', {
        op: op,
        image_id: id
    })
    if (op == 'add') {
        // Get the thing to animate.
        var img = $(event.target).parents('.commands').is('ul') ? $('#photodetail img') : $(event.target).siblings('.square');
        // Hide the link that was clicked.
        $(event.target).hide();
        // Animate the thing.
        img.TransferTo({
            to: 'scrapbook-link',
            duration: 400,
        	className: 'transferIndicator'
        })
    }
    if (op == 'remove') {
        $(event.target).parent().DropOutDown(400, function(){
            $(event.target).parent().hide()
            // Tell the user how many images are on the page.
            $('.commands .first').text($('#thumbnails').children(':visible').size() + ' images');
        })
    }
    if (op == 'remove_all') {
        $('#thumbnails').children(':visible').DropOutDown(400, function(){
            $(event.target).parent().prev().text('0 images');
            $(event.target).parent().hide()
        })
    }
    return false;
}

$(document).ready(function() {
    $('.square, .scrapbook-command').hover(function(){
        $(this).filter('.square').addClass('image-pop');
        $(this).prev('.square').addClass('image-pop');
    }, function(){
        $(this).filter('.square').removeClass('image-pop');
        $(this).prev('.square').removeClass('image-pop');
    })
})
