/*!
 * jQCloud Plugin for jQuery
 *
 * Version 0.2.1
 *
 * Copyright 2011, Luca Ongaro
 * Licensed under the MIT license.
 *
 * Date: Tue Jul 26 20:02:40 +0200 2011
 */
(function(a){a.fn.jQCloud=function(b,c){var d=this,e=d.attr("id"),f={width:d.width(),height:d.height(),center:{x:d.width()/2,y:d.height()/2},delayed_mode:b.length>50};typeof c=="function"&&(c={callback:c}),c=a.extend(f,c||{}),d.addClass("jqcloud");var g=function(){var f=function(a,b){var c=function(a,b){if(Math.abs(2*a.offsetLeft+a.offsetWidth-2*b.offsetLeft-b.offsetWidth)<a.offsetWidth+b.offsetWidth&&Math.abs(2*a.offsetTop+a.offsetHeight-2*b.offsetTop-b.offsetHeight)<a.offsetHeight+b.offsetHeight)return!0;return!1},d=0;for(d=0;d<b.length;d++)if(c(a,b[d]))return!0;return!1};for(i=0;i<b.length;i++)b[i].weight=parseFloat(b[i].weight,10);b.sort(function(a,b){return a.weight<b.weight?1:a.weight>b.weight?-1:0});var g=2,h=[],j=c.width/c.height,k=function(i,k){var l=e+"_word_"+i,m="#"+l,n=6.28*Math.random(),o=0,p=Math.round((k.weight-b[b.length-1].weight)/(b[0].weight-b[b.length-1].weight)*9)+1,q=k.url!==undefined?"<a href='"+encodeURI(k.url).replace(/'/g,"%27")+"'>"+k.text+"</a>":k.text;d.append("<span id='"+l+"' class='w"+p+"' title='"+(k.title||"")+"'>"+q+"</span>");var r=a(m,d),s=r.width(),t=r.height(),u=c.center.x-s/2,v=c.center.y-t/2,w=r[0].style;w.position="absolute",w.left=u+"px",w.top=v+"px";while(f(document.getElementById(l),h))o+=g,n+=(i%2===0?1:-1)*g,u=c.center.x-s/2+o*Math.cos(n)*j,v=c.center.y+o*Math.sin(n)-t/2,w.left=u+"px",w.top=v+"px";h.push(document.getElementById(l))},l=function(a){a=a||0,a<b.length?(k(a,b[a]),setTimeout(function(){l(a+1)},10)):typeof c.callback=="function"&&c.callback.call(this)};c.delayed_mode?l():(a.each(b,k),typeof c.callback=="function"&&c.callback.call(this))};setTimeout(function(){g()},10);return this}})(jQuery)
