// Coupon display specific js - cc.coupons.js - beaver6813 - sam cleaver
$(function() {
$('.favouritecontainer a').live('click',function() {
									  var couponid = $(this).parent().siblings('.couponiddata').val();
									  var target = $(this);
									  $.ajax({
											   type: "GET",
											   url: "/setresponse.php",
											   data: "type=ToggleFavourite&ID="+couponid,
											   beforeSend: function() {
												  target.css('background','top left no-repeat url(/images/loading.gif)');
	   
											  },
											   success: function(msg){
												   if(msg=='TRUE')
											   {
													  target.css('background','top left no-repeat url(/images/star.png)');
													  target.attr('title','Click to remove from favorites');
											   }
												  else if(msg=='NOLOGIN')
												  	{
													target.css('background','top left no-repeat url(/images/star-empty.png)');	
													alert("You must login to pick favorites.");
													}
												  else if(msg=='REMOVED')
											   {
													  target.css('background','top left no-repeat url(/images/star-empty.png)');
													  target.attr('title','Click to add to favorites');
											   }
												  else
												  	{
													target.css('background','top left no-repeat url(/images/star-empty.png)');	
													  alert("An error occured. Please try again later.");
													}
											   }
											 });
											   });

});

