// Scrollable Tables for IE and Mozilla
// License: http://www.gnu.org/licenses/gpl.txt
// Compressed by: http://dean.edwards.name/packer/
(function($){$.fn.scrollable=function(options){var opts=$.extend({},$.fn.scrollable.defaults,options);return this.each(function(){var scrolTable=$(this);opts.tableWidth=opts.tableWidth?opts.tableWidth:scrolTable.width();opts.tableHeight=opts.tableHeight?opts.tableHeight:scrolTable.height();if(jQuery.browser.msie){var containerDiv=$("<div></div>");containerDiv.insertBefore(scrolTable);var tableFoot=scrolTable.find("tfoot");var tableHead=scrolTable.find("thead");if(tableHead){var headerTable=scrolTable.clone(true);headerTable.find("tbody").remove();headerTable.find("tfoot").remove();headerTable.css("margin","0px");headerTable.width(opts.tableWidth-opts.scrollWidth);scrolTable.find("thead").remove();containerDiv.append(headerTable)}var tableDiv=$("<div></div>");tableDiv.append(scrolTable);tableDiv.width(opts.tableWidth);tableDiv.css("overflow","auto");tableDiv.height(opts.tableHeight);scrolTable.css("margin","0px");scrolTable.width(opts.tableWidth-opts.scrollWidth);containerDiv.append(tableDiv);if(tableFoot){var footerTable=scrolTable.clone(true);footerTable.find("thead").remove();footerTable.find("tbody").remove();footerTable.css("margin","0px");footerTable.width(opts.tableWidth-opts.scrollWidth);scrolTable.find("tfoot").remove();containerDiv.append(footerTable)}$.scrollable.syncWidths(containerDiv,opts)}else if(jQuery.browser.mozilla){var theadHeight=scrolTable.find("thead").height()?scrolTable.find("thead").height():0;var tfootHeight=scrolTable.find("tfoot").height()?scrolTable.find("tfoot").height():0;var tbodyHeight=scrolTable.find("tbody").height();var calulatedHeight=opts.tableHeight-(theadHeight+tfootHeight);if(tbodyHeight>=calulatedHeight){scrolTable.find("tbody").css("overflow","-moz-scrollbars-vertical")}else{scrolTable.find("tbody").css("overflow","-moz-scrollbars-none")}var cellSpacing=(scrolTable.attr("offsetHeight")-(tbodyHeight+theadHeight+tfootHeight))/4;var tBodyHeight=(opts.tableHeight-(theadHeight+cellSpacing*2)-(tfootHeight+cellSpacing*2));var tBodyWidth=opts.tableWidth;scrolTable.css("width",opts.tableWidth+'px');scrolTable.find("tbody").css("height",tBodyHeight+'px');scrolTable.find("tbody").css("width",tBodyWidth+'px')}})};$.scrollable={syncWidths:function(container,opts){if(jQuery.browser.msie){var thead=container.find("thead");var tbody=container.find("tbody");var tfoot=container.find("tfoot");var synchList=container.find(opts.synchWidthsWith+" tr:first td");if(opts.synchWidthsWith!="tbody"){synchList=container.find(opts.synchWidthsWith+" tr:first th")}if(synchList.size()>0){$.each(tbody.find("tr"),function(i,tr){$.each($(tr).find("td"),function(i,td){var column=$(synchList[i]);$(td).width(column.width());$(td).removeAttr("width")})});if(thead){var theadColumns=thead.find("tr:first th");$.each(theadColumns,function(i,th){$(th).css("wordBreak","break-all");$(th).removeAttr("width");$(th).css("width","")});$.each(tbody.find("tr:first td"),function(i,td){$(theadColumns[i]).width($(td).width())})}if(tfoot){var tfootColumns=tfoot.find("tr:first th");$.each(tfootColumns,function(i,th){$(th).css("wordBreak","break-all");$(th).removeAttr("width");$(th).css("width","")});$.each(tbody.find("tr:first td"),function(i,td){$(tfootColumns[i]).width($(td).width())})}}}}};$.fn.scrollable.defaults={synchWidthsWith:"tbody",scrollWidth:17}})(jQuery);