var TB_version="2.4.2",TB_minTweetID,TB_maxTweetID,TB_tweetsShown=0,TB_rateLimitData,TB_mode="widget",TB_tmp,TB_started=false,TB_monthNumber={Jan:1,Feb:2,Mar:3,Apr:4,May:5,Jun:6,Jul:7,Aug:8,Sep:9,Oct:10,Nov:11,Dec:12},TB_timePeriods=new Array("second","minute","hour","day","week","month","year","decade"),TB_timePeriodLengths=new Array("60","60","24","7","4.35","12","10"),TB_urlCounter=0,TB_urlsToExpand=new Array(),TB_expandedUrls=new Object,TB_shortUrlIds=new Object,jQnc=jQuery.noConflict();function TB_init(){if(TB_started){return}else{TB_started=true}if(jQuery("#tweetblender").hasClass("archive")){TB_mode="archive"}jQuery.ajax({dataType:"jsonp",url:"http://tweet-blender.com/check_optout.php",data:({u:window.location.href,s:TB_config.general_source_ids,r:TB_config.widget_refresh_rate,v:"wp_"+TB_version}),success:function(a){if(a.ERROR){TB_hide_link()}else{if(a.chk>0){TB_hide_link()}else{TB_show_link()}}},error:TB_hide_link});if(typeof(jQuery("body").simpletip)=="undefined"&&typeof(jQnc("body").simpletip)=="function"){jQuery.prototype.simpletip=jQnc.prototype.simpletip}if(typeof(jQuery.toJSON)=="undefined"&&typeof(jQnc.toJSON)=="function"){jQuery.toJSON=jQnc.toJSON}if(typeof(TB_config)!="undefined"){if(typeof(TB_config.general_source_ids)=="undefined"||TB_config.general_source_ids==""){TB_showMessage("nosrc","Twitter sources to blend are not defined",true);jQuery("#refreshlink").remove()}else{if(TB_config.advanced_reroute_on){TB_config.rate_limit_url={url:TB_pluginPath+"/ws.php?action=rate_limit_status",dtype:"json"}}else{TB_config.rate_limit_url={url:"http://twitter.com/account/rate_limit_status.json",dtype:"jsonp"}}TB_initInfoBox();TB_makeAjaxURLs();TB_showLoader();TB_blend()}}else{TB_showMessage("noconf","Cannot retrieve TweetBlender configuration options",true);jQuery("#refreshlink").remove()}}function TB_hide_link(){jQuery("#infolink").remove();jQuery("#tb_tools").css("background-image","url("+TB_pluginPath+"/img/bg_sm.png)").width(28)}function TB_show_link(){jQuery("#infolink").css("background-image","url("+TB_pluginPath+"/img/info-kino.png)");jQuery("#tb_tools").css("background-image","url("+TB_pluginPath+"/img/bg.png)")}function TB_makeAjaxURLs(){TB_config.ajaxURLs=new Array();var a=new Array();jQuery.each(TB_config.general_source_ids.split(","),function(b,c){if(c.charAt(0)=="!"){TB_config.ajaxURLs.push({url:TB_pluginPath+"/ws.php?action=user_timeline&screen_name="+c.substr(2)+"&private=1&count="+TB_config[TB_mode+"_tweets_num"],source:c.substr(2),privateSrc:1,dtype:"json"})}else{if(c.charAt(0)=="@"&&c.indexOf("/")==-1){if(TB_config.advanced_reroute_on||TB_config.reached_api_limit){TB_config.ajaxURLs.push({url:TB_pluginPath+"/ws.php?action=user_timeline&screen_name="+c.substr(1)+"&count="+TB_config[TB_mode+"_tweets_num"],source:c.substr(1),privateSrc:0,dtype:"json"})}else{TB_config.ajaxURLs.push({url:"http://twitter.com/statuses/user_timeline.json?screen_name="+c.substr(1)+"&count="+TB_config[TB_mode+"_tweets_num"],source:c.substr(1),"private":0,dtype:"jsonp"})}}else{if(c.charAt(0)=="@"&&c.indexOf("/")>1){if(TB_config.advanced_reroute_on||TB_config.reached_api_limit){TB_config.ajaxURLs.push({url:TB_pluginPath+"/ws.php?action=list_timeline&user="+c.substr(1,c.indexOf("/")-1)+"&list="+c.substr(c.indexOf("/")+1)+"&count="+TB_config[TB_mode+"_tweets_num"],source:c.substr(1,c.indexOf("/")-1)+"::"+c.substr(c.indexOf("/")+1),privateSrc:0,dtype:"jsonp"})}else{TB_config.ajaxURLs.push({url:"http://api.twitter.com/1/"+c.substr(1,c.indexOf("/")-1)+"/lists/"+c.substr(c.indexOf("/")+1)+"/statuses.json?count="+TB_config[TB_mode+"_tweets_num"],source:c.substr(1,c.indexOf("/")-1)+"::"+c.substr(c.indexOf("/")+1),privateSrc:0,dtype:"jsonp"})}}else{if(escape(a.join(" ")).length+c.length>140){TB_addSearchUrl(a);a=new Array();a.push(c)}else{a.push(c)}}}}});if(a.length>0){TB_addSearchUrl(a)}}function TB_addSearchUrl(b){var a="";if(typeof(TB_config.filter_lang)!="undefined"&&TB_config.filter_lang.length==2){a="&lang="+TB_config.filter_lang}if(TB_config.advanced_reroute_on||TB_config.reached_api_limit){TB_config.ajaxURLs.push({url:TB_pluginPath+"/ws.php?action=search&q=&ors="+escape(b.join(" "))+"&rpp="+TB_config[TB_mode+"_tweets_num"]+"&page=1"+a,source:"search",privateSrc:0,dtype:"json"})}else{TB_config.ajaxURLs.push({url:"http://search.twitter.com/search.json?q=&ors="+escape(b.join(" "))+"&rpp="+TB_config[TB_mode+"_tweets_num"]+"&page=1"+a,source:"search",privateSrc:0,dtype:"jsonp"})}}function TB_initInfoBox(){TB_config.sourcesHTML="";TB_config.sourcesCount=0;jQuery.each(TB_config.general_source_ids.split(","),function(a,b){if(b.charAt(0)=="!"){b=b.substr(1)}TB_config.sourcesHTML+='<a target="_blank" href="';if(b.charAt(0)=="@"){TB_config.sourcesHTML+="http://twitter.com/"+b.substr(1)}else{TB_config.sourcesHTML+="http://search.twitter.com/search?q="+escape(b)}TB_config.sourcesHTML+='">'+b+"</a> ";TB_config.sourcesCount++});jQuery("#twitterlogo").click(function(){TB_showMessage("info","Powered by TweetBlender plugin v"+TB_version+" blending "+TB_config.sourcesHTML,false)});if(parseInt(TB_config.widget_refresh_rate)>0){setInterval("TB_showLoader();TB_blend();",parseInt(TB_config.widget_refresh_rate)*1000)}}function TB_blend(){if(!TB_config.advanced_reroute_on&&!TB_config.reached_api_limit){jQuery.ajax({url:TB_config.rate_limit_url.url,dataType:TB_config.rate_limit_url.dtype,success:function(c){if(c.error||c.remaining_hits<TB_config.ajaxURLs.length){TB_config.reached_api_limit=true;if(!TB_config.advanced_disable_cache){var d=parseInt(TB_config.widget_refresh_rate)*1000*5,b=new Date(),a;if(c.reset_time){a=TB_str2date(c.reset_time);d=Math.round(a.getTime()-b.getTime())}setTimeout("TB_config.reached_api_limit=false;TB_makeAjaxURLs();TB_blend();",d);TB_makeAjaxURLs();TB_getTweets()}else{if(TB_config.advanced_show_limit_msg){TB_showMessage("limit","You reached Twitter API connection limit. Next reset "+TB_verbalTime(TB_str2date(c.reset_time)),false)}}}else{TB_getTweets()}},error:function(){TB_getTweets()}})}else{TB_getTweets()}}function TB_checkComplete(){if(TB_config.urlsDone==TB_config.ajaxURLs.length){if(jQuery("#tweetlist").children("li").size()==0){TB_showMessage("notweets","No tweets found for "+TB_config.sourcesHTML,true)}else{TB_hideMessage("notweets")}}}function TB_getTweets(){TB_config.urlsDone=0;jQuery("#tb_loading").html("Loading...");jQuery.each(TB_config.ajaxURLs,function(b,a){TB_getFreshTweets(a)})}function TB_getFreshTweets(a){jQuery.ajax({dataType:a.dtype,url:a.url,success:function(b){if(b.error){if(b.error.indexOf("Rate limit exceeded")==0){TB_config.reached_api_limit=true}TB_config.urlsDone++;TB_checkComplete()}else{if(a.dtype=="jsonp"&&!TB_config.disable_cache){TB_cacheData(a,b)}TB_addTweets(b)}},error:function(){TB_config.urlsDone++;TB_checkComplete()}})}function TB_showFullUrl(b,a){if(a==""){return}if(jQuery("#tb_url_"+b+"e").length>0){return}var c=jQuery("#tb_url_"+b);switch(TB_config.general_tiny_urls){case"showicon":c.after('<span><img class="urlexpand" src="'+TB_pluginPath+'/img/urlexpand-icon.png" alt="'+a+'"></span>');TB_addTooltip(c.next());break;case"showhint":c.attr("title",a);break;case"replace":c.html(a);break}jQuery("#tb_url_"+b).attr("id","tb_url_"+b+"e")}function TB_expandUrls(){while(shortUrl=TB_urlsToExpand.shift()){jQuery.ajax({dataType:"jsonp",url:"http://urlexpand.com/json",data:{u:shortUrl,k:"853548444daf0029003a5211c313e924"},success:function(a){if(a.e){TB_expandedUrls[a.u]=a.e;TB_showFullUrl(TB_shortUrlIds[a.u],a.e)}else{return false}},error:function(){return false}})}}function TB_cacheData(a,b){if(b.error){return}jQuery.ajax({url:TB_pluginPath+"/ws.php?action=cache_data",type:"POST",dataType:"json",data:({source:a.source,data:jQuery.toJSON(b),"private":a.privateSrc})})}function TB_addTweets(a){TB_showTweetList();var b=a;if(typeof(a.results)!="undefined"){b=a.results}jQuery.each(b,function(d,e){if(TB_config.filter_hide_replies&&e.in_reply_to_user_id){return true}if(jQuery("#"+e.id).length>0){return true}else{if(TB_tweetsShown==0){TB_tweetsShown++;TB_minTweetID=e.id;TB_maxTweetID=e.id;jQuery("#tweetlist").append(TB_makeHTML(e))}else{if(TB_minTweetID>0&&e.id<TB_minTweetID){if(TB_tweetsShown>=TB_config[TB_mode+"_tweets_num"]){return false}else{TB_tweetsShown++;jQuery("#tweetlist").append(TB_makeHTML(e));TB_minTweetID=e.id}}else{if(TB_maxTweetID>0&&e.id>TB_maxTweetID){TB_enforceLimit();jQuery("#tweetlist").prepend(TB_makeHTML(e));TB_tweetsShown++;TB_maxTweetID=e.id}else{TB_enforceLimit();var c=TB_maxTweetID;jQuery("#tweetlist li").each(function(f,g){if(e.id<c&&e.id>g.id){jQuery("#"+c).after(TB_makeHTML(e));TB_tweetsShown++;return false}c=g.id});if(jQuery("#"+e.id).length<=0){jQuery("#"+TB_minTweetID).after(TB_makeHTML(e));TB_minTweetID=e.id;TB_tweetsShown++}}}}}if(TB_config[TB_mode+"_show_reply_link"]||TB_config[TB_mode+"_show_follow_link"]){jQuery("#"+e.id).hover(function(){jQuery(this).find("div:last").slideDown()},function(){jQuery(this).find("div:last").slideUp()})}});if(b.length>0&&TB_mode!="archive"&&TB_config.archive_is_disabled==""){jQuery("#archivelink").show()}TB_config.urlsDone++;TB_checkComplete();TB_expandUrls();TB_addTooltips()}function TB_enforceLimit(){if(TB_tweetsShown==TB_config[TB_mode+"_tweets_num"]){var a=jQuery("#"+TB_minTweetID),b=a.prev("li");a.remove();TB_tweetsShown--;TB_minTweetID=parseInt(b.attr("id"))}}function TB_makeHTML(d){var c="",a,b;if(typeof(d.user)=="undefined"){if(d.from_user){d.user={screen_name:d.from_user}}else{d.user={screen_name:""}}}c+='<li id="'+d.id+'">';if(TB_config[TB_mode+"_show_photos"]){if(!d.user.profile_image_url&&d.profile_image_url){d.user.profile_image_url=d.profile_image_url}c+='<a class="tb_photo" rel="nofollow" href="http://twitter.com/'+d.user.screen_name+'" target="_blank">';c+='<img src="'+d.user.profile_image_url+'" alt="'+d.user.screen_name+'"/>';c+="</a>"}c+='<span class="tb_author"><a rel="nofollow" href="http://twitter.com/'+d.user.screen_name+'" target="_blank">'+d.user.screen_name+"</a>: </span> ";if(TB_config.general_tiny_urls!="keep"){if(b=d.text.match(/http\:\/\/[a-z0-9]{2,6}\.[a-z]+\/[a-z0-9]+/gi)){jQuery.each(b,function(f,e){e=jQuery.trim(e);if(TB_expandedUrls[e]){fullUrl=TB_expandedUrls[e];switch(TB_config.general_tiny_urls){case"showicon":d.text=d.text.replace(e,'<a rel="nofollow" href="'+e+'" target="_blank">'+e+'</a><span><img class="expandicon" src="'+TB_pluginPath+'/img/urlexpand-icon.png" alt="'+fullUrl+'"></span>');break;case"showhint":d.text=d.text.replace(e,'<a rel="nofollow" href="'+e+'" target="_blank" title="['+fullUrl+'] by URLexpand.com">'+e+"</a>");break;case"replace":d.text=d.text.replace(e,'<a rel="nofollow" href="'+e+'" target="_blank">'+fullUrl+"</a>")}}else{TB_urlsToExpand.push(e);TB_shortUrlIds[e]=TB_urlCounter;d.text=d.text.replace(e,'<a rel="nofollow" id="tb_url_'+TB_urlCounter+'" href="'+e+'" target="_blank">'+e+"</a>");TB_urlCounter++}})}else{d.text=d.text.replace(/(https?:\/\/\S+)/gi,'<a rel="nofollow" href="$1" target="_blank">$1</a>')}}else{if(TB_config.general_link_urls){d.text=d.text.replace(/(https?:\/\/\S+)/gi,'<a rel="nofollow" href="$1" target="_blank">$1</a>')}}if(TB_config.general_link_screen_names){d.text=d.text.replace(/\@([^\s\.\:]+)/gi,'<a rel="nofollow" href="http://twitter.com/$1" target="_blank">@$1</a>')}if(TB_config.general_link_hash_tags){d.text=d.text.replace(/\#([^\s\,]+)/gi,'<a rel="nofollow" href="http://search.twitter.com/search?q=%23$1" target="_blank">#$1</a>')}c+='<span class="tb_msg">'+d.text+"</span><br/>";c+=' <span class="tb_tweetinfo">';c+='<a rel="nofollow" href="http://twitter.com/'+d.user.screen_name+"/statuses/"+d.id+'">';a=TB_str2date(d.created_at);if(TB_config.general_timestamp_format){if(typeof(jQuery.PHPDate)!="undefined"){c+=jQuery.PHPDate(TB_config.general_timestamp_format,a)}else{if(typeof(jQnc.PHPDate)!="undefined"){c+=jQnc.PHPDate(TB_config.general_timestamp_format,a)}}}else{c+=TB_verbalTime(a)}c+="</a>";if(TB_config[TB_mode+"_show_source"]&&d.source){c+=" from ";if(d.source.indexOf("&lt;")>=0){c+=jQuery("<textarea/>").html(d.source).val()}else{c+=d.source}}c+="</span>";c+='<div class="tweet-tools" style="display:none;"><a rel="nofollow" href="http://twitter.com/home?status=@'+d.user.screen_name+"%20&in_reply_to_status_id="+d.id+"&in_reply_to="+d.user.screen_name+'" target="_blank">reply<a/> | <a rel="nofollow" href="http://twitter.com/'+d.user.screen_name+'" target="_blank">follow '+d.user.screen_name+"</a></div>";c+="</li>\n";return c}function TB_addTooltips(){jQuery("img.urlexpand").each(function(){TB_addTooltip(jQuery(this).parent())})}function TB_addTooltip(a){a.simpletip({content:a.contents().attr("alt"),fixed:true,position:["-20","-16"]})}function TB_showLoader(){jQuery("#refreshlink img").attr("src",TB_pluginPath+"/img/ajax-refresh.gif");jQuery("#refreshlink").addClass("loading")}function TB_hideLoader(){jQuery("#tb_loading").hide();jQuery("#refreshlink img").attr("src",TB_pluginPath+"/img/ajax-refresh-icon.gif");jQuery("#refreshlink").removeClass("loading")}function TB_showTweetList(){TB_hideLoader();jQuery("#tweetlist").show()}function TB_showMessage(c,b,a){TB_hideLoader();if(!jQuery("#msg_"+c).length){jQuery("#tweetlist").before('<div id="msg_'+c+'" class="tb_msg" style="display:none;">'+b+"</div>");jQuery("#msg_"+c).slideDown();if(!a){setTimeout('TB_hideMessage("'+c+'")',8000)}}else{if(jQuery("#msg_"+c).is(":hidden")){jQuery("#msg_"+c).slideDown()}}}function TB_hideAllMessages(){jQuery("div.tb_msg").slideUp(1000,function(){jQuery("div.tb_msg").remove()})}function TB_hideMessage(a){jQuery("#msg_"+a).slideUp(1000,function(){jQuery("#msg_"+a).remove()})}function TB_str2date(c){var a=new Date(),b=c.split(/[\s\:]/);if(c.indexOf(",")>=0){a.setUTCFullYear(b[3],TB_monthNumber[""+b[2]]-1,b[1]);a.setUTCHours(b[4],b[5],b[6])}else{a.setUTCFullYear(b[7],TB_monthNumber[""+b[1]]-1,b[2]);a.setUTCHours(b[3],b[4],b[5])}return a}function TB_verbalTime(a){var c,b=new Date(),g,d,e="",f="";if(b.getTime()>a.getTime()){g=Math.round((b.getTime()-a.getTime())/1000);f=" ago"}else{g=Math.round((a.getTime()-b.getTime())/1000);e="in "}for(c=0;g>=TB_timePeriodLengths[c]&&c<TB_timePeriodLengths.length;c++){g=g/TB_timePeriodLengths[c]}g=Math.round(g);d=TB_timePeriods[c];if(g!=1){d+="s"}return e+g+" "+d+f}jQuery(document).ready(function(){TB_init()});TB_tmp=setTimeout("TB_init()",4000);