function buyLink(product_id) { 
	
	

	
	
	
	
	//var buyLinkUrl = $.getJSON('/products/buy?ajax=1&pid=' + product_id , function(data) {
	var qtyToBuy_featured = $('#qtyToBuy_f_' + product_id).val();
	var qtyToBuy_normal = $('#qtyToBuy_n_' + product_id).val();	
	//alert('test = ' + qtyToBuy);
	
	if (qtyToBuy_featured > 1) { 
		var qtyToBuy = qtyToBuy_featured;	
	} else if (qtyToBuy_normal > 1) { 
		var qtyToBuy = qtyToBuy_normal;	
	}
	
	var buyLinkUrl = $.getJSON('/products/buy?ajax=1&pid=' + product_id + '&qty=' + qtyToBuy, function(data) {
		
		if (data['stocklevel'] < 1) { 
		
			alert('Sorry, this product is currently out of stock.');
				
		} else { 
			
		
		//$("body").animate({ scrollTop: 20 }, "slow");
		
		$('li#totalbasketitems').html('<img src="/images/icons/chart_bar.png" width="16" height="16" alt="Current Items In Basket" class="icon16px" />Current Items In Basket: ' + data['total_basket_items']);
		$('li#totalbasketvalue').html('<img src="/images/icons/money.png" width="16" height="16" alt="Current Total" />Current Total: &pound;' + data['total_basket_value']);
			
		var prodName = data['name'];
		prodName = prodName.substr(0,23) + '...';
		//alert('name = ' + prodName);
		
			// recently added
			var recentlyadded = '<div class="imagecontainer"><div class="img_top">&nbsp;</div><div class="img_cont"><img src="' + data['image_thumb'] + '" /></div><div class="img_bot">&nbsp;</div></div>';
			recentlyadded = recentlyadded + '<div class="clear">&nbsp;</div><div class="added_qty">Quantity: ' + data['qty'] + '</div>&nbsp;&nbsp;<div class="added_price">' + data['price'] + '</div><div class="clear spacer">&nbsp;</div>';
			$('#recentlyadded').html(recentlyadded);
			$('.recentlyadded').slideDown();

			if($('div#basketitem_' + data['product_id']).html() == null) {
				
				// any products at all??
				// currently no products at all
				if ($('#basketempty').html()) { 
					
					//basketstuff
					$('#basketempty').hide();
					$('#basketstuff').slideDown();
	
					var currentBasket = $('#basketitems').html();
					
					$('#basketitems').html(currentBasket + '<div class="basketitem" id="basketitem_' + data['product_id'] + '"><div class="item_del"><a href="/basket/removeitem?id=' + data['product_id'] + '" onClick="javascript:confirmDelete(\'/basket/removeitem?id=' + data['product_id'] + '\');return false;"><img src="/images/icons/cross.png" width="16" height="16" alt="Remove Item" /></a></div><div class="item_name">' + prodName + '</div><div class="item_qty">' + data['qty'] + '</div><div class="clear"></div></div><div class="clear"></div>');
					$('#totalbasketitems').html('<img src="/images/icons/chart_bar.png" width="16" height="16" alt="Current Items In Basket" class="icon16px" />Current Items In Basket: ' + data['total_basket_items']);
					$('#baskettotal').html('&pound;' + data['total_basket_value'] + ' <small>' + data['pricevat'] + ' VAT</small>');
					
					
				// basket has some products - but not this one	
				} else { 
				
					// doesn't yet exist
					// add it to the html, but with existing stuff already there too.
					var currentBasket = $('#basketitems').html();
					
					$('#basketitems').html(currentBasket + '<div class="basketitem" id="basketitem_' + data['product_id'] + '"><div class="item_del"><a href="/basket/removeitem?id=' + data['product_id'] + '" onClick="javascript:confirmDelete(\'/basket/removeitem?id=' + data['product_id'] + '\');return false;"><img src="/images/icons/cross.png" width="16" height="16" alt="Remove Item" /></a></div><div class="item_name">' + prodName + '</div><div class="item_qty">' + data['qty'] + '</div><div class="clear"></div></div><div class="clear"></div>');
					$('#totalbasketitems').html('<img src="/images/icons/chart_bar.png" width="16" height="16" alt="Current Items In Basket" class="icon16px" />Current Items In Basket: ' + data['total_basket_items']);
					$('#baskettotal').html('&pound;' + data['total_basket_value'] + ' <small>' + data['pricevat'] + ' VAT</small>');
						
				}
				
				
			} else {
				
				// already exists
				$('div#basketitem_' + data['product_id']).html('<div class="item_del"><a href="/basket/removeitem?id=' + data['product_id'] + '" onClick="javascript:confirmDelete(\'/basket/removeitem?id=' + data['product_id'] + '\');return false;"><img src="/images/icons/cross.png" width="16" height="16" alt="Remove Item" /></a></div><div class="item_name">' + prodName + '</div><div class="item_qty">' + data['qty'] + '</div><div class="clear"></div>');
				$('#totalbasketitems').html('<img src="/images/icons/chart_bar.png" width="16" height="16" alt="Current Items In Basket" class="icon16px" />Current Items In Basket: ' + data['total_basket_items']);
				$('#baskettotal').html('&pound;' + data['total_basket_value'] + ' <small>' + data['pricevat'] + ' VAT</small>');
				
			}


			$('#totalbasketitems').animate({backgroundColor: '#ff9933'}, 400 );
			$('li#basketitem_' + data['product_id']).animate({backgroundColor: '#ff9933'}, 400 );
			$('li#totalbasketvalue').animate({backgroundColor: '#ff9933'}, 400 );
			$('#totalbasketitems').animate({backgroundColor: '#ffffff'}, 400 );
			$('li#basketitem_' + data['product_id']).animate({backgroundColor: '#ffffff'}, 400 );
			$('li#totalbasketvalue').animate({backgroundColor: '#ffffff'}, 400 );
			
			$('#totalbasketitems').animate({backgroundColor: '#ff9933'}, 400 );
			$('li#basketitem_' + data['product_id']).animate({backgroundColor: '#ff9933'}, 400 );
			$('li#totalbasketvalue').animate({backgroundColor: '#ff9933'}, 400 );
			$('#totalbasketitems').animate({backgroundColor: '#ffffff'}, 400 );
			$('li#basketitem_' + data['product_id']).animate({backgroundColor: '#ffffff'}, 400 );
			$('li#totalbasketvalue').animate({backgroundColor: '#ffffff'}, 400 );
			
			$('#totalbasketitems').animate({backgroundColor: '#ff9933'}, 400 );
			$('li#basketitem_' + data['product_id']).animate({backgroundColor: '#ff9933'}, 400 );
			$('li#totalbasketvalue').animate({backgroundColor: '#ff9933'}, 400 );
			$('#totalbasketitems').animate({backgroundColor: '#ffffff'}, 400 );
			$('li#basketitem_' + data['product_id']).animate({backgroundColor: '#ffffff'}, 400 );
			$('li#totalbasketvalue').animate({backgroundColor: '#ffffff'}, 400 );
			
			//$.scrollTo('#header', 10);
			//$.scrollTo('#header');
			
			$('.recentlyadded').animate({backgroundColor: '#ff9933'}, 400 );
			$('.recentlyadded').animate({backgroundColor: '#efefef'}, 400 );
			
			/*
			var msie = $.browser.msie();
			var version = $.browser.version.number();
			
			if (typeof document.body.style.maxHeight != "undefined") {
				// good browsers
				$('#basket_updated').slideDown('slow');
				setTimeout('$(\'#basket_updated\').slideUp()', 1500);
				//alert('good');
				
			} else { 
				// shit browsers
				$('#basket_updated').show();
				setTimeout('$(\'#basket_updated\').hide()', 2300);
				//alert('bad bad');
				
			}
			*/
			
	
				
		}
			  
  
	});
	
	//return false;
}
