window.onresize = function(event){
	$('.ui-slider-handle:last').width(Math.round($('#slider').width() * document.documentElement.clientWidth / $('#index').attr('scrollWidth')));
	$('#slider').slider('option', 'max', $('#index').attr('scrollWidth') - document.documentElement.clientWidth);
}

$(document).ready(function(){
	$('#slider').slider({
		min: 0,
		max: $('#index').attr('scrollWidth') - document.documentElement.clientWidth,
		// step: 20,
		start: stopSliderAnimation,
		change: sliderChanged,
		slide: sliderChanged
	});
	
	$('.ui-slider-handle:first').width('0px');
	
	window.onresize();
	
	if ($('#index').attr('scrollWidth') > document.documentElement.clientWidth)
	{
		startSliderAnimation();
	}
	else
	{
		$('#slider').css('visibility', 'hidden');
		$('#slider').css('height', '0');
		$('#slider').css('margin-bottom', '0');
	}
	
	setupSearch();
	
	var img = new Image(); 
	for (var i=1; i<10; i++)
		img.src = '/images/index-line-'+i+'.png';
	
	$('.scrollable-area .over').mouseover(function(){
		if ($.browser.msie && $.browser.version < 7)
			return;
		
		if ($('#blackbox').html() == $(this).children('.blackbox').html())
		{
			$('#blackbox').show();
			stopSliderAnimation(1);
			return;
		}
		
		$('#blackbox').remove();
		$(this).append('<div id="blackbox">'+$(this).children('.blackbox').html()+'</div>');
		$('#blackbox').show();
		
		stopSliderAnimation(1);
		if ($('#blackbox').offset().left+$('#blackbox').width() > $('body').width()-350)
			$('#slider').slider('option', 'value', 430);
	});
	
	$('.scrollable-area .over, .scrollable-area .over #blackbox').mouseout(function(){
		if ($.browser.msie && $.browser.version < 7)
			return;
			
			$('#blackbox').hide();
			
			setTimeout(function(){
				if ($('#blackbox') && $('#blackbox').css('display') == 'none')
					$('#blackbox').remove();
			}, 500);
		
		startSliderAnimation();
	});
});
