I wrote this code using jQuery, but I think it can be improved. Can you provide some feedback?    var $i = 1,    totalImg = $('.home-featured-bg .absolute div').length,    $theWidth = $(window).width(),    $theHeight = $(window).height();    $('.home-featured-bg .absolute').css('width',$theWidth * totalImg+'px');    $('.home-featured-bg .absolute .slide,.home-featured-bg .absolute .slide img').css({'width':$theWidth+'px','height' : $theHeight+'px'});window.setInterval(function(){    $('.events-links a').hide();    if($i == 1)    {        var $el = $theWidth;    }else{        var $el = $theWidth * $i;    }    if($i < totalImg)    {        $('.home-featured-bg .absolute').animate({'margin-left':'-'+$el+'px'},2000);        $i++;        $('.events-links a').eq($i - 1).css('display','block');    }else{        $('.home-featured-bg .absolute').animate({'margin-left':'0px'},2000);        $i = 1;        $('.events-links a').eq($i - 1).css('display','block');    }},3000);$(window).resize(function(){    totalImg = $('.home-featured-bg .absolute div').length,    $theWidth = $(window).width(),    $theHeight = $(window).height();    $('.home-featured-bg .absolute').css('width',$theWidth * totalImg+'px');    $('.home-featured-bg .absolute .slide,.home-featured-bg .absolute .slide img').css({'width':$theWidth+'px','height' : $theHeight});});
Periodically sliding images
javascript;jquery;css;animation