/** Opacity Variables **/
var  opacityDim 	= '.3'
	,opacityFull 	= '1';


function view_feature (feature_id) {
	// Logic for flagging selected thumb
	$('.feature_thumb').removeClass('feature_thumb_current')
		.addClass('feature_thumb_not_current');
	$('img', '#thumb_' + feature_id).removeClass('feature_thumb_not_current')
		.addClass('feature_thumb_current');

	// reset all thumbnails
	// clear border on all thumbnails
	$('.feature_thumb').css('border', '1px solid transparent');
	$('.feature_thumb_not_current').animate({opacity: opacityDim});
	
	// set current thumbnail
	// add red border
	$('img', '#thumb_' + feature_id).css('border', '1px solid #990000')
		.css({opacity: opacityFull})
		.blur();
	
	// remove current content
	$('#feature-details').empty();

	// copy new content into 
	$('#feature-details').append($('#' + feature_id).html());
	
	// add rel attributes to anchor tags to create hooks for fancybox
	$('a.fbhook', '#feature-details').attr('rel', 'group_' + feature_id);

	Cufon.replace('h2'); // must recall cufon since content is hidden
	
	// scroll to top of the page when re-populating content
	$('html, body').animate({scrollTop:0}, 'slow');
	
	// attach fancybox events
	$('a[rel=group_' + feature_id + ']').fancybox({
		 'transitionIn'		:	'fade'
		,'transitionOut'	:	'fade'
		,'speedIn'			:	500
		,'speedOut'			:	500
		,'overlayColor'		: 	'#000'
		,'overlayOpacity'	: 	'.5'
	});
	
}


$(document).ready(function() {
	// default select first feature in #feature-backstage
	view_feature($('#feature-backstage > div:first').attr('id'));

	// Add mouseover dimming
	$('.feature_thumb').hover(
		function() {
			// animate hovered thumb to 1.0 if not already
			if(!$(this).hasClass('feature_thumb_current')) {
				$(this).animate({opacity: opacityFull});
			}
		},
		function() {
			// animate hovered thumb to 0.3 if not already
			if(!$(this).hasClass('feature_thumb_current')) {
				$(this).animate({opacity: opacityDim});
			}
		}
	); 
});

