// site specific javascript stuff

$(document).ready( function(){
    $('body.node-type-past-work').each( popup_init );
});

function popup_init(){
    //console.log('popup_init()');
    
    // bind our function to the links
    $('a.imagecache-img_thumbnail_imagelink').click( show_popup );

    // hide popup and bind our click handler for the popup
    $('#past_work_popup').removeClass('closed');
    $('#past_work_popup').hide();
    $('#past_work_popup').click( hide_popup );
    
    //console.log('popup_init() done');
}

// load the popup with the image clicked and then show it
function show_popup(){
    //console.log('show_popup(), this:', this );
    $('#past_work_popup img').attr('src', '');
    
    // get the image source from the anchors href, and load as img src 
    var img_src = $(this).attr('href');
    $('#past_work_popup img').attr('src', img_src);
    
    $('#past_work_popup').show();
    
    return false;
}

function hide_popup(){
    //$(this).addClass('closed');
    $(this).hide();
    // revert src to none
    $('#past_work_popup img').attr('src', '');
}
