/*function handleSliderChange(e, ui)
{
	//$("#index").animate({scrollLeft: ui.value}, 1000);
	$("#index").attr({scrollLeft: ui.value});
}

function handleSliderSlide(e, ui)
{
	$("#index").attr({scrollLeft: ui.value});
}*/

var direction = 1, interval, timeout, disable_hover=0;

function sliderChanged(e, ui)
{
	$('.ui-slider-handle').css('margin-left', -ui.value/$('#slider').slider('option', 'max')*$('.ui-slider-handle').width());
	$("#index").attr({scrollLeft: ui.value});
}

function startSliderAnimation(event, ui)
{
	interval = setInterval(function(){
		var value = $('#slider').slider('option', 'value');
		
		if (value == $('#slider').slider('option', 'max'))
			direction = -1;
		else if (value == 0)
			direction = 1;
		
		$('#slider').slider('option', 'value', value+direction);
	}, 100);
}

function stopSliderAnimation(dontstartagain)
{
	clearInterval(interval);
	clearTimeout(timeout);
	if (!dontstartagain)
		timeout = setTimeout(function(){
			startSliderAnimation();
		}, 5000);
}
