$(document).ready(function() {

		//-pagination
    var carouselPage = 1;
		function rectifyScrollerPagination(){
			//-left
			if( carouselPage == 1 )
				$('.arrowLeftCarousel a').removeClass( 'active' );
			else
				$('.arrowLeftCarousel a').addClass( 'active' );
			//-right
			if( carouselPage < (($('#carousel-window div.brand').length * 100) / 900) )
				$('.arrowRightCarousel a').addClass( 'active' );
			else
				$('.arrowRightCarousel a').removeClass( 'active' );
		}
    function carouselPrevious(e) {
        if (carouselPage > 1) {
            $('#carousel-window').stop();
            carouselPage--;
            $('#carousel-window').animate(
                { 'left': (1 - carouselPage) * $('#carousel-window').width() },
                1000, rectifyScrollerPagination
            );
        }
    }
    function carouselNext(e) {
        if (carouselPage < (($('#carousel-window div.brand').length * 100) / 900)) {
            $('#carousel-window').stop();
            carouselPage++;
            $('#carousel-window').animate(
                { 'left': (1 - carouselPage) * 900 },
                1000, rectifyScrollerPagination
            );
        }
    }
    $('.arrowLeftCarousel a').bind('click', carouselPrevious);
    $('.arrowRightCarousel a').bind('click', carouselNext);
		rectifyScrollerPagination();

    // brand hovers
    var c = 0;
    $('.brand').each(function() {
        $(this).css({ left: (c++ * 100), display: 'block' });
    });
    $('.brand img').each(function() {
        $(this).bind('mouseover', function() {
            $(this).stop().animate(
				{ width: 135, 'margin-left': -17, 'margin-top': 6 },
				180,
				function() {
				    $(this).css({ 'margin-top': -65, 'margin-left': 0, width: 101 });
				}
			);
        });
        $(this).bind('mouseout', function() {
            $(this).stop();
            $(this).css({ width: 135, 'margin-left': -17, 'margin-top': 6 });
            $(this).stop().animate(
				{ width: 101, 'margin-left': 0, 'margin-top': 18 },
				180
			);
        });
    });
});
