// JavaScript Document
(function($){
$.fn.extend({
  scrollableTable: function(opts){
    var defaults = {
      cloneClass:"cloned",
      type:"thead",
	  show:"no",
    }, o = $.extend({}, defaults, opts);

    return this.each(function(){
      var $this = $(this), $clone = $this.clone();
      if (o.type === "thead")
        $this.find(o.type).remove();
      else if(o.type === "th")
        $this.find(o.type).parent("tr").remove();
      $this.find("tr:first td").each(function(i){
          var w = $(this).width();
          $clone.find("tr:first th").each(function(j){
            if (i === j){
              $(this).width(w);
            }
          });
        });
      var width = $this.width();
	  if(o.show === "yes")
	    $clone.addClass(o.cloneClass).width("100%")
        .find("tr:not(:first)").remove().end()
		.insertBefore($this.parent());
	  else 
	    $clone.addClass(o.cloneClass).width("100%")
        .find("tr:not(:first)").remove().end();
    });
  }
});
})(jQuery);