/* General JavaScript Functions: */

$(document).ready(function() {
	
	// Add some border radii:
	$('.prod-dims').rounded(5);
	$('.board-review').rounded(5);
	$('.board-module').rounded(5);
	$('ul#navigation ul.child').rounded([ 0, 5 ]);
	$('form.new-layout').rounded(4);
	$('#dealerLogin').rounded([ 0, 5 ]);
	$('div.catalog-container > div').rounded(5);
	
	$('.autosize').autoexpand();
	
	// Hook up the show more bio:
	$('a.show-bio').click(function() {
		if($('div#more-bio').is(':visible'))
		{
			$('div#more-bio').slideUp('normal');
			$(this).html('Show complete bio');
		}
		else
		{
			$('div#more-bio').slideDown('normal');
			$(this).html('Hide complete bio');
		}
		
		// Prevent following blank anchor:
		return false;
	});
	
	// When they hover on a product image and there's a data-hoversrc, change it:
	$('img.product').mouseover(function() {
		var original_src = $(this).attr('src');
		var replacement_src = $(this).attr('data-hoversrc');
		var changed_flag = false;
		
		if(replacement_src != undefined && replacement_src != '' && replacement_src != null)
		{
			$(this).attr('src', replacement_src);
			changed_flag = true;
		}
		$(this).mouseleave(function() {
			if(changed_flag)
			{
				$(this).attr('src', original_src);
			}
		});
	});
	
	// When they click to reveal a board review, show it or hide it:
	$('a.board-review-reveal').click(function() {
		var the_review = $(this).parents('li').find('p.board-review');
		
		if(the_review.is(':visible'))
			the_review.slideUp();
		else
			the_review.slideDown();
			
		return false;
	});	
});
