function addToCart(id, target, rand){	$.post("/cart/add/"+id+"/"+rand,		function(data){			if ($("rand", data).text() == rand){				couponCount = $("amount",data).text();				$("#coupons_amount").html(couponCount);				if (couponCount > 0){					$(".button > a.multiple_to_friend:hidden").fadeIn('slow');				}				target.addClass("coupon_thumb_selected");				target.children(".loading").remove();				target.children(".checkbox").addClass("checkbox_selected").show();				target.attr("rel", "in_cart");				hideLoading();			}		}	);}function removeFromCart(id, target, rand){	$.post("/cart/del/"+id+"/"+rand,		function(data){			if ($("rand", data).text() == rand){				couponCount = $("amount",data).text();				$("#coupons_amount").html(couponCount);				if (couponCount <= 0){					$(".button > a.multiple_to_friend:visible").fadeOut('slow');				}				target.removeClass("coupon_thumb_selected");				target.children(".loading").remove();				target.children(".checkbox").removeClass("checkbox_selected").show();				target.attr("rel", "");				hideLoading();			}		}	);}$(document).ready(function(){	$("div.coupon_thumb div.checkbox:not(.expired)").click(function(){		var rand = Math.round(Math.random()*200000);		showLoading();		if ($(this).parent().attr("rel") == "in_cart"){			$(this).hide().after('<img class="loading" src="/img/loading.gif"/>');			removeFromCart($(this).siblings(".id").attr('id'), $(this).parent(), rand);			return false;		}		else {			$(this).hide().after('<img class="loading" src="/img/loading.gif"/>');			addToCart($(this).siblings(".id").attr('id'), $(this).parent(), rand);			return false;		}	});		$(".coupon_thumb").hover(function(){		$(this).addClass("coupon_thumb_over");	}, 	function(){		$(this).removeClass("coupon_thumb_over");	})	showLoading();	$.post("/cart/coupons/", function(data){		hideLoading();		$("coupon", data).each(function(i){			var couponId = $(this).text();			$("#"+couponId).siblings(".checkbox").addClass("checkbox_selected");			$("#"+couponId).parent().addClass("coupon_thumb_selected").attr("rel", "in_cart");		});				if ($("coupon", data).length > 0){			$(".button > a.multiple_to_friend").show();		}	});	});