
     var t1,t2;

     var user1=new Array();
     var user2=new Array();
     var followers1;
     var followers2;

     $(document).ready(function() {
       $("#calcbutton").blur();

      $("#f1").focus(function() {
         $("#f1status").html("&nbsp;");
         t1=false;
      });
      $("#f2").focus(function() {
         $("#f2status").html("&nbsp;");
         t2=false;
      });

       $("#f1").blur(function() {
         name1=$("#f1").val();
         if(name1=="") return;
         url="getlist.php?name="+escape(name1);
         $("#f1status").html("Retrieving followers for "+escape(name1)+"... this might take a bit.. <img src=\"spinner.gif\">");
         $.getJSON(url,
          function (data1, textStatus) {
              if(data1[0]>0) {     
                $("#f1status").html(data1.length+" followers");
                user1=new Array();
                for(i=0;i<data1.length;i++) user1[data1[i]]=1;
                followers1=data1.length;
                t1=true;
              } else {
		 $("#f1status").html("Problem finding that user. Check or try again.");
              }
          });
       });

       $("#f2").blur(function() {
         name1=$("#f2").val();
         if(name1=="") return;
         url="getlist.php?name="+escape(name1);
         $("#f2status").html("Retrieving followers for "+escape(name1)+"... this might take a bit.. <img src=\"spinner.gif\">");
         $.getJSON(url,
          function (data2, textStatus) {
              if(data2[0]>0) {     
                $("#f2status").html(data2.length+" followers");
                user2=new Array();
                for(i=0;i<data2.length;i++) user2[data2[i]]=1;
                followers2=data2.length;
                t2=true;
              } else {
                 $("#f2status").html("Problem finding that user. Check or try again.");
              }

          });
       });
     });


function update() {

  if(t1 && t2) {
    shared=0;
    notshared=0;
    for (var i in user1) {
      if(user2[i]) {
        shared++;
      } else {
        notshared++;
      }
   }
   $("#result").html("<div style=\"text-align:left; padding: 10px 50px 10px 50px;\">If @"+$("#f1").val()+" retweets @"+$("#f2").val()+", "+notshared+" new tweeps are potentially reached, but "+shared+", or "+Math.floor(1000*shared/followers1+0.5)/10+"%, of "+$("#f1").val()+"'s followers already follow @"+$("#f2").val()+".</p> <p>The extra reach of @"+$("#f1").val()+"'s retweet is +" +Math.floor(1000*notshared/followers2+0.5)/10+"% compared to @"+$("#f2").val()+"'s original tweet. <a target=\"_new\" href=\"http://twitter.com/home?status=If%20@"+$("#f1").val()+" retweets @"+$("#f2").val()+", the extra reach is %2B" +Math.floor(1000*notshared/followers2+0.5)/10+" %25. See http://cli.gs/7MVtr8 to calculate your %23retweeteffect\">Tweet this!</a><p>More stats:<br>"+Math.floor(1000*shared/followers1+0.5)/10+"% of @"+$("#f1").val()+"'s followers follow @"+$("#f2").val()+"<br>"+Math.floor(1000*shared/followers2+0.5)/10+"% of @"+$("#f2").val()+"'s followers follow @"+$("#f1").val()+" <p>This tool is created by <a href=\"http://twitter.com/michielb\">@michielb</a>, who also made the <a href=\"http://tweepguide.com\">Tweepguide Twitter Directory and Search Engine</a> worth checking out. </p></div>");

   username1=$("#f1").val();
   username2=$("#f2").val();
   sitestat("http://nl.sitestat.com/twittergids/com/s?rt.tool.result&amp;user1="+username1+"&amp;user2="+username2);
  }
}


    function sitestat(ns_l){ns_l+="&ns__t="+(new Date()).getTime();ns_pixelUrl=ns_l;
    ns_0=document.referrer;
    ns_0=(ns_0.lastIndexOf("/")==ns_0.length-1)?ns_0.substring(ns_0.lastIndexOf("/"),0):ns_0;
    if(ns_0.length>0)ns_l+="&ns_referrer="+escape(ns_0);
         if(document.images){ns_1=new Image();ns_1.src=ns_l}else
	   document.write("<img src="+ns_l+" width=1 height=1>");}

