/**
 * @requires jQuery
 */

function colorHover(rootEl) {
	rootEl = $(rootEl);

	var
		modificationEls = rootEl.find('.modification'),
		linksEls = rootEl.find('.color');

	linksEls.each(function(index) {
		var el = $(this);

		el.find('.clear').mouseover(function() {
			linksEls.filter('.selected').removeClass('selected');
			el.addClass('selected');
			modificationEls.filter('.modification_selected').removeClass('modification_selected');
			modificationEls.eq(index).addClass('modification_selected');
		});
	});
}

$(function() {
	$('#content .products_list .item').each(function() {
		if ($(this).find('.colors').length) {
			colorHover(this);
		}
	});
});
