(function($) {
    $(function() {
	    // ...code to run on dom ready
		
		// highlight & display first thumbnail for before and after function
		
		FirstBeforeAfterImageAlt = $('div.before-after-thumbs img:first').attr('alt');
		highlightThumb(FirstBeforeAfterImageAlt);
		showBeforeAfter("before-after-" + FirstBeforeAfterImageAlt);
		
		$('div.before-after-thumbs img').click(function() {
			//alert($(this).attr('alt'));
			highlightThumb($(this).attr('alt'));
			showBeforeAfter("before-after-" + $(this).attr('alt'));
		})
	});
	
	function showBeforeAfter(divId) {
		if ($('table#' + divId).css('display') != "table") {
			$('table.before-after-detail').css('display','none');
			$('table#' + divId).fadeIn();
		}
	}
	
	function highlightThumb(divAlt) {
			$('div.before-after-thumbs img').css('border','1px solid #ffffff');
			$('div.before-after-thumbs img[alt="' + divAlt + '"]').css('border','1px solid #d9d9d9');
	}
})(jQuery);	
		
