	function getFlickr(userid, target, numberToDisplay) {

    var url = "http://api.flickr.com/services/feeds/photos_public.gne?id=" + userid + "&lang=en-us&format=json&jsoncallback=?";

    $.getJSON(url, displayImages);

    function displayImages(data) {
        var htmlString = "";

        var ctr = 0;
        $.each(data.items, function(i, item) {

            if (ctr < numberToDisplay) {
                var sourceSquare = 
                    (item.media.m).replace("_m.jpg", "_s.jpg");
                var sourceOrig = 
                    (item.media.m).replace("_m.jpg", ".jpg");

                htmlString += '<a href="' + sourceOrig + 
                    '" rel="facebox" title="' + item.title + 
                    '">';
                htmlString += '<img title="' + item.title + 
                    '" src="' + sourceSquare + '" ';
                htmlString += 'alt="' + item.title + 
                    '" style="opacity: 1;" />';
                htmlString += '</a>';
                ctr = ctr + 1
            }
        });

        $('#' + target).append(htmlString);

        //update image preview so we get 
        //the nice popup mouseovers on the images
        //Note: this uses the Image Preview Script, 
        //if not using it remove the below line.



        imagePopup();
    }
}	




this.imagePopup = function() {

    $(function() {
        $('#flickrphotos a').lightBox();
    });


}



this.imagePreview = function(){    
    /* CONFIG */
    xOffset = -20;
    yOffset = -100;
        
    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result
        
    /* END CONFIG */
    $("a.preview").hover(function(e){
        this.t = this.title;
        this.title = "";    
        var c = (this.t != "") ? "<br/>" + this.t : "";
        $("body").append("<p id='preview'><img src='"+ 
            this.href +"' alt='Image preview' />"+ c +"</p>");                                 
        $("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px")
            .fadeIn("fast");                        
    },
    function(){
        this.title = this.t;    
        $("#preview").remove();
    });    
    $("a.preview").mousemove(function(e){
        $("#preview")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px");
    });            
};


// starting the script on page load
$(document).ready(function(){
    imagePreview();
});
