var scrollerTimer = 0;

function scrollBrands(speed, limit)
{
	curLeft = $('#brand-scroller-holder ul').position().left + speed;
	if (curLeft > 0) curLeft = 0;
	if (curLeft < limit) curLeft = limit;
	$('#brand-scroller-holder ul').css('left', curLeft.toString() + 'px');
}

$(document).ready(function () {
	containerWidth = $('#brand-scroller-holder').width();
	scrollerWidth = 0;
	$('#brand-scroller-holder ul li').each(function (i) { scrollerWidth += $(this).width()} );
	limit = (containerWidth - scrollerWidth) + 2;

	$('#brand-scroller div.scroll-left').mouseenter(function(ev) {															 
		clearTimeout(scrollerTimer);
		if(navigator.appName=='Microsoft Internet Explorer') {
			scrollerTimer = setInterval(function() {scrollBrands(5, limit)}, 5);
		}else{
			scrollerTimer = setInterval(function() {scrollBrands(2, limit)}, 5);
		}
		
		//scrollerTimer = setInterval(function() {scrollBrands(2, limit)}, 5);
	});

	$('#brand-scroller div.scroll-left').mouseleave(function(ev) {
		clearTimeout(scrollerTimer);
	});

	$('#brand-scroller div.scroll-right').mouseenter(function(ev) {
		clearTimeout(scrollerTimer);
		
		if(navigator.appName=='Microsoft Internet Explorer') {
			scrollerTimer = setInterval(function() {scrollBrands(-5, limit)}, 5);
		}else{
			scrollerTimer = setInterval(function() {scrollBrands(-2, limit)}, 5);
		}
		
	});

	$('#brand-scroller div.scroll-right').mouseleave(function(ev) {
		clearTimeout(scrollerTimer);
	});

	$('.header-menu ul li').mouseover(function(ev) {
		$(this).addClass('hover');
	});

	$('.header-menu ul li').mouseout(function(ev) {
		$(this).removeClass('hover');
	});
});