var hBlocks_1 = 2; // Количество боксов с информацией.
var hScore_1 = 10;
var hIID = false;

//var hSearchBlock = document.getElementById("search_block");
//var hContainerParent = document.getElementById("top_pic");
//var hBanner = document.getElementById("top_banner");
//hContainerParent.style.width = (hSearchBlock.clientWidth - hBanner.clientWidth-20) + 'px';

var hText_1 = document.getElementById("slider");
var hRtl = document.getElementById("rtl");
var hLtr = document.getElementById("ltr");
var hContainer_1 = document.getElementById("viewer");
var hScrolling_1 = true;
var hCounter_1 = 0;
var hPos_1 = -1;
var hDir = 'l';
var hDuplicate = false;
hContainer_1.onmouseover = HOnScrollerMouseOver_1;
hRtl.onclick = HOnScrollerToL;
hLtr.onclick = HOnScrollerToR;
hContainer_1.onmouseout = HOnScrollerMouseOut_1;

function HOnScrollerMouseOver_1()
{
	hScrolling_1 = false;
}

function HOnScrollerToR()
{
	hDir = 'r';
	hDuplicate = true;
	HWrite_1()
}

function HOnScrollerToL()
{
	hDir = 'l';
	hDuplicate = true;
	HWrite_1()
}

function HOnScrollerMouseOut_1()
{
	hScrolling_1 = true;
}

function HOnTimer_1()
{
	if (!hScrolling_1) return;

	if (hDir == 'r'){
		hText_1.style.left = hPos_1.toString() + "px";
		hPos_1++;
	} else {
		hText_1.style.marginLeft = hPos_1.toString() + "px";
		hPos_1--;
	}
	hCounter_1++;
	hWidthM_1 =  Math.round(hWidth_1/hBlocks_1*100)/100;

	if(hCounter_1 >= hWidthM_1){
		hCounter_1 = 0;
		//		hPos_1 = -3; // Поправка на тормознутось браузеров
		if (hDir == 'r'){
			hPos_1 = '-'+hWidthM_1; // Поправка на тормознутось браузеров
		} else hPos_1 = -3; // Поправка на тормознутось браузеров
	}
}

function HWrite_1()
{
	hScore_1 = 10;
	if (!hDuplicate) {
		// duplicate rows in table
		hRow = hText_1.getElementsByTagName('tr')[0]
		hElems = hRow.cells
		hElemsCount = hElems.length
		for (var obj = 0; obj<hElemsCount; obj++){
			if (hElems[obj].innerHTML) {
				var x = hRow.insertCell(hElems.length);
				x.innerHTML = hElems[obj].innerHTML
			}
		}
	}
//
	hContainer_1.style.height = hText_1.offsetHeight + "px";
	hWidth_1 = hText_1.offsetWidth;
	if (hDir == 'r'){
		hPos_1 = '-'+Math.round(hWidth_1/hBlocks_1*100)/100;
		hText_1.style.left = hPos_1.toString() + 'px';
		hText_1.style.marginLeft = -1+'px';
	} else {
		hPos_1 = '-'+1;
		hText_1.style.left = 0+'px';
		hText_1.style.marginLeft = -1+'px';
	}
	if (hIID !== false) {
		window.clearInterval(hIID);
	}

	hIID = window.setInterval(HOnTimer_1, hScore_1);
}

//if(typeof window.onload == 'function') {
//	var existing = window.onload;
//	window.onload = function() {
//		existing();
		HWrite_1();
//	}
//} else {
//	window.onload = HWrite_1;
//}
