$(function(){
	/*
	 * Set up product image rotator
	 */
	var timer;
		
	var products = $('ol#product-range li > a');
	products.each(function(){
		var product = $(this);
		product
			.data('info',product.siblings('div').remove())
			.append('<span></span>')
			.mouseover(function(){
				$(this).each(hoverProduct);
				clearTimeout(timer);
			});
	});
	
	nextProduct(0,5000);
	
	function nextProduct(i,t) {
		timer = setTimeout(function(){
			products.eq(i).each(hoverProduct);
			nextProduct(i+1 < products.length ? i+1 : 0, t);
		},t);
	}
	
	function hoverProduct() {
		$('div#product-range-info').html($(this).data('info'));
		$(this).parent('li').find('span').fadeTo(150,1).end().siblings().find('span').fadeTo(150,0.5);
	}
	
	
	/*
	 * Initialise popup box for TV advert
	 */
	$('#btn-tv')
		.attr('href',function(){
			return $(this).attr('href')+'?popup'
		})
		.fancybox({
			zoomSpeedIn:0, 
			zoomSpeedOut:0,
			frameWidth:675,
			frameHeight:378,
			overlayShow:true
		});
		
	$('#other-markets').hover(function(){
		$(this).children('a').addClass('hover').siblings('div').fadeIn(100);
	},function(){
		$(this).children('a').removeClass('hover').siblings('div').fadeOut(100);		
	}).children('a').click(function(){
		return false;
	});

});
