function setupThumbs(){
	$('#product_view_thumbs img').each(function(){
		var src = $(this).attr('src').replace('-thumb','');
		$(this).wrap('<a href="' + src + '" class="thumbbox" rel="thumbbox"></a>');
	});
	$('.thumbbox').fancybox({zoomOpacity: true});
	$('#product_view_thumbs img').mouseover(function(e){
		var src = $(this).attr('src').replace('-thumb','-preview');
		$('#product_view_image').attr('src',src);
		$('#product_view_image').attr('alt',$(this).attr('alt'));
	});
}

function setupProductImagePopup(){	
	$('#product_view_image').css('cursor','pointer');
	if($('#product_view_thumbs a').length === 0){
		// product has no thumbnails
		if($('#product_view_image').length){
			// check that we have an image to get the source of...
			var src = $('#product_view_image').attr('src').replace('-preview','');		
			$('#product_view_image').wrap('<a id="product_view_image_container" href="' + src + '"></a>' );
			$('#product_view_image_container').fancybox({zoomOpacity: true});
		}
	}else{
		// product has thumnails
		$('#product_view_image').click(function(e){
			var src = $('#product_view_image').attr('src').replace('-preview','');
			$('#product_view_thumbs a').each(function(){
				if($(this).attr('href') == src){
					$(this).click();
					return false;
				}
			});
		});
	}
}