/**
  * Flickr
  */
var feedUrl = "http://api.flickr.com/services/feeds/photos_public.gne?id=49722377@N07&lang=en-us&format=json&jsoncallback=?";
        // Don't execute any code until the DOM is ready!
        $(document).ready(function() {

            // Our very special jQuery JSON fucntion call to Flickr, gets details of the most recent 20 images
            $.getJSON(feedUrl, displayImages);

            function displayImages(data) {
                // Randomly choose where to start. A random number between 0 and the number of photos we grabbed (20) minus 9 (we are displaying 9 photos).
                var iStart = 0;  //Math.floor(Math.random() * (11));

                // Reset our counter to 0
                var iCount = 0;

                // Start putting together the HTML string
                var htmlString = '<ul class="mh-flickr">';

                // Now start cycling through our array of Flickr photo details
                $.each(data.items, function(i, item) {

                    // Let's only display 9 photos (a 3x3 grid), starting from a random point in the feed					
                    if (iCount > iStart && iCount < (iStart + 9)) {

                        // I only want the ickle square thumbnails
                        var sourceSquare = (item.media.m).replace("_m.jpg", "_s.jpg");

                        // Here's where we piece together the HTML
                        htmlString += '<li><a href="' + item.link + '"  onclick="window.open(this.href, \'_blank\', \'\'); return false;" onkeypress="window.open(this.href, \'_blank\', \'\'); return false;">';
                        htmlString += '<img src="' + sourceSquare + '" alt="' + item.title + '" title="' + item.title + '"/>';
                        htmlString += '</a></li>';
                    }
                    // Increase our counter by 1
                    iCount++;
                });

                // Pop our HTML in the #images DIV
                $('#feedFlickr').html(htmlString + "</ul>");

                // Close down the JSON function call
            }

            // The end of our jQuery function	
        });
