/**
 * @author ccortes
 */
var realStories = {
    moreUrl: '#',
    linkText: 'MORE STORIES',
	init: function(){
		this.setNavigation();
		this.setInitState();
		$('#navCarousel a').click(function(){
			realStories.showItem($(this));
		});
	},
	setNavigation: function(){
		$('#navCarousel').append(this.buttonsHTML($('#realStoriesStage .realStory').length));
	},
	setInitState: function(){
		$('#realStoriesStage .realStory').each(function(){
			$(this).hide();
		});
		$('#realStoriesStage .realStory:first').show();
	},
	showItem: function(objLink){
		if ($(objLink).html().length == 1) {
			var divToShow = 'div.story' + $(objLink).html();
			var divShown = 'div.story' + $('#navCarousel a.current').html();
			$('#navCarousel a.current').removeClass('current');
			$(objLink).addClass('current');
			$(divShown).fadeOut('slow', function(){
				$(divToShow).fadeIn('slow')
			});
		}
	},
	buttonsHTML: function(numButtons){
		var classActive = 'current';
		var output = '';
		if (numButtons > 1) {
			for (i = 1; i <= numButtons; i++) {
				output += '<a class="btnNumber ' + classActive + ' arial_12" href="javascript:void(0);">' + i + '</a>';
				classActive = '';
			}
		}
		output += '<a class="more arial_12" href="'+ this.moreUrl +'">' + this.linkText + '</a>';
		return output;
	}
}
