jQuery.noConflict();
jQuery(function($){
	$("input.osx, a.osx").click(function(){
		adboost.getCookie("OptOut", "ECD.ATP.cb");
	});
	$("#osx-modal-data button").click(function(){
		var msg;	
		if ($(this).data("opt"))
		{
			adboost.optin("");
			msg = "You have been added.";
		}
		else
		{
			adboost.optout("");
			msg = "You have been removed.";
		}
		ECD.ATP.msg(msg, ECD.ATP.closemodal);
	});
});

function test(obj)
{
	if (obj.length > 0) // The are OUT
	{
		jQuery("#osx-modal-data button").data("opt", true);
		jQuery("#osx-modal-data button span").text("Remove Opt Out");
		jQuery("#osx-modal-data #content").append("Allow targeted advertising.");
	}
	else // They are IN
	{
		jQuery("#osx-modal-data button").data("opt", false);
		jQuery("#osx-modal-data button span").text("Opt Out");
		jQuery("#osx-modal-data #content").append("Opt out of targeted advertising.");
	}
}

var ECD = {
	ATP: {
		cb: function(obj){
			if (obj.length > 0) // The are OUT
			{
				jQuery("#osx-modal-data button").data("opt", true);
				jQuery("#osx-modal-data button span").text("Remove Opt Out");
				jQuery("#osx-modal-data #content").append("Allow targeted advertising.");
			}
			else // They are IN
			{
				jQuery("#osx-modal-data button").data("opt", false);
				jQuery("#osx-modal-data button span").text("Opt Out");
				jQuery("#osx-modal-data #content").append("Opt out of targeted advertising.");
			}
		},
		closemodal: function(){
			jQuery.modal.close();
			if (opener){setTimeout(function(){self.close()}, 800);}
		},
		msg: function(msg, callback){
			jQuery("#modal-message").empty().append("<span></span>");
			jQuery("#modal-message span").hide().text(msg).fadeIn("slow", function(){
				setTimeout(function(){
					jQuery("#modal-message span").fadeOut(function(){
						if (callback){callback.call()};
					});
				}, 800);
			});
		}
	}
};
