$(function() {

    var autoPlay = true;
    var currentSlide = 1;
    var numSlides = 5;
    
    var slideHeight = $("#home-fader-bg").height();

    $("#home-fader-nav a").click(function() {
            
        goToSlide($(this).text());
        
        autoPlay = false;
        
    });
    
    function goToSlide(theSlide) {
            
       
        $("#home-fader-bg").fadeOut(808, function() {
        
            distance = (theSlide-1) * slideHeight;
                    
            $(this)
                .css({backgroundPosition: "0 -" + distance + "px"})
                .fadeIn(400);
                
            $("#home-fader-desc div#slide-" + theSlide + "-text").fadeIn(400).addClass("current");
        
        });
        
    }
    
    function moveSlide() {
        if (autoPlay) {
            currentSlide = currentSlide + 1;
            if (currentSlide > numSlides) { currentSlide = 1; }
            goToSlide(currentSlide);
        }
    }
    
    var int = setInterval(moveSlide, 6000);

});
