//Function to set up the Inside Stories Showcase
$(document).ready(
    function initiateInsideStoriesShowcase(){
        var currentShowcase = 1;                    //Start the Showcase at the first inside story    
        showInsideStoryShowcase(currentShowcase);   //Show the first inside story
        //Add a click event to the previous button
        $("#insideStoriesSpotlightNavPrev").click(
            function showPreviousInsideStoryShowcase(){
                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
                hideInsideStoryShowcase(currentShowcase);   //Hide the current showcase
                showInsideStoryShowcase(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
        $("#insideStoriesSpotlightNavNext").click(
            function showNextInsideStoryShowcase(){
                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
                hideInsideStoryShowcase(currentShowcase);   //Hide the current showcase
                showInsideStoryShowcase(nextShowcase);      //Show the next showcase
                currentShowcase = nextShowcase;             //Set the current showcase to the showcase we've just shown
                return false;
            }
        );              
    }
);

function hideInsideStoryShowcase(intShowcase)
{
    $("#insideStoriesSpotlight" + intShowcase.toString()).hide();
}

function showInsideStoryShowcase(intShowcase)
{
    var pathString = $("#insideStoriesSpotlight" + intShowcase.toString()).find(".insideStoriesSpotlightPaths").attr("rel");
    var pathArray = pathString.split("|");
    var imagePath = pathArray[0];
    var pdfPath = pathArray[1];
    var fileSize = pathArray[2];
    $("#imgInsideStoriesSpotlight").attr("src",imagePath);
    $("#divInsideStoriesSpotlightLink").find("a").attr("href",pdfPath);
    $(".linkInsideStoriesImageToPDF").attr("href",pdfPath);
    $(".insideStoriesSpotlightFileSize").html(fileSize);
    $("#insideStoriesSpotlight" + intShowcase.toString()).show();
}