
var compareLib = function()
{
	this.no = 0;

	// подсветка строк таблицы/пунктов меню
	this.hilite = function(el, flag)
	{
		if (flag) el.className = 'cmpSelected'; else el.className = '';
	}

	// показать/убрать выпадающий список моделей
	this.showDropdown = function(el, no)
	{
		var list = document.getElementById('cmpList');
		if (this.no && this.no == no)
		{
			list.style.display = 'none';
			this.no = 0;
		}
		else
		{
			var top = getAbsoluteTop(el) + el.offsetHeight;
			var left = getAbsoluteLeft(el) + 1;
			list.style.top = top+'px';
			list.style.left = left+'px';
			list.style.display = 'block';
			this.no = no;
		}
	}

	// выбор модели из списка
	this.select = function(el, id)
	{
		$.get(
			'/bitrix/templates/.default/iblock/mini/comparison/table.php', 
			'ID='+id+'&no='+this.no,
			function(data)
			{
				$('#cmpContainer').html(data);
				document.getElementById('cmpList').style.display = 'none';
				$CMP.no = 0;
				var o = document.getElementById('Scroller');
				var w = document.getElementById('cmpContainer').offsetWidth;
				var h = document.getElementById('cmpContainer').offsetHeight;
				scroller.reset(o, w, h);
				scrollbar.reset(document.getElementById('Scrollbar-Container'), scroller, false);
			}
		);
		$('#cmpChoose'+this.no).html(el.innerHTML);
		$('#cmpModelPic'+this.no).attr('src', this.imgs[id]);
	}

}

var $CMP = new compareLib();

