/* snippetClipper.js - function to trim the title of a 
 *     snippet to a length that will reside on a single 
 *     line. In the event that this has to be done, the 
 *     title of the anchor will be the full text.
 */

jQuery.fn.snippetClipper = function() {
	return jQuery(this).each(function(){
		if(jQuery("h4 a", jQuery(this) ).length > 0){
			jQuery("h4 a", jQuery(this) ).each(function(){
				$this = jQuery(this);
				if (($this).text().length > 60 ){
					$this.attr('title', $this.text() )
					 .truncate(60, {
					     chars: /./,
				         leave: false,
					     trail: [true, '...','']
					});
				}
			})
		}
		if(jQuery(".main p.description", jQuery(this)).length > 0) {
			jQuery(".main p.description", jQuery(this) ).each(function(){
				$this = jQuery(this);
				if (($this).text().length > 70 ){
					$this.attr('title', $this.text() )
					 .truncate(70, {
					     chars: /./,
				         leave: false,
					     trail: [true, '...','']
					});
				}
			})
		}
	})
}