//Function to set up the New Product Releases Showcase
$(document).ready(
    function initiateNewProductReleaseShowcase(){
        var currentShowcase = 1;                    //Start the Showcase at the first new product release  
        if ($("#divContentSpotlightLeft").length > 0)
        {
            showNewProductReleaseShowcase(currentShowcase);      //Show the first new product release
        }
        //Add a click event to the previous button
        $("#newProductReleasesSpotlightNavPrev").click(
            function showPreviousNewProductReleaseShowcase(){
                var nextShowcase = currentShowcase - 1;         //Set the next showcase number to the next lowest showcase number
                if (nextShowcase == 0) {nextShowcase = 4;}      //If the next showcase would be 0 make the next showcase, showcase 4
                hideNewProductReleaseShowcase(currentShowcase); //Hide the current showcase
                showNewProductReleaseShowcase(nextShowcase);    //Show the next showcase
                currentShowcase = nextShowcase;                 //Set the current showcase to the showcase we've just shown
                return false;
            }
        );
        //Add a click event to the next button
        $("#newProductReleasesSpotlightNavNext").click(
            function showNextNewProductReleaseShowcase(){
                var nextShowcase = currentShowcase + 1;         //Set the next showcase number to the next highest showcase number
                if (nextShowcase == 5) {nextShowcase = 1;}      //If the next showcase would be 5 make the next showcase, showcase 1
                hideNewProductReleaseShowcase(currentShowcase); //Hide the current showcase
                showNewProductReleaseShowcase(nextShowcase);    //Show the next showcase
                currentShowcase = nextShowcase;                 //Set the current showcase to the showcase we've just shown
                return false;
            }
        );              
    }
);

function hideNewProductReleaseShowcase(intNewProductRelease)
{
    $("#newProductReleasesSpotlight" + intNewProductRelease.toString()).hide();
}

function showNewProductReleaseShowcase(intNewProductRelease)
{
    var pathString = $("#newProductReleasesSpotlight" + intNewProductRelease.toString()).find(".newProductReleasesSpotlightPaths").attr("rel");
    var pathArray = pathString.split("|");
    var imagePath = pathArray[0];
    var linkPath = pathArray[1];
    $("#imgNewProductReleasesSpotlight").attr("src",imagePath);
    $("#linkNewProductReleasesSpotlightImage").attr("href",linkPath);
    $("#newProductReleasesSpotlight" + intNewProductRelease.toString()).show();
}
