var lifestyleLib = function()
{
	this.shift = 0;

	this.getAbsoluteLeft = function(el)
	{
		if (typeof el != 'object') el = document.getElementById(el);
		var x = 0;
		if (el)
		{

			while (el.offsetParent !== null) 
			{
				x += el.offsetLeft;
				el = el.offsetParent;
			}
			x += el.offsetLeft;
		}
		return x;
	}

	this.getAbsoluteTop = function(el)
	{
		if (typeof el != 'object') el = document.getElementById(el);
		var y = 0;
		if (el)
		{
			while (el.offsetParent !== null) 
			{
				y += el.offsetTop;
				el = el.offsetParent;
			}
			y += el.offsetTop;
		}
		return y;
	}

	this.toggle = function(id)
	{
		var el = document.getElementById('lfDescr'+id);
		if (el)
		{
			if (el.style.display == 'block')
			{
//				el.style.display = 'none';
				$(el).slideToggle(150);
			}
			else
			{
				var x = this.getAbsoluteLeft('lfImg'+id);
				var y = this.getAbsoluteTop('lfImg'+id);
//				el.style.display = 'block';
				el.style.left = x+'px';
				el.style.top = y+92+'px';
				$(el).slideToggle(150);
			}
		}
	}

	this.move = function(direction)
	{
		this.shift += direction;
		$.get(
			'/bitrix/templates/.default/iblock/mini/accessories/getthree.php',
			'shift='+this.shift,
			function(data)
			{
				$('#lsScrollable').html(data);
			}
		);
	}

	this.detail = function(id)
	{
		$.get(
			'/bitrix/templates/.default/iblock/mini/accessories/detail.php',
			'id='+id,
			function(data)
			{
				$('#lsLeft').html(data);
				$('#lsDetailHeader').html($LF.header);
			}
		);
	}

}

var $LF = new lifestyleLib();

