var TagCloud={Version:"1.1.2a",create:function(){return new TagCloud.Container()}};TagCloud.Tag=function(b,c,a,d,e){this.name=b;this.id=e;this.count=c;this.url=a;this.epoch=d;this.element=document.createElement("li");this.linkElement=document.createElement("a");this.style={};this.initClasses();this.initAnchorClasses()};TagCloud.Tag.prototype.initClasses=function(){this.classes=["tagcloud-base"]};TagCloud.Tag.prototype.initAnchorClasses=function(){this.anchorClasses=["tagcloud-anchor","toggleOff"]};TagCloud.Tag.prototype.attachClass=function(a){this.classes.push(a)};TagCloud.Tag.prototype.attachAnchorClass=function(a){this.anchorClasses.push(a)};TagCloud.Tag.prototype.toElement=function(){var b=this.element;var a=this.linkElement;a.setAttribute("href",this.url);var c=document.createTextNode(this.name);a.appendChild(c);a.className=this.anchorClasses.join(" ");b.appendChild(a);b.className=this.classes.join(" ");for(var d in this.style){b.style[d]=this.style[d]}return b};TagCloud.Container=function(){this.reset();this.classes={list:"tagcloud-list"}};TagCloud.Container.prototype.reset=function(){this.tags=new Array();this.effectors=new Array()};TagCloud.Container.prototype.clear=function(){this.tags=new Array()};TagCloud.Container.prototype.add=function(c,d,b,e,f){if(d==0){throw"TagCloud.Container.prototype.add: second argument should be over 0."}var a=this.createTag(c,d,b,e,f);this.tags.push(a);return a};TagCloud.Container.prototype.createTag=function(b,c,a,d,e){return new TagCloud.Tag(b,c,a,d,e)};TagCloud.Container.prototype.toElement=function(b){var d=document.createElement("ul");for(var c=0;c<this.tags.length;c++){var a=this.tags[c];if(!(b&&!b(a))){d.appendChild(a.toElement());d.appendChild(document.createTextNode("\n"))}}d.className=this.classes.list;return d};TagCloud.Container.prototype.setElementsTo=function(a){var b=document.getElementById(a);if(!b){alert("Could not find target: "+a)}while(b.childNodes.length>0){b.removeChild(b.firstChild)}b.appendChild(this.toElement())};TagCloud.Container.prototype.searchAndDisplay=function(b,a){var d=document.getElementById(b);while(d.childNodes.length>0){d.removeChild(d.firstChild)}var c=new RegExp(a,"i");d.appendChild(this.toElement(function(e){return e.name.match(c)}))};TagCloud.Container.prototype.toHTML=function(){var a=document.createElement("div");a.appendChild(this.toElement());return a.innerHTML};TagCloud.Container.prototype.generateHTML=function(){this.runEffectors();return this.toHTML()};TagCloud.Container.prototype.setup=function(a){this.runEffectors();this.setElementsTo(a)};TagCloud.Container.prototype.runEffectors=function(){for(var b=0;b<this.effectors.length;b++){var a=this.effectors[b];a.affect(this.tags)}};TagCloud.Container.prototype.loadEffector=function(d,b){var a=TagCloud.Effector[d];if(!a){throw"Unknown Effector, "+d}var c=new a(b);this.effectors.push(c);return c};TagCloud.Effector=new Object();TagCloud.Effector.CountSize=function(a){this.baseFontSize=24;this.fontSizeRange=12;this._suffix="px";this.suffixTypes=["px","pt","pc","in","mm","cm"];if(a){if(a.min){this.min=a.min}if(a.max){this.max=a.max}}};TagCloud.Effector.CountSize.prototype.base=function(a){this.baseFontSize=a;return this};TagCloud.Effector.CountSize.prototype.range=function(a){this.fontSizeRange=a;return this};TagCloud.Effector.CountSize.prototype.suffix=function(b){for(var a=0;a<this.suffixTypes.length;a++){if(this.suffixTypes[a]==b){this._suffix=b;break}}return this};TagCloud.Effector.CountSize.prototype.affect=function(n){var g=this.baseFontSize+this.fontSizeRange;var h=this.baseFontSize-this.fontSizeRange;if(h<0){h=0}var d=g-h;if(!(this.min||this.max)){var b=null;var f=null;for(var c=0;c<n.length;c++){var e=n[c].count;if(b==null||b>e){b=e}if(f==null||f<e){f=e}}this.min=b;this.max=f}var k=new TagCloud.Calculator(this.min,this.max,d);for(var a=0;a<n.length;a++){var m=n[a];var l=k.calculate(m.count);m.style.fontSize=String(l+h)+this._suffix}};TagCloud.Effector.DateTimeColor=function(){this.types=["earliest","earlier","later","latest"];this.styles={earliest:"tagcloud-earliest",earlier:"tagcloud-earlier",later:"tagcloud-later",latest:"tagcloud-latest"}};TagCloud.Effector.DateTimeColor.prototype.setClass=function(a){for(var b in a){this.styles[b]=a[b]}return this};TagCloud.Effector.DateTimeColor.prototype.affect=function(l){var e=null;var g=null;for(var f=0;f<l.length;f++){var c=l[f].epoch;if(e==null||e>c){e=c}if(g==null||g<c){g=c}}var h=new TagCloud.Calculator(e,g,3);for(var d=0;d<l.length;d++){var k=l[d];var b=h.calculate(k.epoch);var a=this.styles[this.types[b]];k.attachAnchorClass(a)}};TagCloud.Effector.HotWord=function(){this.hotWords=new Array();this.className="tagcloud-hotword"};TagCloud.Effector.HotWord.prototype.words=function(){for(var a=0;a<arguments.length;a++){this.hotWords.push(arguments[a])}return this};TagCloud.Effector.HotWord.prototype.setClass=function(a){this.className=a;return this};TagCloud.Effector.HotWord.prototype.affect=function(c){for(var d=0;d<c.length;d++){var a=c[d];for(var b=0;b<this.hotWords.length;b++){if(this.hotWords[b]==a.name){a.initAnchorClasses();a.attachAnchorClass(this.className);break}}}};TagCloud.Calculator=function(c,a,b){this.min=Math.log(c);this.max=Math.log(a);this.range=b;this.factor=null;this.initializeFactor()};TagCloud.Calculator.prototype.initializeFactor=function(){if(this.min==this.max){this.min-=this.range;this.factor=1}else{this.factor=this.range/(this.max-this.min)}};TagCloud.Calculator.prototype.calculate=function(a){return parseInt((Math.log(a)-this.min)*this.factor)};
