var _5bnetwork_collection_scroll_ = new Array() ;

var _5bnetwork_object_scroll_active_ = null ;

document.onmousedown = _5bnetwork_function_scroll_ ;

document.onmouseup = _5bnetwork_function_scroll_ ;

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// :: OBJECT - scroll :: //

function _5bnetwork_object_scroll_ (_id,_type,_cacheLayerID,_scrollLayerID,_scrollBarID,_scrollButtonID,_scrollButtonDistance,_buttonLeftID,_buttonRightID)
{
	this.id = _id ;
	
	this.type = _type ;
	
	this.cacheLayer = document.getElementById(_cacheLayerID) ;
	
	this.scrollLayer = document.getElementById(_scrollLayerID) ;
	
	this.scrollBar = document.getElementById(_scrollBarID) ;
	
	this.scrollButton = document.getElementById(_scrollButtonID) ;
	
	this.scrollButtonDistance = _scrollButtonDistance ;
	
	this.leftButton = document.getElementById(_buttonLeftID) ;
	
	this.rightButton = document.getElementById(_buttonRightID) ;
	
	this.startLeft ;
	
	this.startTop ;
	
	this.startLeftTop() ;
	
	this.initialize() ;
	
	if (this.type == "horizontal")
	{
		this.scrollButtonStart = this.scrollButton.offsetLeft ;
	}
	else if (this.type == "vertical")
	{
		this.scrollButtonStart = this.scrollButton.offsetTop ;
	}
	
	this.speed = parseInt((this.scrollLayer.offsetWidth - this.cacheLayer.offsetWidth)/100,10) ;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// :: OBJECT - scroll - METHOD - initialize :: //

_5bnetwork_object_scroll_.prototype.startLeftTop = function ()
{
	this.startLeft = 0 ;
	
	this.startTop = 0 ;
	
	if (document.all)
	{
		var parent = this.scrollButton.parentElement ;
		
		while (parent.tagName != "BODY")
		{
			this.startLeft += parent.offsetLeft ;
			
			this.startTop += parent.offsetTop ;
			
			parent = parent.parentElement ;
		}
	}
	else
	{
		var parent =  this.scrollButton.parentNode ;
		
		while (parent.tagName != "BODY")
		{
			this.startLeft += parent.offsetLeft ;
			
			this.startTop += parent.offsetTop ;
			
			parent = parent.parentNode ;
		}
	}
	
	// this.startLeft += 1 ;
	
	// this.startTop += 1 ;
}

_5bnetwork_object_scroll_.prototype.initialize = function ()
{
	this.scrollBar.style.display = "none" ;
	
	this.scrollButton.style.display = "none" ;
	
	this.leftButton.style.display = "none" ;
	
	this.rightButton.style.display = "none" ;
			
	if (this.type == "horizontal")
	{
		if (this.scrollLayer.offsetWidth - this.cacheLayer.offsetWidth > 0)
		{
			this.scrollBar.style.display = "block" ;
	
			this.scrollButton.style.display = "block" ;
			
			this.leftButton.style.display = "block" ;
	
			this.rightButton.style.display = "block" ;
		}
	}
	else if (this.type == "vertical")
	{
		if (this.scrollLayer.offsetHeight - this.cacheLayer.offsetHeight > 0)
		{
			this.scrollBar.style.display = "block" ;
	
			this.scrollButton.style.display = "block" ;
			
			this.leftButton.style.display = "block" ;
	
			this.rightButton.style.display = "block" ;
		}
	}
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// :: FUNCTION - scroll :: //

function _5bnetwork_function_scroll_ (e)
{
	var scroller = _5bnetwork_object_scroll_active_ ;
	
	if (!scroller)
	{
		for (var t = 0 ; t < _5bnetwork_collection_scroll_.length ; t++)
		{
			var obj = _5bnetwork_collection_scroll_[t] ;
			
			if (document.all)
			{
				if (obj.scrollButton == event.srcElement || obj.leftButton == event.srcElement || obj.rightButton == event.srcElement)
				{
					_5bnetwork_object_scroll_active_ = obj ;
					
					scroller = _5bnetwork_object_scroll_active_ ;
					
					break ;
				}
			}
			else
			{
				if (obj.scrollButton == e.target || obj.leftButton == e.target || obj.rightButton == e.target)
				{
					_5bnetwork_object_scroll_active_ = obj ;
					
					scroller = _5bnetwork_object_scroll_active_ ;
					
					break ;
				}
			}
		}
	}
	
	if (scroller)
	{
		var ev, er, x, y ;
		
		if (document.all)
		{
			ev = event.type ;
	
			x = event.clientX ;
	
			y = event.clientY ;
	
			event.returnValue = true ;
		}
		else
		{
			ev = e.type ;
	
			x = e.pageX ;
	
			y = e.pageY ;
	
			er = true ;
		}
		
		if (ev == "mousedown")
		{
			if (_5bnetwork_function_is_scroll_mousedown_(e))
			{
				document.onmousemove = _5bnetwork_function_scroll_ ;
	
				(document.all) ? event.returnValue = false : er = false ;
			}
			else if (_5bnetwork_function_is_scroll_mouseover_left_(e))
			{
				_5bnetwork_function_scrolling_horizontal_btn_left_() ;
	
				(document.all) ? event.returnValue = false : er = false ;
			}
			else if (_5bnetwork_function_is_scroll_mouseover_right_(e))
			{
				_5bnetwork_function_scrolling_horizontal_btn_right_() ;
	
				(document.all) ? event.returnValue = false : er = false ;
			}
		}
		else if (ev == "mousemove")
		{
			if (scroller.type == "horizontal")
			{
				var i = x - scroller.startLeft ;
	
				i = Math.max(i,scroller.scrollButtonStart) ;
		
				i = Math.min(i,scroller.scrollButtonStart + scroller.scrollButtonDistance) ;
				
				scroller.scrollButton.style.left = i + "px" ;
	
				_5bnetwork_function_scrolling_horizontal_() ;
			}
			else if (scroller.type == "vertical")
			{
				var i = y - scroller.startTop ;
	
				i = Math.max(i,scroller.scrollButtonStart) ;
		
				i = Math.min(i,scroller.scrollButtonStart + scroller.scrollButtonDistance) ;
			
				scroller.scrollButton.style.top = i + "px" ;
	
				_5bnetwork_function_scrolling_vertical_() ;
			}
	
			(document.all) ? event.returnValue = false : er = false ;
		}
		else if (ev == "mouseup")
		{
			document.onmousemove = null ;
			
			_5bnetwork_object_scroll_active_ = null ;
	
			(document.all) ? event.returnValue = false : er = false ;
		}
	
		if (!document.all) return er ;
	}
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// :: FUNCTION - over, down :: //

	function _5bnetwork_function_is_scroll_mousedown_ (e)
	{
		var bool ;
		
		var scroller = _5bnetwork_object_scroll_active_ ;
		
		var x, y ;
		
		if (document.all)
		{
			x = event.clientX ;
		
			y = event.clientY ;
		}
		else
		{
			x = e.pageX ;
	
			y = e.pageY ;
		}
	
		var x1 = scroller.startLeft + scroller.scrollButton.offsetLeft ;
		
		var x2 = scroller.startLeft + scroller.scrollButton.offsetLeft + scroller.scrollButton.offsetWidth ;
	
		var y1 = scroller.startTop + scroller.scrollButton.offsetTop ;
	
		var y2 = scroller.startTop + scroller.scrollButton.offsetTop + scroller.scrollButton.offsetHeight ;
		
		(x >= x1 && x <= x2 && y >= y1 && y <= y2) ? bool = true : bool = false ;
		
		return bool ;
	}
	
	function _5bnetwork_function_is_scroll_mouseover_left_ (e)
	{
		var bool ;
		
		var scroller = _5bnetwork_object_scroll_active_ ;
		
		var x, y ;
		
		if (document.all)
		{
			x = event.clientX ;
		
			y = event.clientY ;
		}
		else
		{
			x = e.pageX ;
	
			y = e.pageY ;
		}
	
		var x1 = scroller.startLeft + scroller.leftButton.offsetLeft ;
		
		var x2 = scroller.startLeft + scroller.leftButton.offsetLeft + scroller.leftButton.offsetWidth ;
	
		var y1 = scroller.startTop + scroller.leftButton.offsetTop ;
	
		var y2 = scroller.startTop + scroller.leftButton.offsetTop + scroller.leftButton.offsetHeight ;
		
		(x >= x1 && x <= x2 && y >= y1 && y <= y2) ? bool = true : bool = false ;
		
		return bool ;
	}
	
	function _5bnetwork_function_is_scroll_mouseover_right_ (e)
	{
		var bool ;
		
		var scroller = _5bnetwork_object_scroll_active_ ;
		
		var x, y ;
		
		if (document.all)
		{
			x = event.clientX ;
		
			y = event.clientY ;
		}
		else
		{
			x = e.pageX ;
	
			y = e.pageY ;
		}
	
		var x1 = scroller.startLeft + scroller.rightButton.offsetLeft ;
		
		var x2 = scroller.startLeft + scroller.rightButton.offsetLeft + scroller.rightButton.offsetWidth ;
	
		var y1 = scroller.startTop + scroller.rightButton.offsetTop ;
	
		var y2 = scroller.startTop + scroller.rightButton.offsetTop + scroller.rightButton.offsetHeight ;
		
		(x >= x1 && x <= x2 && y >= y1 && y <= y2) ? bool = true : bool = false ;
		
		return bool ;
	}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
// :: FUNCTION - scrolling :: //

	function _5bnetwork_function_scrolling_horizontal_ ()
	{
		var scroller = _5bnetwork_object_scroll_active_ ;
		
		var l = scroller.scrollButton.offsetLeft - scroller.scrollButtonStart ;
	
		var d = scroller.cacheLayer.offsetWidth - scroller.scrollLayer.offsetWidth ;
	
		scroller.scrollLayer.style.left = (l * d / scroller.scrollButtonDistance) + "px" ;
	}
	
	function _5bnetwork_function_scrolling_vertical_ ()
	{
		var scroller = _5bnetwork_object_scroll_active_ ;
		
		var l = scroller.scrollButton.offsetTop - scroller.scrollButtonStart ;
	
		var d = scroller.cacheLayer.offsetHeight - scroller.scrollLayer.offsetHeight ;
	
		scroller.scrollLayer.style.top = (l * d / scroller.scrollButtonDistance) + "px" ;
	}
	
	function _5bnetwork_function_scrolling_horizontal_btn_left_ ()
	{
		var scroller = _5bnetwork_object_scroll_active_ ;
		
		if (scroller)
		{
			var d = scroller.cacheLayer.offsetWidth - scroller.scrollLayer.offsetWidth ;
		
			for (var t = 0 ; t < scroller.speed ; t++)
			{
				if (parseInt(scroller.scrollLayer.style.left,10) < 0)
				{
					scroller.scrollLayer.style.left = parseInt(scroller.scrollLayer.style.left,10) + 1 + "px" ;
					
					scroller.scrollButton.style.left = 77 + (parseInt(scroller.scrollLayer.style.left,10) * scroller.scrollButtonDistance / d) + "px" ;
				}
			}
				
			setTimeout("_5bnetwork_function_scrolling_horizontal_btn_left_()",0) ;
		}
	}
	
	function _5bnetwork_function_scrolling_horizontal_btn_right_ ()
	{
		var scroller = _5bnetwork_object_scroll_active_ ;
		
		if (scroller)
		{
			var d = scroller.cacheLayer.offsetWidth - scroller.scrollLayer.offsetWidth ;
			
			if (scroller.scrollLayer.style.left == "") scroller.scrollLayer.style.left = "0px" ;
		
			for (var t = 0 ; t < scroller.speed ; t++)
			{
				if (parseInt(scroller.scrollLayer.style.left,10) > scroller.cacheLayer.offsetWidth - scroller.scrollLayer.offsetWidth)
				{
					scroller.scrollLayer.style.left = parseInt(scroller.scrollLayer.style.left,10) - 1 + "px" ;
					
					scroller.scrollButton.style.left = 77 + (parseInt(scroller.scrollLayer.style.left,10) * scroller.scrollButtonDistance / d) + "px" ;
				}
			}
			
			setTimeout("_5bnetwork_function_scrolling_horizontal_btn_right_()",0) ;
		}
	}