jQuery.fn.table2CSV=function(l){var l=jQuery.extend({separator:",",header:[],delivery:"popup"},l);var j=[];var a=[];var d=this;var e=l.header.length;var k=[];if(e>0){for(var h=0;h<e;h++){k[k.length]=c(l.header[h])}}else{$(d).filter(":visible").find("th").each(function(){if($(this).css("display")!="none"){k[k.length]=c($(this).html())}})}g(k);$(d).find("tr").each(function(){var i=[];$(this).filter(":visible").find("td").each(function(){if($(this).css("display")!="none"){i[i.length]=c($(this).html())}});g(i)});if(l.delivery=="popup"){var f=j.join("\n");return b(f)}else{var f=j.join("\n");return f}function g(i){var n=i.join("");if(i.length>0&&n!=""){var m=i.join(l.separator);j[j.length]=m}}function c(m){var n=new RegExp(/["]/g);var i=m.replace(n,"â€œ");var n=new RegExp(/\<[^\<]+\>/g);var i=i.replace(n,"");if(i==""){return""}return'"'+i+'"'}function b(i){var m=window.open("","csv","height=400,width=600");m.document.write("<html><head><title>CSV</title>");m.document.write("</head><body >");m.document.write('<textArea cols=70 rows=15 wrap="off" >');m.document.write(i);m.document.write("</textArea>");m.document.write("</body></html>");m.document.close();return true}};
