// pesla-yql-min.js (c) 2009 Peter Slagter
// Licensed under the terms of the MIT license.

PESLA={};PESLA.init=function(){var c=function(){var e=document.getElementById("container");var d=document.getElementById("psl-blogs");var h=document.createElement("ul");d.appendChild(h);for(var g=0;g<3;g++){var n=document.createElement("li");var k=document.createElement("a");k.setAttribute("href","#tabs-"+(g+1));n.appendChild(k);h.appendChild(n);var m=document.createElement("section");m.id="tabs-"+(g+1);if(g===0){var f=b("Procurios")}else{if(g===1){var f=b("Procurios Techblog")}else{var f=b("Fronteers")}}m.appendChild(f);d.appendChild(m)}var l=a("psl-loading");var o=b("Loading contents");var j=document.createElement("ol");j.id="psl-loading-list";l.appendChild(o);l.appendChild(j);e.appendChild(l);$(".no-js").remove();$("#psl-toolkit").hide();$("#psl-tk-title").click(function(){$(this).toggleClass("open");$("#psl-toolkit").slideToggle()});PESLA.yql.guidelines.WCAGGuidelines();PESLA.yql.delicious.bookmarks();PESLA.yql.blogs.articles();PESLA.yql.twitter.tweets()};var a=function(e){var d=document.createElement("article");d.id=e;return d};var b=function(g){var d=document.createElement("header");var f=document.createElement("h1");var e=document.createTextNode(g);f.appendChild(e);d.appendChild(f);return d};return{build:function(){c()}}}();PESLA.yql={};PESLA.yql.loader=function(){var a=[];var b=function(){a.push("1");if(a.length===4){$("#psl-loading h1").text("Contents loaded.");setTimeout(function(){$("#psl-loading-list").fadeOut()},3000)}};return{handler:function(){b()}}}();PESLA.yql.delicious=function(){var a=function(){$(function(){$.jsonp({url:"http://query.yahooapis.com/v1/public/yql?q=select%20channel.item.title%2Cchannel.item.link%2Cchannel.item.pubDate%20from%20xml%20where%20url%3D%22http%3A%2F%2Ffeeds.delicious.com%2Fv2%2Frss%2Fpesla%3Fcount%3D5%22&format=json&diagnostics=false&callback=?",dataType:"jsonp",success:function(c){b(c.query.results.rss)},error:function(){$("#psl-delicious").append("<p class='error'>I'm sorry, the delicious bookmarks couldn't be loaded. Please refresh the page or try again later.</p><p>You could also visit <a href='http://delicious.com/pesla'>http://delicious.com/pesla</a>.</p>")},complete:function(){$("#load-bookmarks").addClass("loaded");PESLA.yql.loader.handler()}})})};var b=function(e){$("<ol id='psl-bookmark-list' class='psl-list'></ol>").appendTo("#psl-delicious");for(var c=0;c<5;c++){var f=(c===0)?"first":"";var d=(c===4)?"last":"";$("#psl-bookmark-list").append("<li class="+f+d+"><span>"+e[c].channel.item.pubDate.substring(5,16)+"</span><a href='"+e[c].channel.item.link+"'>"+e[c].channel.item.title+"</a></li>")}};return{bookmarks:function(){$("#psl-loading-list").append("<li id='load-bookmarks'>Delicious bookmarks</li>");a()}}}();PESLA.yql.blogs=function(){var a=function(){if($("#psl-blogs").length>0){$(function(){$("#psl-blogs").tabs()})}$(function(){var c=[];var g=function(){$.jsonp({url:"http://query.yahooapis.com/v1/public/yql?q=select%20channel.item.title%2Cchannel.item.link%2Cchannel.item.pubDate%20from%20xml%20where%20url%3D%22http%3A%2F%2Fwww.procurios.nl%2Fl%2Frss%2Fcollect%2Fnews%2F12768.459%22%20limit%2006&format=json&diagnostics=false&callback=?",dataType:"jsonp",success:function(i){if(i.query.results!=null){b(i.query.results.rss,"1","Procurios")}else{$("a[href='#tabs-1']").text("Procurios");$("#tabs-1").append("<p>No blogposts to show... :(</p>")}},error:function(){d("Procurios","1","http://www.procurios.nl/")},complete:function(){e()}})};var h=function(){$.jsonp({url:"http://query.yahooapis.com/v1/public/yql?q=select%20channel.item.title%2Cchannel.item.link%2Cchannel.item.pubDate%20from%20xml%20where%20url%3D%22http%3A%2F%2Ftechblog.procurios.nl%2Fl%2Frss%2Fcollect%2Fnews%2F14863.618%22%20limit%2006&format=json&diagnostics=false&callback=?",dataType:"jsonp",success:function(i){b(i.query.results.rss,"2","Procurios Techblog")},error:function(){d("Procurios Techblog","2","http://techblog.procurios.nl/")},complete:function(){e()}})};var f=function(){$.jsonp({url:"http://query.yahooapis.com/v1/public/yql?q=select%20channel.item.title%2Cchannel.item.description%2Cchannel.item.link%20from%20xml%20where%20url%3D%22http%3A%2F%2Ffronteers.nl%2Fblog.rss%22%20limit%206&format=json&diagnostics=false&callback=?",dataType:"jsonp",success:function(i){b(i.query.results.rss,"3","Fronteers")},error:function(){d("Fronteers","3","http://fronteers.nl/")},complete:function(){e()}})};var d=function(k,i,j){$("a[href='#tabs-"+i+"']").text(k);$("#tabs-"+i).append("<p class='error'>I'm sorry, the "+k+" newsitems can't be loaded at the moment. Please refresh the page or try again later.</p><p class='error'>You could also visit the <a href='"+j+"'>"+k+"</a> newspage.</p>")};var e=function(){c.push(1);if(c.length===3){$("#load-blogs").addClass("loaded");PESLA.yql.loader.handler()}};g();h();f()})};var b=function(f,j,k){$("a[href='#tabs-"+j+"']").text(k);var c="blogs-tabs"+j;$("#tabs-"+j).append("<ol id='"+c+"' class='psl-list'></ol>");var d=f.length;for(var g=0;g<d;g++){var h=(g===0)?"first":"";var l=(g===d-1)?"last":"";var e=(f[g].channel.item.pubDate)?"<li class='has-date "+h+l+"'><span>"+f[g].channel.item.pubDate.substring(5,16)+"</span>":"<li class="+h+l+">";$("#"+c).append(e+"<a href='"+f[g].channel.item.link+"'>"+f[g].channel.item.title+"</a></li>")}};return{articles:function(){$("#psl-loading-list").append("<li id='load-blogs'>Blog-items</li>");a()}}}();PESLA.yql.twitter=function(){var c="";var b=function(){$(function(){$.jsonp({url:"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Ftwitter.com%2Fpesla%2F%22%20and%20xpath%3D%22%2F%2Fspan%5B%40class%3D'entry-content'%5D%22%20limit%2010&format=xml&diagnostics=false&callback=?",dataType:"jsonp",success:function(d){c=d.results;a()},error:function(){$("#psl-tweets").append("<p class='error'>I'm sorry, the Twitter timeline couldn't be loaded. Please refresh the page or try again later.</p><p class='error'>You could also visit <a href='http://twitter.com/pesla'>http://twitter.com/pesla</a>.</p>")},complete:function(){$("#load-tweets").addClass("loaded");PESLA.yql.loader.handler()}})})};var a=function(){if($("#psl-tweets-list").length<1){$("<ol id='psl-tweets-list' class='psl-list'></ol><button id='psl-tweets-more'>Show more tweets</button>").appendTo("#psl-tweets");for(var d=0;d<5;d++){var e=(d===0)?"first":"";$("#psl-tweets-list").append("<li class="+e+">"+c[d].replace(/<span class="entry-content">/,"").replace(/<\/span>/,"").replace(/href="\//g,'href="http://www.twitter.com/')+"</li>")}$("#psl-tweets-more").click(function(){var f=$(this).data("status");if(f===undefined){for(var g=5;g<10;g++){$("#psl-tweets-list").append('<li class="psl-tweets-more">'+c[g].replace(/<span class="entry-content">/,"").replace(/<\/span>/,"").replace(/href="\//g,'href="http://www.twitter.com/')+"</li>")}$(this).data("status","open");$(this).addClass("open");$(this).text("Show less tweets")}else{if(f==="open"){$(this).data("status","closed");$(this).removeClass("open");$(this).text("Show more tweets");$(".psl-tweets-more").hide()}else{$(this).data("status","open");$(this).addClass("open");$(this).text("Show less tweets");$(".psl-tweets-more").show()}}a()})}};return{tweets:function(){$("#psl-loading-list").append("<li id='load-tweets'>Twitter statusses</li>");b()}}}();PESLA.yql.guidelines=function(){var c="";var b=function(){$("<blockquote id='wcag-guideline'></blockquote><button id='psl-wcag-update' class='button'><span>Show me more!</span></button>").appendTo("#psl-wcag");d();$("#psl-wcag-update").click(function(){d()})};var a=function(){$(function(){$.jsonp({type:"GET",url:"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fwww.w3.org%2FTR%2FWCAG%2F%22%20and%20xpath%3D%22%2F%2Fdiv%5B%40class%3D'guideline'%5D%2Fh3%22&format=json&callback=?",dataType:"jsonp",success:function(e){c=e.query.results.h3;b()},error:function(){$("#psl-wcag").append("<p class='error'><a href='http://www.w3.org/TR/WCAG/'>Read the WCAG 2.0 guidelines to build a better web!</a></p>")},complete:function(){$("#load-guidelines").addClass("loaded");PESLA.yql.loader.handler()}})})};var d=function(){var e=c.length;var g=c[Math.floor(Math.random()*(e-1))+1];var f="http://www.w3.org/TR/WCAG/#"+g.a.id;$("#wcag-guideline").empty();$("<p><a href="+f+">"+g.content+"</a></p>").appendTo("blockquote#wcag-guideline")};return{WCAGGuidelines:function(){$("#psl-loading-list").append("<li id='load-guidelines'>WCAG 2.0 guidelines</li>");a()}}}();
