$(document).ready(function(){	
	$('#slider-big').anythingSlider({
		width          : 782,
		height         : 388,
		toggleControls : false,
		startStopped   : false,
		theme          : 'raceroom',
		themeDirectory : 'css/theme-raceroom.css',
		resizeContents : true,
		buildNavigation : false,
		autoPlay       : true,
		delay		   : 10000,
		infiniteSlides : false,
		animationTime  : 200
	}).bind('slide_begin', function(e, slider) {	
		if( $("#slider-thumbs" ).length ) 
		{
			$("#slider-thumbs a").each(function(i) {
				strActId = $(this).attr('id');
				$("#" + strActId).removeClass("act");
			});
	
			var iCurrentId = $('#slider-big').data('AnythingSlider').currentPage;
			iThumbSector = Math.ceil(iCurrentId/9);
			var iThumbCurrentId = $('#slider-thumbs').data('AnythingSlider').currentPage;
			if( iThumbSector != iThumbCurrentId )
			{
				$('#slider-thumbs').anythingSlider(iThumbSector);
			}
			
			$("#thumb-" + iCurrentId).addClass("act");			
		}		
	})
	
	if( $("#slider-thumbs" ).length ) 
	{
		$('#slider-thumbs').anythingSlider({
			width          : 823,
			height         : 62,
			toggleControls : false,
			startStopped   : false,
			theme          : 'raceroom-thumbs',
			themeDirectory : 'css/theme-raceroom-thumbs.css',
			resizeContents : true,
			buildNavigation : false,
			autoPlay       : false,
			infiniteSlides : false
		})	
		.find('a').click( function() {
			$("#slider-thumbs a").each(function(i) {
				strActId = $(this).attr('id');
				iIdPart = strActId.substr( 6, strActId.length );																
				$("#" + strActId).removeClass("act");
			}); 
			
			strActId = $(this).attr('id');
			iIdPart = strActId.substr( 6, strActId.length );
			$("#thumb-" + iIdPart).addClass("act");
			$('#slider-big').anythingSlider(iIdPart);
		})
	}
});
