﻿//variables
var brandscrollstep = 20;
var brandscrolltime = 10;
var brandspeedupstart = 600;
var brandspeedupstep = 150;
var brandtimer = 0;
var brandspeeduptimer = 0;

//onload scroll right
function onloadBrandScroll() {
    clearTimeout(brandtimer);
    if (brandscrollstep > 0) {
        $('brandslistholder').scrollLeft += brandscrollstep;
        brandscrollstep -= 1;
        brandtimer = setTimeout("onloadBrandScroll()", brandscrolltime);
    }
    else
        brandscrollstep = 2;
}

//scroll brand left
function scrollBrandLeft() {
    clearTimeout(brandtimer);
    $('brandslistholder').scrollLeft -= brandscrollstep;
    brandtimer = setTimeout("scrollBrandLeft()", brandscrolltime);

    //speed up
    if (brandspeeduptimer == 0)
        brandspeeduptimer = setTimeout("speedUpBrandLeft()", brandspeedupstart);
}

//speed up brand left
function speedUpBrandLeft() {
    clearTimeout(brandspeeduptimer);
    brandscrollstep += 1;
    brandspeeduptimer = setTimeout("speedUpBrandLeft()", brandspeedupstep);
}

//stop left scrolling
function stopBrandLeft() {
    clearTimeout(brandtimer);
    clearTimeout(brandspeeduptimer);
    brandtimer = 0;
    brandspeeduptimer = 0;
    brandscrollstep = 2;
}

//scroll brand right
function scrollBrandRight() {
    clearTimeout(brandtimer);
    $('brandslistholder').scrollLeft += brandscrollstep;
    brandtimer = setTimeout("scrollBrandRight()", brandscrolltime);

    //speed up
    if (brandspeeduptimer == 0)
        brandspeeduptimer = setTimeout("speedUpBrandRight()", brandspeedupstart);
}

//speed up brand right
function speedUpBrandRight() {
    clearTimeout(brandspeeduptimer);
    brandscrollstep += 1;
    brandspeeduptimer = setTimeout("speedUpBrandRight()", brandspeedupstep);
}

//stop right scrolling
function stopBrandRight() {
    clearTimeout(brandtimer);
    clearTimeout(brandspeeduptimer);
    brandtimer = 0;
    brandspeeduptimer = 0;
    brandscrollstep = 2;
}

