// Javascript for Tennis WP Theme

function scrollUp(elem) {
    window.px = 15;
    upInterval = setInterval(function(){setBgP(elem)}, 10);
}

function setBgP(elem) {
    if ( px == 0 ) {
        clearInterval(upInterval);
    }

    px--;
    var bgP = '0px ' + px + 'px';
    elem.style.backgroundPosition = bgP;
}

function scrollDown(elem) {
    clearInterval(upInterval);
    elem.style.backgroundPosition = '0px 15px';
}


window.onload = function() {
    // collect nav item elems and attach behaviors
    var navElems = $$('a.tennis-nav-item');
    for( var i = 0; i < navElems.length; i++ ) {
        var navElem = navElems[i];
        navElem.onmouseover = function() { scrollUp(this) };
        navElem.onmouseout  = function() { scrollDown(this) };
    }
}