$.fn.thumbnail = function(baseURL){
    var serverURL = "http://capture.heartrails.com/300x300/border?";
    return this.each(function(){
        $(this).hover(
            function(e){
                var url = $(this).attr("href");
                if( url ){
                    var offsetTop = document.body.scrollTop  || document.documentElement.scrollTop;
                    var offsetBottom = offsetTop + $(window).height();
                    $("#jqThumbnail").attr("src",serverURL+url);
                    $("#jqThumbnail").css("left",e.pageX+40);
                    if(offsetBottom>=(e.pageY+300)){
                        $("#jqThumbnail").css("top",e.pageY+10);
                    }else{
                        $("#jqThumbnail").css("top",offsetBottom-300);
                    }
                    $("#jqThumbnail").show();
                }
            },
            function(){
                $("#jqThumbnail").hide();
            }
        );
    });
}
$(function(){
    $("body").append("<img src='' id='jqThumbnail' width='300' height='300' style='position:absolute;display:none'>");
    $("a").thumbnail();
});

