﻿/* Licuit Interactive SL */
/* scroll.js */
/* Created Jul, 2009 */
/* Modified Jul, 2009
--------------------------------------- */
/*function makeScrollbar(content,scrollbar,handle){
	var steps = content.getSize().x - scrollbar.getSize().x;
		
	var slider = new Slider(scrollbar, handle, {	
		steps: steps,
		mode: 'vertical',
		onChange: function(step){
			content.setStyle('left',-step);
		}
	}).set(0);
}*/
	
			

function makeScrollbar(content,scrollbar,handle,horizontal){
	var steps = (horizontal?(content.getScrollSize().x - content.getSize().x):(content.getScrollSize().y - content.getSize().y))
	if(steps <= 0){
		scrollbar.setStyle("backgroundColor","#f6f6f5");
		handle.setStyle("backgroundColor","#f6f6f5");
		return;
	}
	var slider = new Slider(scrollbar, handle, {   
		steps: steps,
		mode: (horizontal?'horizontal':'vertical'),
		onChange: function(step){
			// Scrolls the content element in x or y direction.
			var x = (horizontal?step:0);
			var y = (horizontal?0:step);
			content.scrollTo(x,y);
		}
	}).set(0);
	
	
}


window.addEvent('domready', function(){    
			// -- first example, vertical scrollbar --
			makeScrollbar( $('cajaClientes'), $('scrollbar1'), $('handle1') );
			makeScrollbar( $('categorielist'), $('scrollbar2'), $('handle2') );
});