  function printIt(printThis, template)
  {
    win = window.open();
    self.focus();
    win.document.open();
    win.document.write(template.replace('{content}', printThis));
    win.document.close();
    win.print();
  }

  (function($){
	 	$.fn.extend({ 
	 		printable: function(options) {
	 			var defaults = {
	 				title : "Print This Table",
	 				template:   '<html>'+
					 				'<head>'+
					 					'<style>'+
					 	    				'body, td { font-family: Verdana; font-size: 10pt;}'+
					 	    			'</style>'+
					 	    		 '</head>'+
					 	    		 '<body>'+
					 	    		 	'{content}' +
					 	    		 '</body>'+
	 	    					'</html>'	 	    		
	 			};
	 			
	 			var o = $.extend({}, defaults, options);
	 			
	 			return this.each(function() {
	 				var $this = $(this); 	 
	 				var $link = $('<a href="#" class="print-this-link">'+ o.title + '</a>')
	 					.appendTo($this)
	 			
	 					.click(function(){
	 						var printedElement = $this.clone();
	 						printedElement.find(".print-this-link").remove();
	 						printIt(printedElement.html(), o.template);
	 					}).hover(
	 							function(){$(this).toggleClass("hover");}, 
	 							function(){$(this).toggleClass("hover");}
	 					);
	 			});
	    	}
		});
	})(jQuery);
