$(document).ready(function() {	
	/*
	$('#gallery_links a').each(function(){
		$(this).click(function() {
			$('#gallery_title').html('<img src="/images/load.gif" />');
			galContent = $(this).attr('href')+' #gallery_thumbs';
			gal = $(this).attr('title');
			getPage(galContent,gal);
			return false;
		});
	});
	*/
	
	$('#gallery_select').change(function() {
		$('#gallery_title').html('<img src="/images/load.gif" />');
		galContent = 'media.cfm?gid=' + $(this).val() + ' #gallery_thumbs';
		gal = $('#gallery_select :selected').text();
		getPage(galContent,gal);
		return false;		
	});
	initGallery();		
});

function getPage(content,title) {
	$('#gallery').slideUp(200, function() {
		$('#gallery').load(content,'',function() {
			$('#gallery').slideDown(200);
			initGallery();
			$('#gallery_title').html(title);
		});  
	}); 	
}	

function initGallery() {
	$("a.fb").fancybox({
		'transitionIn'	 :	'elastic',
		'transitionOut'	 :	'elastic',
		'speedIn'		 :	600, 
		'speedOut'		 :	200, 
		'titlePosition'  : 	'over',
		'overlayShow'	 :	false,
		//'overlayOpacity' :  0.8,
		'onComplete'	 : 	function() { $('#fancybox-title span').wrapInner('<a href="http://www.flickr.com/photos/47600485@N03" title="View this photostream" target="_blank"></a>'); } 			
	});
}
