$(document).ready(function() {
    $('#slider').cycle({
        fx: 'fade',
        pager: '#slideNav',
        timeout: 6000,
        startingSlide: 4,
        before: onBefore,
        pagerAnchorBuilder: function(idx, slide) {
            return '#slideNav li:eq(' + idx + ') a';
        }
    });
    $('#slideNav a').click(function() {
        $('#slider').cycle('pause');
        return false;
    });
    $('#slider .entry').hover(function() {
        $(this).animate({ marginTop: '-15' }, 300);
        $('#slider').cycle('pause');
    }, function() {
        $(this).animate({ marginTop: '0' }, 300);
        $('#slider').cycle('resume');
    });
});

function onBefore(curr, next, opts) {
    var nT = $(next).index();
    var position = $('#slideNav li').eq(nT).find('a').position();
    var bgPos = $('#onSt').position();
    var curPos = bgPos.left;
    $('#onSt').stop().animate({ left: position.left }, 1000);
}



