/*
Truncate Sentences Plugin allows you to truncate sentences from displayed text and apply a suffx.
-Evan Rutledge Borden
*/

(function($) {
  $.fn.truncateSentences = function(sentences,suffix) {
  	return this.each(function(){
		if(!suffix) suffix = ".";
		if(!sentences) sentences = 1;
		textval = $(this).text();
		index = 0;
		testtext = textval;
		for(i=0;i<sentences;i++){
			testindex = testtext.search(/(\.|\!|\?)/);
			index += testindex+1;
			testtext = testtext.slice(testindex+1);
		}
		$(this).text(textval.slice(0,index-1)).append(suffix);
	});
  }
})(jQuery);