$(document).ready(function(){
						   
	var doc_w = document.documentElement.clientWidth;
	var doc_h = document.documentElement.clientHeight;
	var img_w = doc_w-200;
	var img_h = doc_h-200;
	var w = $(document).width();
	var h = $(document).height();
	
	$('.exploding').parent('a').click(function(){
		$('body').prepend("<div id='lightbox' style='width:"+w+"px;height:"+h+"px'><div id='lightboxinner' style='width:"+doc_w+"px;height:"+doc_h+"px'></div></div>");
		$('#lightbox').css({opacity: 0, display: 'block'}).animate({opacity: 1}, 'slow');
		$('#lightbox img').remove();
		var img1 = $(new Image()).attr({'src': $(this).attr('href'), style: 'position:fixed;left:-9999px;top:-9999px'}).load(function(){
			if(img1.width() > img_w || img1.height() > img_h){
				if (img_w/img_h > img1.width()/img1.height()){
					$('#lightbox img').attr({'height': img_h});
				}
				else {
					$('#lightbox img').attr({'width': img_w});
				}
			}
			$('#lightbox img').css({top: (doc_h-img1.height())/2});
			$('#lightbox img').css({left: (doc_w-img1.width())/2});

		});
		$('#lightboxinner').append(img1);
		return false;
	});
	
	$('#lightbox').live('click', function(){
		$(this).animate({opacity: 0}, 'slow', function(){$(this).remove()});
	});
});
