//##############
//###     Scroll
	var moving = false;
	function Scroll(scrHight,scrBarHight,textId,bittId,speed,IntPause,time,scrId){
		//--- obgect id
		this.textId = textId;
		this.bittId = bittId;
		this.scrId = scrId;
		//--- moving property
		this.scrHight = scrHight;
		this.scrBarHight = scrBarHight+58;
		this.speed = speed;
		this.IntPause = IntPause;
		this.time = time;
		//--- interval
		this.interval = {};
		//--- global keys
		this.i = 0;
		if(!this.getContainers()){ return;}
		if(this.textHeight<scrHight){ this.hideScr(); return; }
		if(this.getSlider()){
			this.absolute_c = 0;
			this.point = 0;
			this.setMovEvents();
		}
		this.setClickEvents();
		this.setHover();
	}
	Scroll.prototype.getContainers=function(){
		try{
			this.scroll = document.getElementById(this.scrId);
			this.text = document.getElementById(this.textId);
			this.text.style.top = 0;
			this.textHeight = this.text.offsetHeight;
			//---
			this.ost = this.textHeight - this.scrHight;
			//---
			this.bit_top = document.getElementById(this.bittId+'_top');
			this.bit_bottom = document.getElementById(this.bittId+'_bottom');
			//---
			this.bit_top.style.cursor = 'pointer';
			this.bit_bottom.style.cursor = 'pointer';
		} catch(err){return false;}
		return true;
	}
	Scroll.prototype.getSlider=function(){
		try{
			this.bit_slider = document.getElementById(this.bittId+'_slider');
			this.bit_slider_test = document.getElementById(this.bittId+'_slider_test');
			this.bit_slider_test_height = parseInt(this.bit_slider_test.style.top.substring(0, this.bit_slider_test.style.top.length-2));
			this.bit_slider_height = this.bit_slider.offsetHeight;
			this.bit_slider.style.cursor = 'pointer';
		} catch(err){return false;}
		return true;
	}
	Scroll.prototype.setHover = function(){
		var arr_bit = Array(this.bit_slider,this.bit_top,this.bit_bottom);
		var img = Array();
		for(var k=0;k<3;k++){
			try{
				img[k] = arr_bit[k].getElementsByTagName('img')[0];
				img[k].name = img[k].src.substring(0, img[k].src.length-4);
				
				img[k].onmouseover = function(){
					this.src = this.name + '_active.gif';
				}
				img[k].onmouseout = function(){
					this.src = this.name + '.gif';
				}
				this.scroll.onmouseout = function(){
					this.src = this.name + '.gif';
				}
				
			} catch(err){}
		}
	}
	Scroll.prototype.hideScr=function(){
		try {
			this.scroll.style.display = 'none'; 
		} catch(err){}
	}
	Scroll.prototype.setClickEvents=function(){
		var obj = this;
		
		this.bit_top.onclick = function(){
			obj.stopMovie();
			obj.top_ost = false;
			
			obj.top = parseInt(obj.text.style.top.substring(0, obj.text.style.top.length-2));
			var height_scr = obj.top + obj.textHeight - obj.scrHight;
			
			if(obj.top == 0) return false;
			if(-obj.top > obj.speed*obj.time){
					obj.end = obj.time;
			} else {
				obj.end = - parseInt(obj.top/obj.speed);
				if(-obj.top/obj.speed != obj.end){
					obj.top_ost = -(obj.top + obj.speed*obj.end);
				}
			}
			obj.interval = setInterval(function(o){return function(){o.movingTop()}}(obj),obj.IntPause);
			return false;
		}
		this.bit_bottom.onclick = function(){
			obj.stopMovie();
			obj.bottom_ost = false;
			
			obj.top = parseInt(obj.text.style.top.substring(0, obj.text.style.top.length-2));
			var height_scr = obj.top + obj.textHeight - obj.scrHight;
			
			if(height_scr < 2) return false;
			if(height_scr - obj.speed*obj.time > 0){
					obj.end = obj.time;
			} else {
				obj.end = parseInt(height_scr/obj.speed);
				if(height_scr/obj.speed != obj.end){
					obj.bottom_ost = height_scr - obj.speed*obj.end;
				}
			}
			obj.interval = setInterval(function(o){return function(){o.movingBottom()}}(obj),obj.IntPause);
			return false;
		}
	}
	Scroll.prototype.movingTop = function(){
		if(this.i == this.end + 1){
			if(this.top_ost){
				this.text.style.top = this.top + this.speed*(this.i - 1) + this.top_ost + 'px';
			}
			this.movieSlider();
			this.stopMovie();
			return;
		}
		this.text.style.top = this.top + this.speed*this.i + 'px';
		this.movieSlider();
		this.i++;
	}
	Scroll.prototype.movingBottom = function(){
		if(this.i == this.end + 1){
			if(this.bottom_ost){
				this.text.style.top = this.top - this.speed*(this.i -1) - this.bottom_ost + 'px';
			}
			this.movieSlider();
			this.stopMovie();
			return;
		}
		this.text.style.top = this.top - this.speed*this.i + 'px';
		this.movieSlider();
		this.i++;
	}
	Scroll.prototype.movieSlider = function(){
		try{
			var top = this.text.style.top.substring(0, this.text.style.top.length-2);
			var top_point = top/this.ost*this.scrBarHight;
			this.bit_slider.style.top = - top_point + 'px';
		}catch(err){}
	};
	Scroll.prototype.setMovEvents=function(){
		var obj = this;
		relative_c = this.bit_slider_height;
		
		this.bit_slider.onmousedown = function(event){
			moving = true;
			obj.blockEvent(event);
		}
		
		document.onmouseup = function(event){
			moving = false;
		}
		
		this.scroll.onmousemove = function(event){
			if(moving){
				var ycoord;
				if(!event){ event = window.event; }
				
				if(typeof(event.pageX) == 'number'){
					ycoord = event.pageY;
				} else if(typeof(event.clientX) == 'number'){
					ycoord = event.clientY;
					if(document.body && (document.body.scrLeft || document.body.scrTop)){
						ycoord += document.body.scrTop;
					} else if(document.documentElement && (document.documentElement.scrLeft || document.documentElement.scrTop)){
						ycoord += document.documentElement.scrTop;
					}
				} else { return; }
				
				obj.bit_slider.style.top = ycoord +'px';
				
				var absolute_c = 0;
				var test = obj.bit_slider_test;
				while(test = test.parentNode){
					if(test.offsetTop != undefined) absolute_c += test.offsetTop;
				}
				var s = ycoord - absolute_c - relative_c;
				
				if(s < 0){
					obj.bit_slider.style.top = 0 +'px';
				} else if(s >= obj.scrBarHight) {
					obj.bit_slider.style.top = obj.scrBarHight +'px';
				} else {
					obj.bit_slider.style.top = s +'px';
				}
				
				obj.point = parseInt(obj.bit_slider.style.top.substring(0, obj.bit_slider.style.top.length-2));
				
				var top_point = obj.point/(obj.scrBarHight)*obj.ost;
				
				obj.text.style.top = - top_point + 'px';
				obj.blockEvent(event);
				
			}
		}
	}
	Scroll.prototype.stopMovie = function(){
		clearInterval(this.interval);
		this.i = 0;
	}
	Scroll.prototype.blockEvent=function(event){
		try{
		    if (!event) event = window.event;
		    if (event.stopPropagation) event.stopPropagation();
		    else event.cancelBubble = true;
		    if (event.preventDefault) event.preventDefault();
		    else event.returnValue = false;
		}catch(err){}
	}
//###     Scroll
//##############
if (typeof document.attachEvent!='undefined') window.attachEvent('onload',setscr);
else window.addEventListener('load',setscr,false);
//--------------------------------------------  start  -------------------------------------//

function setscr(){
	var scr = new Scroll(350,217,'scroll','bitt',20,10,6,'scrollbar');
}