/**
* Javascript for the shopping cart module ... specifically for adding a product
* to the cart from a product page.
*/
jQuery(document).ready(function($) {
	// save the page for use with continue shopping button
	$.cookie('HTTP_REFERER', window.location.href, {path: '/'});
	
	// restore scroll position if we came from the continue shopping link
	if ($.cookie('continueShopping')) {
		$(window).scrollTop($.cookie('scrollTop'));
		
		$.cookie('continueShopping', null, {path: '/'});
		$.cookie('scrollTop', null, {path: '/'});
	}
	
	$('.sell').each(function() {
		// get link container
		var cell = $(this).closest('td');
		
		// store pertinate data for the cell for easy/predictable switchout
		cell.data('href', $(this).attr('href'));
		cell.data('content', cell.html());
		cell.data('bgcolor', cell.css('background-color'));
		cell.data('width', cell.css('width'));
		
		cell.css('cursor','pointer').click(function() {
			//alert(cell.data('href'));
			window.location = cell.data('href');
			
			// save the vertical scroll location to return to later when we
			// use the continue shopping button
			$.cookie('scrollTop', $(window).scrollTop(), {path: '/'});
		}).mouseenter(function() {
			cell.html('');
			cell.css('width',cell.data('width'));
			cell.css('background','url(/images/shopping-cart.gif) top left no-repeat');
			cell.css('background-color','#000');
		}).mouseleave(function () {
			cell.html(cell.data('content'));
			cell.css('background','none');
			cell.css('background-color',cell.data('bgcolor'));
		});
	});
});

