var totalSlides;
var current = 1;
var pixels = 0;
var slideshow;

$(document).ready(function() {
    totalSlides = $(".showcaseSlide").length;
    slideshow = setInterval( nextSlide, 5500);
    /*$('.navactive').css("backgroundPosition", "0 -62px");
    $('.navbutton').each(function(index) {
        $('#'+$(this).text()+'_btn').mouseover(function() {
            $('#'+$(this).text()+'_btn').css("backgroundPosition", "0 -31px");
        });
        $('#'+$(this).text()+'_btn').mouseout(function() {
            $('#'+$(this).text()+'_btn').css("backgroundPosition", "0 0");
        });
    });*/
});


function nextSlide(stop) {
    if(stop == "stop") clearInterval(slideshow);
    //Figure out where it needs to animate to.
    current++;
    if(current > totalSlides) {
        current = 1;
    }
    pixels = (current-1) * 810
    
    //Animate to the next slide.
    $('#slideshow').animate({ marginLeft : -pixels }, 450, 'swing');
}

function previousSlide(stop) {
    if(stop == "stop") clearInterval(slideshow);
    //Figure out where it needs to animate to.
    current--;
    if(current == 0) {
        current = totalSlides;
    }
    pixels = (current-1) * 810
    
    //Animate to the next slide.
    $('#slideshow').animate({ marginLeft : -pixels }, 450, 'swing');
}
