/* 
 * Copyright (c) Day Barr 2009. All rights reserved.
 * By http://www.DayBarr.com for use at http://www.FeedRunner.net
 */
$(function(){var h=[],d={},i=0,c=0,l=0,f=0,m="http://pipes.yahoo.com/pipes/pipe.run?_id=41e1a853a67617db61914c48b4bbdec6&_render=rss&q=%40feedrunner",b=function(){var n=$("<ul/>").hide().appendTo($("#content"));a(m,n,"page-link")},k=function(n){return n.replace(/^(https?:\/\/[^\/]+)\/.*/,"$1")},a=function(o,n,p){n.append($('<p class="loading"/>').text("Loading feed...")).fadeIn();p=p||"feed-link";$.ajax({url:"http://pipes.yahoo.com/pipes/pipe.run?_id=jLS87ckf3hG8m90APm7D0g&_render=json&url="+encodeURIComponent(o)+"&_callback=?",dataType:"jsonp",success:function(q){n.empty().hide();if(!q.value||!q.value.items||!q.value.items.length){n.append('<div class="error">Dead end</div>');return}$.each(q.value.items,function(r,s){n.append($("<li/>").addClass(p).append($("<a/>").attr({href:s.link,id:"link"+i++,title:s.title}).text(s.title)))});l++},error:function(){n.append('<div class="error"><code>:(</code></div>')},complete:function(){g(n)}})},e=function(o,n){var p=k(o),q="javascript";n.append($('<p class="loading"/>').text("Loading page content...")).fadeIn();$.ajax({url:"http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent("select * from html where url='")+encodeURIComponent(o)+encodeURIComponent("' and xpath=\"//a[not(starts-with('"+q+":',@href))]\"")+"&format=json&callback=?",dataType:"jsonp",success:function(t){n.empty().hide();if(!t.query||!t.query.results||!t.query.results.a||!t.query.results.a.length){n.append('<div class="error">Dead end</div>');return}var r=t.query.results.a,s={};$.each(r,function(u,v){if(v.href.substr(0,p.length)!=p&&v.href.match("https?://")&&!s[v.href]){s[v.href]=1;var w=$.trim(v.content)||$.trim(v.title)||$.trim(v.img?v.img.alt:"")||((v.href.length<63)?v.href:(v.href.slice(0,60)+"..."));n.append($('<li class="page-link"/>').append($("<a/>").attr({href:v.href,id:"link"+i++,title:w}).text(w)))}})},error:function(){n.append('<div class="error"><code>:(</code></div>')},complete:function(){g(n)}})},g=function(n){var p=n.parent("li").data("depth")||0,o=p+1;if(o>f){f=o}n.children("li").each(function(q,r){$(r).data("depth",o).addClass("depth"+(o%30))});n.find(">li>a").each(function(r,s){var q=$(s);q.before($('<img class="favicon"/>').attr("src",k(q.attr("href"))+"/favicon.ico")," ")});if(n.children("li").length){n.slideDown(2000,j)}else{n.show();setTimeout(j,100)}},j=function(){var r=$("li:not(.done)"),s=function(){return r.eq(Math.floor(Math.random()*r.length))},o=s();$("#current-depth").text(f);$("#link-count").text(i);$("#feed-count").text(l);if(o.length){var q=o.find(">a").attr("href").replace(/#.*$/,"");o.addClass("done");if(d[q]){o.append(" Already visited");d[q].find(">a").after(" +");setTimeout(j,0);return}var p=$("<ul/>").hide();o.append(p);d[q]=o;c++;var n=0;$("html,body").animate({scrollTop:o.offset().top-100},2000,function(){if(++n==2){if(o.hasClass("feed-link")){e(q,p)}else{a(q,p)}}})}else{if(confirm("Can't find any more feeds. Restart?")){location.reload()}}};if(location.search){$.each(location.search.slice(1).split("&"),function(n,o){o=o.split("=");if(o[0]=="url"){m=decodeURIComponent(o[1])}})}b();(function(){var n=(("https:"==document.location.protocol)?"https://ssl.":"http://www.");jQuery.getScript(n+"google-analytics.com/ga.js",function(){_gat._getTracker("UA-5628626-3")._trackPageview()})})()});