   (function($){  
    $.fn.truncate = function(options) {  
          
     
      var defaults = {  
       length: 60,  
      minTrail: 40,  
      moreText: "more",  
     lessText: "less",  
      ellipsisText: "..."  
     };  
      
     var options = $.extend(defaults, options);  
     
     return this.each(function() {  
      obj = $(this);  
     var body = obj.html();  
      var space = " "; 
      
      if(body.length > options.length + options.minTrail) {  
      var splitLocation = body.indexOf(space, options.length);  
       if(splitLocation != -1) {  
        // truncate tip 
       
       var splitLocation = body.indexOf(space, options.length);  
        var str1 = body.substring(0, splitLocation);  
        
      var str2 = body.substring(splitLocation, body.length);
     
        
        obj.html('<span style="font-family:font-family: tahoma, arial, sans-serif; color:black;">' + str1 + '</span>' + '<span class="truncate_ellipsis">' + options.ellipsisText +   
        '</span>' + '<font  class="truncate_more" style="font-family:font-family: tahoma, arial, sans-serif;">' + str2 + '</font>');  
         obj.find('.truncate_more').css("display", "none");  
         
        // insert more link  
        obj.append(  
      '<div class="clearboth" style="display:block;">' +  
          '<a href="#" class="truncate_more_link" style="color:blue;"><font style="color:blue;">' +  options.moreText + '</font></a>' +
     '</div>'  
       );  
    
        // set onclick event for more/less link  
       var moreLink = $('.truncate_more_link', obj);  
      var moreContent = $('.truncate_more', obj);  
       var ellipsis = $('.truncate_ellipsis', obj);  
       moreLink.click(function() {  
        if(moreLink.text() == options.moreText) {  
         moreContent.show('normal');  
          moreLink.text(options.lessText);  
         ellipsis.css("display", "none");  
       } else {  
          moreContent.hide('normal');  
       moreLink.text(options.moreText);  
          ellipsis.css("display", "inline");  
         }  
         return false;  
         });  
       }  
      } // end if  
        
     });  
  };  
   })(jQuery);  