var videos_direction = 0;
var videos_position  = 0;

function videos_scroll(direction) {
	videos_direction = parseInt(direction);
}

function videos_scroller(startup) {
	if (videos_direction != 0 || startup != 0) {            			            			
		videos_position += videos_direction*5;
		element = document.getElementById('gallery-videos');
		var width = element.offsetWidth - 10;
		if (videos_position > 0) 
			videos_position = 0; 
		if ((width + videos_position) < element.parentNode.offsetWidth ) 
			videos_position = element.parentNode.offsetWidth - width;
		element.style.left = videos_position+'px';
		var scrollers_box = document.getElementById('scrollers-box');
		
		var left_scroll = document.getElementById('left-scroll-span');
		if ( videos_position == 0 ) {
			if (left_scroll.getAttribute('class') != 'disabled') {
				left_scroll.setAttribute('class', 'disabled');
				left_scroll.style.background = 'url('+juristat+'/static/images/arrow_red_left_bw.gif) no-repeat';
			}
		} else {
			if (left_scroll.getAttribute('class') != 'enabled') {
				left_scroll.setAttribute('class', 'enabled');
				left_scroll.style.background = 'url('+juristat+'/static/images/arrow_red_left.gif) no-repeat';
			}
		}
		
		var right_scroll = document.getElementById('right-scroll-span');
		if ((width + videos_position) == element.parentNode.offsetWidth ) {
			if (right_scroll.getAttribute('class') != 'disabled') {
				right_scroll.setAttribute('class', 'disabled');
				right_scroll.style.background = 'url('+juristat+'/static/images/arrow_red_right_bw.gif) no-repeat';
			}
		} else {
			if (right_scroll.getAttribute('class') != 'enabled') {
				right_scroll.setAttribute('class', 'enabled');
				right_scroll.style.background = 'url('+juristat+'/static/images/arrow_red_right.gif) no-repeat';
			}
		} 
		            		
		setTimeout(function(){videos_scroller(0)}, 80);
	} else {
		setTimeout(function(){videos_scroller(0)}, 400);
	}
}

