function BestWorst(options){
	var self = this;
	self['options'] = options;
}

BestWorst.prototype.init = function(){
	var self = this;
	self['radio'] = self.options.form.find("input[type=radio]");
	self.radio.attr('checked', '');
	self.addClickEvent();
}

BestWorst.prototype.addClickEvent = function(){
	var self = this;
	self['radio'].click(function(){self.handleClickEvent(this)});
}

BestWorst.prototype.handleClickEvent = function(radio){
	var self = this;
	if (radio.name == 'best_id'){
		var neighbor = $(radio).parents('tr:first').find('input[name=worst_id]');
	} else {
		var neighbor = $(radio).parents('tr:first').find('input[name=best_id]');
	}
	if (neighbor.is(':checked')){
		$(radio).attr('checked', '');
	}
}

$(document).ready(function(){
	var bestWorst = new BestWorst({
		form: $("form.best-worst-form")
	});
	bestWorst.init();
});

