jQuery(document).ready(
 	function initiateInsideStoriesShowcase(){
        var nNews = parseInt(jQuery("#nTotalCases").attr("valor"));
		  if(nNews<=1){
				jQuery("#insideStoriesSpotlightNavPrev").hide();
				jQuery("#insideStoriesSpotlightNavNext").hide();
		  }
		  var currentShowcase = 1;
		  if (nNews > 0)
        {
            showInsideStoryShowcase(currentShowcase);  
        }
        jQuery("#insideStoriesSpotlightNavPrev").click(
				function showPreviousInsideStoryShowcase(){
					 var nextShowcase = currentShowcase - 1;   
                if (nextShowcase == 0) {nextShowcase = nNews;}
                hideInsideStoryShowcase(currentShowcase); 
                showInsideStoryShowcase(nextShowcase);    
                currentShowcase = nextShowcase;           
                return false;
            }
        );
        jQuery("#insideStoriesSpotlightNavNext").click(
            function showNextInsideStoryShowcase(){
                var nextShowcase = currentShowcase + 1;   
                if (nextShowcase == (nNews+1)) {nextShowcase = 1;}
                hideInsideStoryShowcase(currentShowcase); 
                showInsideStoryShowcase(nextShowcase);    
                currentShowcase = nextShowcase;           
                return false;
            }
        );              
    }
);

function hideInsideStoryShowcase(intShowcase)
{
    jQuery("#insideStoriesSpotlight" + intShowcase.toString()).hide();
}

function showInsideStoryShowcase(intShowcase)
{
	 var pathString = jQuery("#insideStoriesSpotlight" + intShowcase.toString()).find(".insideStoriesSpotlightPaths").attr("rel");
	 if(pathString!=undefined){
		 var pathArray = pathString.split("|");
		 var imagePath = pathArray[0];
		 var pathLink = pathArray[1];
		 jQuery("#imgInsideStoriesSpotlight").attr("src",imagePath);
		 jQuery("#divInsideStoriesSpotlightLink").find("a").attr("href",pathLink);
		 jQuery(".linkInsideStoriesImage").attr("href",pathLink);
		 jQuery("#insideStoriesSpotlight" + intShowcase.toString()).show();
	 }
}
