jQuery(document).ready(
    function initiateFeaturesShowcase(){
        var nNewsRight = parseInt(jQuery("#nTotalNoticias").attr("valor"));
		  if(nNewsRight<=1){
				jQuery("#featuresSpotlightNavPrev").hide();
				jQuery("#featuresSpotlightNavNext").hide();
		  }
		  var currentShowcase = 1;                    
        if (nNewsRight > 0)
        {
            showFeaturesShowcase(currentShowcase);  
        }
        jQuery("#featuresSpotlightNavPrev").click(
            function showPreviousFeaturesShowcase(){
                var nextShowcase = currentShowcase - 1; 
                if (nextShowcase == 0) {nextShowcase = nNewsRight;}
                hideFeaturesShowcase(currentShowcase);    
                showFeaturesShowcase(nextShowcase);       
                currentShowcase = nextShowcase;           
                return false;
            }
        );
      jQuery("#featuresSpotlightNavNext").click(
            function showNextFeaturesShowcase(){
                var nextShowcase = currentShowcase + 1;
                if (nextShowcase == (nNewsRight+1)) {nextShowcase = 1;}
                hideFeaturesShowcase(currentShowcase);    
                showFeaturesShowcase(nextShowcase);       
                currentShowcase = nextShowcase;           
                return false;
            }
        );              
    }
);

function hideFeaturesShowcase(intFeature)
{
   jQuery("#featuresSpotlight" + intFeature.toString()).hide();
}

function showFeaturesShowcase(intFeature)
{
   var pathString = jQuery("#featuresSpotlight" + intFeature.toString()).find(".featuresSpotlightPaths").attr("rel");
   if(pathString!=undefined){
		var pathArray = pathString.split("|");
   	var imagePath = pathArray[0];
		var linkPath = pathArray[1];   
		jQuery("#imgFeaturesSpotlight").attr("src",imagePath);
		jQuery(".linkFeaturesImage").attr("href",linkPath);
		jQuery("#featuresSpotlight" + intFeature.toString()).show();
	}
}
