

var bSS3 = false;
var iScrollTimeout3 = 1;
var iTimeOut3 = window.addEventListener ? iScrollTimeout3 * 2 : iScrollTimeout3;
var iScrollKoef3 = 8;
var iCW3, iTW3, iTL3, iTR3, iDiff3;
var oContainer3 = null;
var oThumbs3 = null;
var oLeftArr3 = null;
var oRightArr3 = null;


function initScrollVars3(){
	iCW3 = oContainer3.offsetWidth;
	iTW3 = oThumbs3.offsetWidth;
	iTL3 = oThumbs3.offsetLeft;
	iDiff3 = iTW3 - iCW3;
	iTR3 = -(iTL3 + iDiff3);
}

function scrollInit3(){
	if(oContainer3 = document.getElementById('gn_container3')){
	if(oThumbs3 = document.getElementById('gn_thumbs3')){
	if(oLeftArr3 = document.getElementById('gn_arr_left3')){
	if(oRightArr3 = document.getElementById('gn_arr_right3')){
		if(oContainer3.attachEvent){
			oContainer3.attachEvent("onmousewheel", mousescrollThumbs3);
		} else {
			oContainer3.addEventListener("DOMMouseScroll", mousescrollThumbs3, true);
		}
		if(window.addEventListener){
			window.addEventListener('resize', resizeThumbs3, false);
		} else {
			window.attachEvent('onresize', resizeThumbs3);
		}
		checkScrollButtons3();
		//checkSelectedPosition3();
		resizeThumbs3();
	}
	}
	}
	}
}

function checkSelectedPosition3(){
	if(oThumbs3){
		var i = 0;
		var num = 0;
		oSelThumb = null;
		for (i = 0; i < a.length; i++) {
			if(oThumb = document.getElementById('th' + a[i])) {
				if(oThumb.className == 'sel'){
					oSelThumb = oThumb;
					num = i;
				}
			}
		}
		iLeft = Math.round(iCW3 / 2 - (iTW3 / a.length) * (num + 1/2));
		iLeft = iLeft + iTW3 < iCW3 ? iCW3 - iTW3 : iLeft;
		iLeft = iLeft > 0 ? 0 : iLeft;
		oThumbs3.style.left = iLeft + 'px';
	}
}

function checkScrollButtons3(){
	initScrollVars3();
	if(iDiff3 > 0){
		bRA3 = iTR3 < 0 ? true : false;
		bLA3 = iTL3 < 0 ? true : false;
	} else {
		bLA3 = false; bRA3 = false;
	}

	oLeftArr3.style.visibility = bLA3 ? '' : 'hidden';
	oRightArr3.style.visibility = bRA3 ? '' : 'hidden';
}

function resizeThumbs3(){
	if(oThumbs3){
		initScrollVars3();
		if(iTL3 < 0){
			if(iDiff3 < 0) {
				oThumbs3.style.left = '0px';
			} else if(iDiff3 > 0) {
				if(iTR3 >= 0){
					oThumbs3.style.left = -iDiff3 + 'px';
				}
			}
		} else {
			oThumbs3.style.left = '0px';
		}
		checkScrollButtons3();
	}
}

function scrollThumbs3(sSS, sDirection){
	bSS3 = sSS == 'start' ? true : false;
	iDirection3 = sDirection == 'left' ? -1 : 1;
	_scroll3(iDirection3);
}

function mousescrollThumbs3(evt){
	if(!evt) evt = window.event;
	if(evt.wheelDelta) {
		delta = evt.wheelDelta / 120;
		if(window.opera) delta = -delta;
	} else if (evt.detail) {
		delta = -evt.detail / 3;
	}
	iDirection3 = delta > 0 ? -1 : 1;
	_scroll3(iDirection3, delta * 5);
	if (evt.preventDefault) evt.preventDefault();
	evt.returnValue = false;
	return false;
}

function _scroll3(iDirection3, iKoef3){
	var iMultiplier3 = !isNaN(iKoef3) ? Math.abs(iKoef3) : 1;
	var iShift3 = iScrollKoef3 * iMultiplier3 * iDirection3;

	initScrollVars3();
	if(oThumbs3 && iCW3 > 0){
		if(iDiff3 > 0) {
			if(iTL3 > iShift3) {
				oThumbs3.style.left = '0px';
			} else { 
				if((iDiff3 + iTL3) < iShift3) {
					oThumbs3.style.left = -iDiff3 + 'px';	
				} else {
					oThumbs3.style.left = (iTL3 - iShift3) + 'px';
					if(bSS3){
						setTimeout('_scroll3(' + iDirection3 + ')', iTimeOut3);
					}
				}
			}
		}
	}
	checkScrollButtons3();
}
