function $(id) {
	return document.getElementById(id);
}
/* Scroll config ... */
var interval;
var max = 306;
var position = 0;
var old_position = 0;
var scroll_step = 10;
var scroll_timeout = 20;
var first_item = 1, last_item = 3;

function scrollItems(n) {
	if ((last_item >= items_count -3 && n == -1) || (last_item <= 3 && n == 1)) {
		n = 0;
	} else {
		first_item -= n;
		last_item -= n;
	}
	var path = '/bitrix/templates/komtel/images/';
	if (last_item >= (items_count -3)) {
		$('arrow_l').src = path + 'arrow_l_inactive.png';
	} else {
		$('arrow_l').src = path + 'arrow_l.png';
	}
	
	if (last_item <= 3) {
		$('arrow_r').src = path + 'arrow_r_inactive.png';
	} else {
		$('arrow_r').src = path + 'arrow_r.png';
	}	
	
	old_position = position;
	//alert(first_item + ' ' + last_item);
	if (n != 0) {
		interval = window.setInterval('moveItem(' + n + ')', scroll_timeout);
	}
	return false;
}

function moveItem(n) {
	position += scroll_step * n;
	$('items_box').style.left = position + 'px';
	if (old_position + max < position || old_position - max > position) {
		window.clearTimeout(interval);
	}		
}