var CartnumOrTotals = true;
/* set to true if using totals on the top */
$(document).ready(function () {
	$(".proditem").each(function (j) {
		$(this).find("a.prodbutton").eq(0).click(function () {
			var pr = $(this).parent("div.proditem").find("img").eq(0);
			$.post('/index.php?spart&route=module/cart/callback',{product_id:$(this).next("input").eq(0).val(),quantity:'1',justone:'true',quantityonly:CartnumOrTotals},function (html) {

				var image = $(pr).offset();
				var cart  = $('span.cartnumm').offset();
				var l = image.left;
				$("div.outer").before('<img src="' + $(pr).attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;z-index:2000" />');
				var params = {top : cart.top + 'px',left : cart.left + 'px',opacity: 0.0,width : $('span.cartnumm').width(),height : $('span.cartnumm').height()};
				$('#temp').animate(params, 'slow',false,function () {$("#temp").remove();});
				if (CartnumOrTotals === true) {
           			       var str = html.split("<>");
		        	       var s = $('span.cartnumm').html()*1 + 1;
					$('span.cartnumm').html(s).next("span").html("items &#163;" + trim(str[1]));
					var w = 104 - $('span.cartnumm').width()*1;
					w = (w <= 90)?w:90;
					$('span.cartnumm').next('span').css("width",w+"px");
				} else {
					$('span.cartnumm').html(html);
				}
			});
		});
	});
});
$(".centralright").ready(function () {
	$(this).find("a.add").each(function (k) {
		$(this).click(function () {
			var pr = $(this).parent("div").parent("td").parent("tr").parent("tbody").find("img").eq(0);
			$.post('/index.php?spart&route=module/cart/callback',{product_id:$(this).next("input").eq(0).val(),quantity:'1',justone:'true',quantityonly:CartnumOrTotals},function (html) {

				var image = $(pr).offset();
				var cart  = $('span.cartnumm').offset();
				var l = image.left;
				$("div.outer").before('<img src="' + $(pr).attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;z-index:2000" />');
				var params = {top : cart.top + 'px',left : cart.left + 'px',opacity: 0.0,width : $('span.cartnumm').width(),height : $('span.cartnumm').height()};
				$('#temp').animate(params, 'slow',false,function () {$("#temp").remove();});
				if (CartnumOrTotals === true) {
	        		        var str = html.split("<>");
			                var s = $('span.cartnumm').html()*1 + 1;
					$('span.cartnumm').html(s).next("span").html("items &#163;" + trim(str[1]));
					var w = 104 - $('span.cartnumm').width()*1;
					w = (w <= 90)?w:90;
					$('span.cartnumm').next('span').css("width",w+"px");
				} else {
					$('span.cartnumm').html(html);
				}
			});
		return false;
		});
	});
});
