/**ellipsis plugin http://devongovett.wordpress.com/2009/04/06/text-overflow-ellipsis-for-firefox-via-jquery/ + comments + custom mods*/
$.fn.ellipsis=function(a,d,c,b){return $(this).each(function(){var f=$(this);if(f.css("overflow")=="hidden"){var v=f.html();var q=f.width();var g=f.height();var e;if(c){d=true;e=" <a class='MoreLessTag' href='#' >"+c+"</a>"}else{e=""}var l=$(this.cloneNode(true)).hide().css({position:"absolute",overflow:"visible","max-width":"none","max-height":"none"});if(a){l.css("height","auto").width(q)}else{l.css("width","auto")}f.after(l);var w=l.height();var n=(a)?g:q;var u=(a)?l.height():l.width();var i=false,j=false;if(u>n){var p=0;var r=v.length;while(p<=r){var o=(p+r)/2;var m=v.substr(0,o);l.html(m+"&hellip;"+e);u=(a)?l.height():l.width();if(u>n){if(j){i=true}r=o-1;if(p>r){o=(r+r-2)/2;m=v.substr(0,o);l.html(m+"&hellip;"+e);break}}else{if(u<n){p=o+1}else{if(i&&j&&((r-p)/r<0.2)){break}j=true;p=o+1}}}}f.html(l.html());l.remove();if(c){$(".MoreLessTag",this).click(function(t){t.preventDefault();f.html(v);f.animate({height:w});f.append(" <a class='MoreLessTag' href='#' >"+b+"</a>");$(".MoreLessTag",f).click(function(x){x.preventDefault();f.ellipsis(a,d,c,b)})})}else{var h=new RegExp(/<\/?[^>]+>/gi);f.attr("alt",v.replace(h,""));f.attr("title",v.replace(h,""))}if(d==true){var k=f.width();var s=f.height();f.one("resize",function(){if(f.width()!=k||(a&&f.height!=s)){f.html(v);f.ellipsis(a,d,c,b)}})}}})};