/**
 * 
 */


$(document).ready(function() {
						
			$('#brandScroller').scroller({
				direction:       'vertical',
				duration:        2000,
				scrollId:        'brandPane',
				auto:            'true',
				backButtonId:    'back',
				nextButtonId:    'next',
				autoBuffer:      5000,
				stopAutoOnClick: 'false',
				resetOnEnd:      'true'
			});
			
			$('#homeScroller').textScroller({
				direction:       'horizontal',
				duration:        2000,			
				scrollId:        'scrollPane', 
				backButtonId :   'backButton',    
				nextButtonId :   'nextButton',    
				easingType :     '',
				scrollValue :    474,
				auto:            'false'      
			});
			
			$('#brandList').textScroller({
				direction:       'horizontal',
				duration:        2000,			
				scrollId:        'brands', 
				backButtonId :   'backBrands',    
				nextButtonId :   'nextBrands',    
				easingType :     '',
				scrollValue :    536,
				auto:            'false'      
			});
			
			initBanner();
});

function initBanner()
{
	setInterval(function() {
		$('#bannerSlider div.bannerSlide').each(function() {
			if ($(this).width() == 195) {
				$(this).children().click();
			}
		});
	}, 10000);
	$('#bannerSlider div.bannerSlide div').click(function() {
		var rand = randomInt(0, $('#bannerSlider div.bannerSlide').length - 1);
		rand = (rand == $(this).attr('id').replace('slide_', '')) ? ((rand + 1 > $('#bannerSlider div.bannerSlide').length - 1) ? rand - 1 : rand + 1) : rand;
		
		$('.bannerTitle').hide();
		$('#bannerTitle_' + rand).fadeIn(2000);
		
		$('#slide_' + rand).parent().animate({
			width: '195px'
		}, 1000);
		
		$('#slide_' + rand).animate({
			opacity: 0.0
		}, 1000);
		
		$(this).parent().animate({
			width: '86px'
		}, 1000);
		
		$(this).animate({
			opacity: 0.50
		}, 1000);
	});
}

function randomInt(min, max)
{
	return Math.round(min + ((max - min)*(Math.random() % 1)));
}

			

