/* Copyright © 2010, Jacob Blommestein
All rights reserved. This file may not be redistributed or used in whole or significant part without express written 
permission. */
String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};jQuery.fn.reverse=Array.prototype.reverse;function init(){var b=(window.recycle)?100:30;var a="http://search.twitter.com/search.json?lang=en&q="+window.phrase+"+filter:links&rpp="+b+"&callback=?";$.getJSON(a,function(c){if(c.results==undefined||c.results.length==0){window.IDdataflow.prepend('<li id="flowErr">Could not retrieve results. Either there is no realtime data for "'+window.phrase+'" or the data flow may be temporarily down.</li>');window.IDflowErr.hide();window.IDflowErr.fadeIn(1000);setTimeout(function(){window.IDflowAd1.fadeIn(1000)},1000);setTimeout(function(){window.IDflowAd2.fadeIn(1000)},2000);setTimeout(function(){window.IDflowAd3.fadeIn(1000)},3000);return}$(c.results).each(function(){window.flowstack.push(this)});window.newestID=window.flowstack[0].id;window.oldestID=window.flowstack[window.flowstack.length-1].id;showMessage();clearTimeout(window.fetchtimer);window.fetchtimer=setTimeout("fetch()",25000)})}function fetch(b){clearTimeout(window.fetchtimer);if(window.flowstack.length>=45){window.fetchtimer=setTimeout("fetch()",45000);return}var c=0;var a="http://search.twitter.com/search.json?lang=en&q="+window.phrase+"+filter:links&rpp=100&since_id="+window.newestID+"&callback=?";$.getJSON(a,function(d){c=d.results.length;if(c>0){$(d.results).each(function(){window.flowstack.unshift(this)});window.newestID=window.flowstack[0].id}if(window.flowstack.length<15&&c<20){c=20-c;a="http://search.twitter.com/search.json?lang=en&q="+window.phrase+"+filter:links&rpp="+c+"&max_id="+window.oldestID+"&callback=?";$.getJSON(a,function(e){if(e.results.length>0){$(e.results).each(function(){window.flowstack.push(this)});window.oldestID=window.flowstack[window.flowstack.length-1].id}})}window.fetchtimer=setTimeout("fetch()",25000)})}function showMessage(){if(!window.paused){if(window.flowstack.length>0){var a=window.flowstack.shift();if(a){addMessage(a)}}else{window.recycle=true;init();return}}clearTimeout(window.flowtimer);window.flowtimer=setTimeout("showMessage()",window.displaySpeed)}function addMessage(c){if(window.recycle||$("#dataflow #message"+c.id).length==0){var e=c.text;var d=0;while((d=e.indexOf("http://",d))!=-1){endLinkPos=e.indexOf(" ",d);if(endLinkPos==-1){endLinkPos=e.length}var b=e.substring(d,endLinkPos);e=e.replace(b,'<a href="'+b+'" target="_blank">[Visit Link]</a>');d=endLinkPos+43}var a='<li id="message'+c.id+'" class="message"><div class="profile" title=""><img class="profileimage" width="60" height="60" src="'+c.profile_image_url+'" ></div><div class="messagetext">'+e+'</div><div style="display:none">'+c.text+"</div></li>";window.IDdataflow.prepend(a);var f=$("#message"+c.id,window.IDdataflow);f.hide().fadeIn("slow");$("img.profile",f).hide().fadeIn(4000);window.IDdataflow.find("li:gt(20)").remove()}}function playToggle(){if(window.paused){window.IDpauseimg.attr("src","images/pausebutton.png").attr("alt","Pause Data Flow").attr("title","Pause Data Flow")}else{window.IDpauseimg.attr("src","images/playbutton.png").attr("alt","Resume Data Flow").attr("title","Resume Data Flow")}window.paused=!window.paused}function slower(){switch(window.displaySpeed){case 2000:window.displaySpeed+=1000;window.IDfastimg.attr("src","images/fastbutton.png");break;case 3000:window.displaySpeed+=1000;break;case 4000:window.displaySpeed+=1000;window.IDslowimg.attr("src","images/slowdisabled.png");break}}function faster(){switch(window.displaySpeed){case 3000:window.displaySpeed-=1000;window.IDfastimg.attr("src","images/fastdisabled.png");break;case 4000:window.displaySpeed-=1000;break;case 5000:window.displaySpeed-=1000;window.IDslowimg.attr("src","images/slowbutton.png");break}}$(document).ready(function(){window.phrase=decodeURI(window.location.pathname.substring(1)).trim().toLowerCase().replace(/_/g," ");var c=false;var a=new Array("porn","poker","casino","gambling","crack","warez","keygen","fuck","pussy","vagina","sex","hack","drug");for(var b=0;b<a.length;b++){if(phrase.indexOf(a[b])!=-1){c=true;break}}window.IDdataflow=$("#dataflow");window.IDflowErr=$("#flowErr");window.IDflowAd1=$("#flowAd1");window.IDflowAd2=$("#flowAd2");window.IDflowAd3=$("#flowAd3");window.IDpause=$("#pause");window.IDslow=$("#slow");window.IDfast=$("#fast");window.IDpauseimg=$("img",window.IDpause);window.IDslowimg=$("img",window.IDslow);window.IDfastimg=$("img",window.IDfast);if(c){window.IDdataflow.prepend('<li id="flowErr">Did not retrieve results as your query could potentially link to content that violates our advertiser\'s terms.</li>');var d=window.IDflowErr;d.hide();d.fadeIn(1000);setTimeout(function(){window.IDflowAd1.fadeIn(1000)},1000);setTimeout(function(){window.IDflowAd2.fadeIn(1000)},2000);setTimeout(function(){window.IDflowAd3.fadeIn(1000)},3000);return}else{window.flowstack=[];window.newestID;window.oldestID;window.displaySpeed=3000;window.paused=false;window.IDpause.click(playToggle);window.IDslow.click(slower);window.IDfast.click(faster);init()}});