$(document).ready(function() {
	// Make flash messages disappear after ten seconds; hide blank ones entirely.
	$flashText = $('#flash_message').text();

	if ($.trim($flashText) != '') {
		$('#flash_message').slideDown('slow');
		setTimeout("$('#flash_message').slideUp('slow');", 10000);
	}

	// Use tabs on the product info page
	$('ul.tabs').tabs('div.panes > div');

	// Use the overlay (pop-up pictures) where appropriate
	$('a.overlay').colorbox();

	// Make the labels-in-textboxes disappear as required
	$('#NewsletterSubscriptionName').focus(function() {
		if ($(this).val() == 'Your Name') {
			$(this).val('');
		}
	});

	$('#NewsletterSubscriptionEmailAddress').focus(function() {
		if ($(this).val() == 'E-mail Address') {
			$(this).val('');
		}
	});

/*
	// Make the cart hover work
	$('#cart_link a').hover(function() {
		$('#your_cart').css('display', 'block');
	}, function() {
		$('#your_cart').css('display', 'none');
	});
*/

/*
 * The cart hovering is a fun one. Basically, whenever the user moves
 * her mouse cursor over the shopping cart link, a brief summary
 * of her cart should appear. It should stay on the screen until
 * her cursor is outside of both that initial trigger and also the
 * newly revealed cart summary.
 * 
 * There are several ways of doing this, but I've chosen the
 * following: I'm setting up two global variables that keep track of
 * whether the user's cursor is outside of the main trigger or not,
 * and also whether it's outside of the summary or not.  Moving the
 * cursor around not only updates one of these two variables, but
 * also checks the status of both to see if any action needs to
 * be performed.
 */

	// Make the cart hover work
	document.cartTrigger1 = false;
	document.cartTrigger2 = false;

	$('#cart_link a').hover(function() {
		document.cartTrigger1 = true;
		$('#your_cart').css('display', 'block');
	}, function() {
		document.cartTrigger1 = false;

		if (document.cartTrigger2 == false) {
			$('#your_cart').css('display', 'none');
		}
	});

	$('#your_cart').hover(function() {
		document.cartTrigger2 = true;
		$('#your_cart').css('display', 'block');
	}, function() {
		document.cartTrigger2 = false;

		if (document.cartTrigger1 == false) {
			$('#your_cart').css('display', 'none');
		}
	});

	/* The hero banner conflicts with jQuery tools */

});
