//* Copyright (c) 2008 Clint Bounds

$(function(){
	
	$('#logo-btn').animate({opacity: '.7'},"slow")
	.hover(function() {
		$(this).animate({opacity: '1'},"fast")		
	}, function() {
		$(this).animate({opacity: '.7'},"fast")
	});
	
// GALLERY CODE 
	$(".gallery").each(function(){
		if($(this).children("img").length > 1) {
			$(this).after('<div class="thumbs">' + $(this).html() + '</div>')
		}
	})
	
	var tnWidth = $(".gallery img:first").width() / 6 + "px"
	var tnHeight = $(".gallery img:first").height() / 6 + "px"
	
	var $thumbs = $('.thumbs img')
	$thumbs.width(tnWidth).height(tnHeight).addClass('border')
	$thumbs.animate({opacity: '.4'},1)
	
	$thumbs.hover(function() {
		if (!$(this).hasClass('current')) {
			$(this).animate({opacity: '1'},"fast")
		}
	}, function() {
		if (!$(this).hasClass('current')) {
		$(this).animate({opacity: '.4'},"fast")
		}
	});
	
	$('.thumbs').each(function(){
		var $thumbs = $(this).find("img")
		
		$thumbs.filter(":first").animate({opacity: '1'},1).addClass('current')
		
		$thumbs.click(function(event) {
			if (!$(event.target).hasClass('current')) {	// if not current thumb
				
				$thumbs.filter(".current")
				.removeClass('current')
				.animate({opacity: '.4'},1)
				
				$(event.target).addClass('current').animate({opacity: '1'},1,function() {
					var galleryObj = $(event.target).parent().prev('.gallery').find("img:first")
					galleryObj.fadeOut("fast", function() {
						galleryObj.attr('src', $(event.target).attr('src')).fadeIn("fast")
					});
				})
			}
		});
	})
	
})