/* requires core.js */
/* requires tracking/tracking.js */
ADCENTRIC.lang.namespace("ADCENTRIC.tracking");

ADCENTRIC.tracking.WitnessProfile = function(profile_name, witness_node_url) {
	var dispatcher = ADCENTRIC.tracking.EventPixelDispatcher();

	return {
		witness_node_url: witness_node_url,
		profile_name: encodeURIComponent(profile_name),

		set: function(score) {
			return dispatcher.dispatch(this.witness_node_url + "?profile=" + this.profile_name + "&set_value=" + String(Integer(score)));
		},
		remove: function() {
			return dispatcher.dispatch(this.witness_node_url + "?profile=" + this.profile_name + "&remove=1");
		},
		increase_affinity: function(how_much_score) {
			return dispatcher.dispatch(this.witness_node_url + "?profile=" + this.profile_name + "&increment_value=" + String(Integer(how_much_score)));
		},
		decrease_affinity: function(how_much_score) {
			return this.increase_affinity(Integer(how_much_score) * -1);
		}
	};
};

ADCENTRIC.tracking.MultiWitnessProfile = function(profile_name, witness_node_urls) {
	var wps = new Array();
	var i;

	for (i = 0; i < witness_node_urls.length; i++)
		wps.push(ADCENTRIC.WitnessProfile(profile_name, witness_node_urls[i]));

	return {
		profile_name: encodeURIComponent(profile_name),
		witness_node_urls: witness_node_urls,

		set: function(score) {
			var i;
			for (i = 0; i < wps.length; i++) {
				wps[i].set(score);
			}
			return false;
		},
		remove: function() {
			var i;
			for (i = 0; i < wps.length; i++) {
				wps[i].remove();
			}
			return false;
		},
		increase_affinity: function(how_much_score) {
			var i;
			for (i = 0; i < wps.length; i++) {
				wps[i].increase_affinity(how_much_score);
			}
			return false;
		},
		decrease_affinity: function(how_much_score) {
			return this.increase_affinity(Integer(how_much_score) * -1);
		}
	};
};