function scrolling(value, element, slider) {
			if(slider.axis == "vertical"){
				element.scrollTop = Math.round(value/slider.maximum*(element.scrollHeight-element.offsetHeight));
			}else{
				element.scrollLeft = Math.round(value/slider.maximum*(element.scrollWidth-element.offsetWidth));
			}
}


function setSliderValue(value, slider){
		
			element = slider.scrollContent;
			
			if(slider.axis == "vertical"){
				scrollValue = (value/($(element).scrollHeight - $(element).offsetHeight));	
			}else{
				scrollValue = (value/($(element).scrollWidth - $(element).offsetWidth));	
			}			
			
			slider.setValue(slider.value + scrollValue);
}

function stopSlide(){			
			clearInterval(slidingInt);			
}

function startSlide(value, slider) {
			slidingInt = setInterval("setSliderValue("+value+","+slider+")",50);
}


function slideAlt(contentSlided,name,direction,content,handle,track,control1,control2){
	
	slide(contentSlided);
	function scrollrefresh(){
		createScroll(name,direction,content,handle,track,control1,control2)
	};
	if(window[name] == undefined){
		setTimeout(scrollrefresh, 100);
	}
	
};
function createScroll(name,direction,content,handle,track,control1,control2){
		
		//alert($(content).scrollHeight);
		
		var totalHeight = parseFloat($(content).parentNode.style.height.substring(0,$(content).parentNode.style.height.length-2));
		//alert(totalHeight);
		if($(content).offsetHeight == 0){
				$(content).offsetHeight = totalHeight;	
		}
		
		
		window[name] = new Control.Slider(handle, track, {
			axis: direction,
			onSlide: function(v) { scrolling(v, $(content), window[name]);  },
			onChange: function(v) { scrolling(v, $(content), window[name]); }
		});
				
		window[name].scrollContent = content;				
		
		
		
		// disable vertical and horizontal scrolling if text doesn't overflow the div
		if(direction == 'vertical'){
			
			if ($(content).scrollHeight <= $(content).offsetHeight) {
				window[name].setDisabled();
				$(track).hide();						
				$(control1).hide();	
				$(control2).hide();
			}
		}else{
			if ($(content).scrollWidth <= $(content).offsetWidth) {					
				window[name].setDisabled();
				$(track).hide();						
				$(control1).hide();	
				$(control2).hide();
			}
		}
					
}
			
