!function(n){n.fn.cardtable=function(t){var r,u=this,i=n.extend({},{headIndex:0},t);return r=t&&t.headIndex?t.headIndex:0,u.each(function(){var t=n(this),e,u,s,o,h,r,c,f;t.hasClass("stacktable")||(e=n(this).prop("class"),u=n("<div><\/div>"),"undefined"!=typeof i.myClass&&u.addClass(i.myClass),f="",t.addClass("stacktable large-only"),s=t.find("caption").clone(),o=t.find("tr").eq(0),t.siblings().filter(".small-only").remove(),t.find("tbody tr").each(function(){h="";r="";c=n(this).prop("class");n(this).find("td,th").each(function(t){""!==n(this).html()&&(r+='<tr class="'+c+'">',r+=o.find("td,th").eq(t).html()?'<td class="st-key">'+o.find("td,th").eq(t).html()+"<\/td>":'<td class="st-key"><\/td>',r+='<td class="st-val '+n(this).prop("class")+'">'+n(this).html()+"<\/td>",r+="<\/tr>")});f+='<table class=" '+e+' stacktable small-only"><tbody>'+h+r+"<\/tbody><\/table>"}),t.find("tfoot tr td").each(function(t,i){""!==n.trim(n(i).text())&&(f+='<table class="'+e+' stacktable small-only"><tbody><tr><td>'+n(i).html()+"<\/td><\/tr><\/tbody><\/table>")}),u.prepend(s),u.append(n(f)),t.before(u))})};n.fn.stacktable=function(t){var i,u=this,r=n.extend({},{headIndex:0},t);return i=t&&t.headIndex?t.headIndex:0,u.each(function(){var l=n(this).prop("class"),f=n('<table class="'+l+' stacktable small-only"><tbody><\/tbody><\/table>'),t,c,s,h,u,e,o;"undefined"!=typeof r.myClass&&f.addClass(r.myClass);o="";t=n(this);t.addClass("stacktable large-only");c=t.find("caption").clone();s=t.find("tr").eq(0);t.find("tr").each(function(t){h="";u="";e=n(this).prop("class");0===t?o+='<tr class=" '+e+' "><th class="st-head-row st-head-row-main" colspan="2">'+n(this).find("th,td").eq(i).html()+"<\/th><\/tr>":(n(this).find("td,th").each(function(t){t===i?h='<tr class="'+e+'"><th class="st-head-row" colspan="2">'+n(this).html()+"<\/th><\/tr>":""!==n(this).html()&&(u+='<tr class="'+e+'">',u+=s.find("td,th").eq(t).html()?'<td class="st-key">'+s.find("td,th").eq(t).html()+"<\/td>":'<td class="st-key"><\/td>',u+='<td class="st-val '+n(this).prop("class")+'">'+n(this).html()+"<\/td>",u+="<\/tr>")}),o+=h+u)});f.prepend(c);f.append(n(o));t.before(f)})};n.fn.stackcolumns=function(t){var r=this,i=n.extend({},{},t);return r.each(function(){var r=n(this),e=r.find("tr").eq(0).find("td,th").length,u,f,t;if(!(3>e)){for(u=n('<table class="stacktable small-only"><\/table>'),"undefined"!=typeof i.myClass&&u.addClass(i.myClass),r.addClass("stacktable large-only"),f=n("<tbody><\/tbody>"),t=1;e>t;)r.find("tr").each(function(i){var e=n("<tr><\/tr>"),o,u,r,s;0===i&&e.addClass("st-head-row st-head-row-main");o=n(this).find("td,th").eq(0).clone().addClass("st-key");u=t;n(this).find("*[colspan]").length&&(r=0,n(this).find("td,th").each(function(){var i=n(this).attr("colspan");return i?(i=parseInt(i,10),u-=i-1,r+i>t&&(u+=r+i-t-1),r+=i):r++,r>t?!1:void 0}));s=n(this).find("td,th").eq(u).clone().addClass("st-val").removeAttr("colspan");e.append(o,s);f.append(e)}),++t;u.append(n(f));r.before(u)}})}}(jQuery)