function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera5=this.agent.indexOf("Opera 5")>-1;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6;
	this.mac=this.agent.indexOf("Mac")>-1;
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5);
	return this
}
var bw = new lib_bwcheck();

/**************************************************************************
Variables to set.
***************************************************************************/

sScrollspeed = 20; //Скорость прокрутки: (в миллисекундах)
sScrollPx = 8;     //Шаг прокрутки (в пикселах)
sScrollExtra = 15; //Шаг быстрой прокрутки (в пикселах)

/**************************************************************************
Scrolling functions
***************************************************************************/
var tim = 0;
var noScroll = true;
function mLeft(){
	if (!noScroll && oMenu.left<-1){
		if ((oMenu.left+sScrollPx)<-1) {
			oMenu.moveBy(sScrollPx);
		} else {
			oMenu.moveIt(-1);
		}
		tim = setTimeout("mLeft()",sScrollspeed)
	} else { cmnSet_class(oArrowLeft.elm,'disable'); }
}
function mRight(){
	if (!noScroll && oMenu.left>-(oMenu.scrollWidth-pageWidth-1)) {
		if (-(oMenu.left-sScrollPx)<(oMenu.scrollWidth-pageWidth-1)) {
			oMenu.moveBy(-sScrollPx);
		} else {
			oMenu.moveIt(-(oMenu.scrollWidth-pageWidth-1));
		}
		tim = setTimeout("mRight()",sScrollspeed);
	} else { cmnSet_class(oArrowRight.elm,'disable'); }
}
function noMove(){
	clearTimeout(tim);
	noScroll = true;
	sScrollPx = sScrollPxOriginal;
}
/**************************************************************************
Object part
***************************************************************************/

function makeObj(obj){
	this.elm = document.getElementById(obj);
   	this.css = this.elm.style;
	this.scrollWidth = this.elm.offsetWidth;
	this.left = this.elm.offsetLeft;
	this.moveBy = b_moveBy;
	this.moveIt = b_moveIt;
	return this;
}
var px = bw.ns4||window.opera?"":"px";
//
function b_moveIt(width){
	if (width!=null){this.left=width; this.css.left=this.left+px;}
}
function b_moveBy(width) {
	this.left=this.left+width;
	this.css.left=this.left+px;
}

/**************************************************************************
Object part end
***************************************************************************/

/**************************************************************************
Init function. Set the placements of the objects here.
***************************************************************************/
var sScrollPxOriginal = sScrollPx;
function sideInit(){
	//Making the objects...
	oBg = new makeObj('lineup');
	oMenu = new makeObj('rotator');
	oArrowLeft = new makeObj('back-arrow');
	//alert(oArrowLeft.elm.style.backgroundImage);
	oArrowLeft.elm.onmousedown = function () { sScrollPx+=sScrollExtra;	}
	oArrowLeft.elm.onfocus = function () { if(this.blur)this.blur(); }
	oArrowLeft.elm.onclick = function () { sScrollPx-=sScrollExtra; return false; }
	oArrowLeft.elm.onmouseout = function () { noMove(); }
	oArrowLeft.elm.onmouseover = function () { noScroll=false; cmnRemove_class(oArrowRight.elm,'disable'); mLeft(); }
	oArrowRight = new makeObj('next-arrow');
	oArrowRight.elm.onmousedown = function () { sScrollPx+=sScrollExtra; }
	oArrowRight.elm.onfocus = function () { if(this.blur)this.blur(); }
	oArrowRight.elm.onclick = function () { sScrollPx-=sScrollExtra; return false; }
	oArrowRight.elm.onmouseout = function () { noMove(); }
	oArrowRight.elm.onmouseover = function () { noScroll=false; cmnRemove_class(oArrowLeft.elm,'disable'); mRight(); }
	pageWidth = oBg.elm.offsetWidth;
	//
	/*var items = oMenu.elm.getElementsByTagName('td');
	for (var i=0; i<items.length; i++) {
		items[i].onmouseover = function () { this.style.background = "#000;"; }
		items[i].onmouseout = function () { this.style.background = "#000;"; }
	}*/
	onresize = function () { pageWidth = oBg.elm.offsetWidth; }
} 

//executing the init function on pageload if the browser is ok.
onload = sideInit;
