/*
 * UKFast jQuery Gallery
 * Copyright (c) 2010 UKFast.Net Ltd
 *
 * Date:  6th May 2010
 * Version: 1
 *
 * ToDo List
 * - add image transitions
 * - add captions
 * - add next/prev buttons
 * - add slideshow
 */

//add gallery styles to the <head>
$('head').append('<link rel="stylesheet" href="/stylesheets/ukfgallery.css" type="text/css" />');

//if preview pane is available, add preview function to any gallery thumbs
if ( $('#ukfgallery_preview_img').length )
{
	$(document).ready(function() {    
		//set thumbnails to be opaque
		$('img[name=ukfgallery_thumb]').fadeTo("fast",0.4);
		
		//attach update function to all the <img> elements with the gallery tag
		$('img[name=ukfgallery_thumb]').click(function(e) {
			//update preview
			$('#ukfgallery_preview_img').attr('src', $(this).attr('src'));
			$('#ukfgallery_preview_img').attr('title', $(this).attr('alt'));
			
			//update thumbnails
			$('img[name=ukfgallery_thumb]').fadeTo("fast",0.4);
			$(this).fadeTo("fast",1);
			
			//preview transition effects
			$('#ukfgallery_preview_img').fadeTo("slow",1);
		});
	}); 
}