
$(document).ready(function()
{
    // This injects the Flickr function+json into the dom, loading it
    // and executing the below jsonFlickrFeed func.
    //
    flickrFeed_uri = "http://api.flickr.com/services/feeds/photos_public.gne?id=7794066@N08&format=json";
    $("#picts").after(
        $('<script />').
        attr({ src: flickrFeed_uri, type: 'text/javascript' })
    );
});


// Write HTML to picts page, fed from Flickr.
//
function jsonFlickrFeed(data)
{
    var picts = data.items;

    var pBox = $("#picts");
    $.each( picts, function( index, pic ){
        image_uri = pic.media.m.replace( /_m.jpg$/, '.jpg');
        thumb_uri = pic.media.m.replace( /_m.jpg$/, '_s.jpg');

	thumb = $('<img />').attr(
            { 
                src: thumb_uri,
                alt: pic.title
            }
        );
        item  = $('<a />').attr(
            {
                href: image_uri,
                'class': "highslide",
                onclick: "return hs.expand(this)"
            }
        );
        item.append( thumb ).appendTo( pBox );

        // just display the last 16 images
        return index == 15 ? false : true;
    });
}


