
	function imagy ( image_container, thumbs_container, padding ) {

		// okay, just make some action on click
		jQuery('#'+thumbs_container+'-inner a').click(function(){ showPicture(this); });

		var last_picture_id = jQuery("#"+thumbs_container+" a:first").attr('id');

		function showPicture(picture){
			
			last_picture_id = jQuery(picture).attr('id');
			var picture_url = jQuery(picture).attr('rel');
			var width = jQuery('#'+image_container+' img').width();
			var height = jQuery('#'+image_container+' img').height();
			var description = jQuery( jQuery(picture).children('span').get(0) ).html();

			var img = new Image();

			// make dimensions be fixed
			jQuery('#'+image_container)
				.addClass('loading')
				.css('width', width)
				.css('height', height);
			// fade out and remove image
			jQuery('#'+image_container+' > img').fadeOut('slow').remove();


			// wrap our new image in jQuery, then:
			jQuery(img)
				// once the image has loaded, execute this code
				.load(function () {
					// set the image hidden by default    
					jQuery(this).hide();

					// get new image dimensions
					var new_width = img.width;
					var new_height = img.height;

					// animate container dimensions
					// remove the loading class
					// and insert new image
					jQuery('#'+image_container)
						.animate({ 
								width: new_width+padding,
								height: new_height+padding
						}, 150 )
						.removeClass('loading')
						.append(this);
						
					jQuery(this).fadeIn();

				})

				// if there was an error loading the image, react accordingly
				.error(function () {
				// notify the user that the image could not be loaded
				})

				// *finally*, set the src attribute of the new image to our image
				.attr('src', picture_url);				
				

			jQuery('#photo-description').html(description);
			
		};
		
		
		function nextPicture(link) {
			
			var next = jQuery("#"+last_picture_id).next("a");
			if ( jQuery(next).attr('id') != null )
				showPicture( next );
			else
				showPicture( jQuery("#"+thumbs_container+" a:first") );
			
		}
		
		function previousPicture(link) {
					
			var prev = jQuery("#"+last_picture_id).prev("a");
			if ( jQuery(prev).attr('id') != null )
				showPicture( prev );
			else
				showPicture( jQuery("#"+thumbs_container+" a:last") );
			
		}


		// hover prev and next buttons
		jQuery('#prev, #next').hover(
			function(){
				jQuery(this).children('a').hide().css('left', '0px').fadeIn(300);				
			},
			function(){
				jQuery(this).children('a').fadeOut(300);
			}
		);
		
		jQuery('#next a').click(function(){
			nextPicture(this);
		});
		
		jQuery('#prev a').click(function(){
			previousPicture(this);
		});	

	} 

