$(document).ready(function() {
	$('.sliderWrapper').cycle({
		fx: 'scrollHorz',
		next: '#slider-rightArrow',
		prev: '#slider-leftArrow',
		before: function(curr, next, opts) {
			opts.animOut.opacity = 0;
			$('#slider-rightArrow').css('display', 'none');
		},
		after: function(curr, next, opts) {
			$('#slider-rightArrow').css('display', 'block');
		},
		timeout: 6000,
		cleartype: true,
		cleartypeNoBg: true
	});
	/*
	Carousel currently disabled because there are only 5 items
	$('#carousel').cycle({
		fx: 'scrollHorz',
		containerResize: false,
		next: '#carousel-rightArrow',
		prev: '#carousel-leftArrow',
		timeout: 0
	});
	*/
	
	$('.readMoreDiv').find('a').html('Read More');
	var articleTitle = $('.mArticleDivWrapperFirst').find('a').text();
	var articleTitleLength = articleTitle.length;
	
	if ( articleTitleLength > 60 ) {
		var index = 0;
		var lastChar = articleTitle.substring(articleTitleLength - index);
		var SPACE = ' ';
		//console.log('articleTitle: ' + articleTitle);
		//console.log('lastChar: ' + lastChar);
		do {
			index = index + 1;
			lastChar = articleTitle.substring( (articleTitleLength - (index-1)), (articleTitleLength - index));
			//console.log('index: ' + index);
			//console.log('lastChar: ' + lastChar);
		}while(lastChar != ' ');
		$('.mArticleDivWrapperFirst').find('a').text( (articleTitle.substring( 0, (articleTitleLength - index) ) + '...') );
	}
});
