// LiteBox v0.1 - jQuery lightbox plugin (function ($) { var origin; var dummy; $.fn.litebox = function () { origin = this; // Create empty div at the place of the original element and replace it // later when the litebox is closed. dummy = $('
').hide().insertBefore(origin).bind('close-litebox', function () { $(this).replaceWith(origin); }); $('body').append('
'); $('body').append('
'); origin.appendTo('#litebox'); addEvents(); }; function close() { $(dummy).trigger('close-litebox'); $('#litebox-overlay').remove(); $('#litebox').remove(); } function addEvents() { $('#litebox-overlay').click(function () { close(); }); } }(jQuery));