$(document).ready(
    function () {
             $('#add_to_cart').removeAttr('onclick');
             $('#add_to_cart').click(function () {

$.ajax({
	type: 'post',
	url: '/?route=module/cart/callback',
	dataType: 'html',
	data: $(".productright :input"),
	success: function (html) {
		if (CartnumOrTotals === true) {
												var str = html.split("<>");
                        var s = $('span.cartnumm').html()*1 + 1;
                        $('span.cartnumm').html(s);
                        $('span.cartnumm').next("span").html("items &#163;" + str[str.length-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);
		}
	},
	complete: function () {
		var image = $('#image').offset();
                var cart  = $('#module_cart').offset();
                var l = image.left;
                $("div.outer").before('<img src="' + $('#image').attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;z-index:2000" />');									             	  	params = {top : cart.top + 'px',left : cart.left + 'px',opacity: 0.0,width : $('#module_cart').width(),height : $('#module_cart').height()};
		$('#temp').animate(params, 'slow',false,function () {$("#temp").remove();});
	}
});

/*
                 $.post('/index.php?spart&route=module/cart/callback',{options:options,quantity:$('#product input').eq(0).val(),changeq:true,product_id:$('#product input').eq(1).val(),quantityonly:CartnumOrTotals},
                         function (html) {
				 if (CartnumOrTotals === true) {
	                         	var str = html.split("<>");
                                 	var s = $('span.cartnumm').html()*1 + 1;
                                 	$('span.cartnumm').html(s);
                                 	$('span.cartnumm').next("span").html("items &#163;" + str[str.length-1]);
      				 	var w = $('span.cartnumm').width()*1;
                     		 	if (w > 90) {
		                        	$('span.cartnumm').next('span').css("width",(90-w)+"px");
		                 	}
				  } else {
					$('span.cartnumm').html(html);
				  }
				  var image = $('#image').offset();
                                  var cart  = $('#module_cart').offset();
                                  var l = image.left;
                                  $("div.outer").before('<img src="' + $('#image').attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;z-index:2000" />');									             	  params = {top : cart.top + 'px',left : cart.left + 'px',opacity: 0.0,width : $('#module_cart').width(),height : $('#module_cart').height()};
				  $('#temp').animate(params, 'slow',false,function () {$("#temp").remove();});
	               }
                 );
*/
             });


});

function buycombo(arr,masterid) {

         $.post('/index.php?spart&route=module/cart/addcombo',{arr:arr,masterid:masterid,quantityonly:CartnumOrTotals},
            function (html) {
                if (html.indexOf("error") == -1) {
                     var str = html.split("<>");
                     $('span.cartnumm').html(str[0]);
                     $('span.cartnumm').next("span").html("items &#163;" + str[1]);
                     var w = $('span.cartnumm').width()*1;
                     if (w > 90) {
                        $('span.cartnumm').next('span').css("width",(90-w)+"px");
                     }
            
                      var image = $('#image').offset();
                      var cart  = $('#module_cart').offset();
                      var l = image.left;
                      $("div.outer").before('<img src="' + $('#image').attr('src') + '" id="temp" style="position: absolute; top: ' + image.top + 'px; left: ' + image.left + 'px;z-index:2000" />');								params = {					top : cart.top + 'px',					left : cart.left + 'px',					opacity: 0.0,					width : $('#module_cart').width(),  					height : $('#module_cart').height()};
                      $('#temp').animate(params, 'slow',false,function () {$("#temp").remove();});
                }
            }
);
}

