var currentCaption = 0;
$(window).load(function() {
  switchItem();
  $("#main-cap-0").show();
  $('#slider').nivoSlider({
	effect:'sliceUpDown', //Specify sets like: 'fold,fade,sliceDown'
    slices:15,
    animSpeed:2000, //Slide transition speed
    pauseTime:15000,
    startSlide:0, //Set starting Slide (0 index)
    directionNav:true, //Next & Prev
    directionNavHide:true, //Only show on hover
    controlNav:false, //1,2,3...
    controlNavThumbs:false, //Use thumbnails for Control Nav
    controlNavThumbsFromRel:false, //Use image rel for thumbs
    controlNavThumbsSearch: '.jpg', //Replace this with...
    controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
    keyboardNav:true, //Use left & right arrows
    pauseOnHover:true, //Stop animation while hovering
    manualAdvance:false, //Force manual transitions
    captionOpacity:0.8, //Universal caption opacity
    beforeChange: function(){
	  $("#main-cap-" + currentCaption).fadeOut(1800);
	},
    afterChange: function(){
	  $("#main-cap-" + $('#slider').data('nivo:vars').currentSlide).fadeIn(500);
	  currentCaption = $('#slider').data('nivo:vars').currentSlide;
	},
    slideshowEnd: function(){}, //Triggers after all slides have been shown
    lastSlide: function(){}, //Triggers when last slide is shown
    afterLoad: function(){} //Triggers when slider has loaded
  });
});

//title, date, description, image, link
var stories = new Array();
var storyNum = 5;
function switchItem(){
	storyNum++;
	if(storyNum >= 5)//num of items
		storyNum = 0; //reset
	
	$('.news-box-section-title').fadeOut("fast");
	$('.news-box-title').fadeOut('fast', function(){
		$('.news-box-title').html(stories[0][storyNum]);
		$('.news-box-title').fadeIn('fast');
    });
	$('.news-box-post-date').fadeOut('fast', function(){
		$('.news-box-post-date').html(stories[1][storyNum]);
		$('.news-box-post-date').fadeIn('fast');
    });
	$('.news-box-desc').fadeOut('fast', function(){
		$('.news-box-desc').html(stories[2][storyNum]);
		$('.news-box-desc').fadeIn('fast');
    });
	$('#news-box-image').fadeOut('fast', function(){
		$('#news-box-image').attr('src', stories[3][storyNum]);
		$('#news-box-image').fadeIn('fast');
    });
	$('#news-box-link-0').attr('href',stories[4][storyNum]);
	$('#news-box-link-1').attr('href',stories[4][storyNum]);
	$('#news-box-link-2').attr('href',stories[4][storyNum]);

	$('.news-box-section-title').fadeIn("fast");

	var t = setTimeout("switchItem();", 8000);//5 seconds
}

