function add_coupon(imgroot,couponid) {
	var thisUrl  = imgroot+'/couponpack/index.cfm';
	var thisData = 'action=couponajax&couponid='+couponid; 
	var thishtml = "<a href=\"javascript:remove_coupon('"+imgroot+"',"+couponid+");\" title=\"Remove coupon from coupon pack\">Remove from pack</a>";
	
	/*Prototype Style*/
	if(typeof(window['Ajax']) != 'undefined' && Ajax.Request){
		new Ajax.Request(thisUrl,{
			method: 'post',
			parameters: thisData,
			onSuccess: function (response){
				$$('.coupon_'+couponid).each(function(itm){itm.innerHTML = (thishtml);});
				return true;
			},
			onFailure: handlerFailure
		});
	}
	/*JQuery Style*/
	else{
		$.ajax({
			type: "POST",
			url: thisUrl,
			data: thisData,
			success: function (response){
				$('.coupon_'+couponid).html(thishtml);
				updateItin();
		   },
		   failuer: handlerFailure
		 });
	}

}

function remove_coupon(imgroot,couponid) {
	var thisUrl  = imgroot+'/couponpack/index.cfm';
	var thisData = 'action=removeajax&couponid='+couponid; 
	var thishtml = "<a href=\"javascript:add_coupon('"+imgroot+"',"+couponid+");\" title=\"Add to coupon pack\">Add to pack</a>";
	
	/*Prototype Style*/
	if(typeof(window['Ajax']) != 'undefined' && Ajax.Request){
		new Ajax.Request(thisUrl,{
			method: 'post',
			parameters: thisData,
			onSuccess: function (response){
				$$('.coupon_'+couponid).each(function(itm){itm.innerHTML = (thishtml);});
				return true;
			},
			onFailure: handlerFailure
		});
	}
	/*JQuery Style*/
	else{
		$.ajax({
			type: "POST",
			url: thisUrl,
			data: thisData,
			success: function (response){
				$('.coupon_'+couponid).html(thishtml);
				updateItin();
		   },
		   failuer: handlerFailure
		 });
	}

}

function handlerFailure(response){
	alert('We were unable to comply with your request.  Please reload the page and try again');
}

