(function($) {

	// click to big pictures
	$.fn.click_to_big = function() {
		return this.each( function() {
			var image = new Image();

			image.onload = function() {

				var $container = $( "<div class='big_pic' />" ).append( image );
				var img = $container.find( "img" ).get( 0 );

				$container.css( "height", $( "body" ).height()+"px" );
				$( "body" ).prepend( $container );

				var posX = $( self ).scrollTop() + ( $( self ).height()/2 - img.height/2 );
				var posY = $( self ).width() / 2 - img.width / 2;

				$( img ).css( "top", posX+"px" );
				$( img ).css( "left", posY+"px" );

				$container.fadeIn( "fast" );
				$container.bind( "click", function() {
					$container.fadeOut( "fast", function() {
						try {
							$( $container ).remove();
						} catch (err) {}
					});
				});

			};

			image.src = this.href;




		});
	};
})(jQuery);

