$(document).ready(function(){

    var imgs = [
        "gfx/hero1.jpg", 
        "gfx/hero2.jpg", 
        "gfx/hero3.jpg", 
        "gfx/hero4.jpg"];
    
    var i = 0;
    
    var interval = 6000;
    
    function startTimer() { 
        setInterval(Slider, interval);
    };

    function Slider() {
        $("#heroScroller").fadeOut(1000, function() {
            i = (i+1) % imgs.length;
            $(this).attr("src", imgs[i]).fadeIn(1000);
        });
    };
    
    startTimer();
    
    $("li.sidebar").mouseover(function(){
        
        var sidebarProduct;
        
        sidebarProduct = $(this).attr("id");
        
        if (sidebarProduct == "Chimneys"){
            $("#heroScroller").attr("src","gfx/hero1.jpg");
        };
        
        if (sidebarProduct == "Arches"){
            $("#heroScroller").attr("src","gfx/hero2.jpg");
        };
        
        if (sidebarProduct == "Construction"){
            $("#heroScroller").attr("src","gfx/hero3.jpg");
        };
        
        if (sidebarProduct == "CutandBond"){
            $("#heroScroller").attr("src","gfx/hero4.jpg");
        };
    });
});

