$(document).ready(function()
{	
	// ### IE6 hover fix ###
	$('li').hover(function() { $(this).addClass('hover'); }, function() { $(this).removeClass('hover'); });
	
	// ### Product promo hovers ###
	$('.product .popup').hide();
	$('.product').hover
	(
	 	function() { $(this).find('.popup').slideDown(); },
		function() { $(this).find('.popup').slideUp(); }
	);
	
	// ### Fade current product ###
	$('a .product, .programmes a img').each(function()
	{
		var a = $(this).parent();
		var href = $(a).attr('href');		
		var loc = window.location;			
		if (href == loc)
		{			
			$(this).fadeTo(1000, 0.25);
			if (jQuery.browser.msie && parseInt(jQuery.browser.version) == 8)
			{
				$(this).css('opacity', 1).fadeTo(1000, 0.25);
			}
		}
	});
	
	// ### About Us images ###
	// First we clear out anything that's not an image:
	var photos = $('.photos img');
	$('.photos').empty().append(photos);
	// Then we add the class 'large' to the first image:
	$('.photos img:first').addClass('large');
		
	// ### Rave reviews ###
	// Add classes 'review' and 'review-n' to each paragraph:
	var review = 1;
	var reviewLimit = 11;
	$('#rave-reviews p').each(function()
	{
		if (review <= reviewLimit)
		{
			$(this).addClass('review');
			$(this).addClass('review-' + review);
			++review;
		}
	});
	
	// ### Email to a friend link ###
	$('.email-link').click(function()
	{
		var url = window.location;
		var title = encodeURI(document.title);
		
		//alert('URL: ' + url + '\n\nTitle: ' + title);
		
		var windowURL = $('base').attr('href') + 'email-to-a-friend.php?url=' + url + '&title=' + title;
		var windowName = 'emailtoafriend';
		var windowAttributes = 'width=300,height=200,location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0';
		window.open(windowURL, windowName, windowAttributes);
		return false;
	});
});
