/**
 * @author bdgeorge
 * Variant Images routine for rotating swapping the images in product list views of product page views
 */
$(document).ready(function(){	

	/**
	 * On a Products listing page we look for every products_t_thumbnail class
	 * Within that object we look for anchors and replace their click action with an image swapper then preload their images
	 */
	//Look for any anchors inside the image_variants class		
	$('.products_t_thumbnail .image_variants a').each(function(){
		//For any that we find give them a new click event that swaps the target image
			$(this).click(function(){
				$(this)
					.parents('.products_t_thumbnail')
						.find("img:first")
							.attr('src',this.href);
				return false;			
			});
			//Preload their link target as an attached image
			this.ExtraImage= new Image();
			this.ExtraImage.src = this.href;
	});	
	/**
	 * On a product page we ....need to interact gracefully with the xcart variant code
	 */
	// TODO
});