$(document).ready(function() {

	$('.truncate').each(function() {
		
		var length = 10;
    	var stringLength = $(this).attr('strLn');
    	if(typeof stringLength !== 'undefined' && stringLength !== false)
    	{
    		length = stringLength;
    	}
		
		var trunc = $(this).text();
		if (trunc.length > length) {
		
		    /* Truncate the content of the P, then go back to the end of the
		       previous word to ensure that we don't truncate in the middle of
		       a word */
		    trunc = trunc.substring(0, length)+"...";
		    $(this).text(trunc);
		}
    });
	
	
});


function truncate(message, length)
{		
		var trunc = "";
	    trunc = message.substring(0, length)+"...";
	    return trunc;
	
}
