$(document).ready(function(){$('<div id="simple-image-viewer"></div>').appendTo('body').hide();$('<div id="simple-image-viewer-loading">Loading...</div>').appendTo('body').hide();$('#simple-image-viewer').click(function(){$(this).fadeOut(300);});});$.fn.SimpleImageViewer=function(){return this.each(function(){$(this).find('a[@href$=".jpg"], a[@href$=".bmp"], a[@href$=".gif"], a[@href$=".png"]').click(function(){var imgTitle=($(this).attr('title')==undefined)?'':'<h2>'+$(this).attr('title')+'</h2>';var imgSrc=($(this).attr('href')==undefined)?'':'<p><img src="'+$(this).attr('href')+'" alt="" /></p>';var imgDesc=($(this).find('img').attr('alt')==undefined)?'':'<p>'+$(this).find('img').attr('alt')+'</p>';var preload=new Image();preload.src=$(this).attr('href');if(preload.complete){$('#simple-image-viewer').html(imgTitle+imgSrc+imgDesc).fadeIn(300).center();}else{$('#simple-image-viewer-loading').fadeIn(300).center();preload.onload=function(){$('#simple-image-viewer-loading').fadeOut(300);$('#simple-image-viewer').html(imgTitle+imgSrc+imgDesc).fadeIn(300).center();};}return false;});});};