// Ultima version: http://adivina.blogspot.com
var usuariodelicious = "blogsome";
var taggicuentadel = 0;
var lostaggis="";
var tlostaggis=0;
Function.prototype.bg = function(ms){
this.PID = setInterval(this,ms);
return this;
}
Function.prototype.kill = function(){
clearInterval(this.PID)
}
String.prototype.onReady = function(func){
var str = this;
return function(){
try{
eval("var res=("+str+")");
if(res){
arguments.callee.kill();
func()
}
}catch(e){
}
}.bg(10)
}
function taggideliload(user){
taggicuentadel++;
if (taggicuentadel >= 2) return;
document.body.style.cursor="wait";
document.getElementById("taggicontainer").innerHTML="<br /><"+'span style="color:white;background-color:black">Cargando...<'+"/span><br /><br />";
"Delicious.posts".onReady(taggifeed_onload);
var s = document.createElement("script");
s.src = "http://del.icio.us/feeds/json/"+user;
s.charset = "utf-8";
document.body.appendChild(s);
}
function taggifeed_onload(){
var i = 0;
var elpost="";
var delpost="";
for (var i=0, post; post = Delicious.posts[i]; i++) {
if (i == (tlostaggis - 1) ) {
elpost=post.u;
delpost=post.d;
}
}
taggicuentadel = 0;
document.getElementById("taggicontainer").innerHTML='Redireccionando a <'+'span style="font-weight:bold;">'+delpost+"<"+"/span>";
document.body.style.cursor="default";
delete Delicious.posts;
location.href=elpost;
}

function aleatorio(a,b) {
return Math.round(Math.random()*(b-a)+a);
}
function azar() {
lostaggis=document.getElementById("delicious-tags-"+usuariodelicious).innerHTML;
tlostaggis=0;
var rlostaggis=0;
lostaggis = lostaggis.replace(/<[^>]+>/g, "");
slostaggis = lostaggis.split(" ");
for(var iM=0;iM < slostaggis.length;iM++) {
if ((iM/2) == Math.floor(iM/2)) if (parseInt(slostaggis[iM])) tlostaggis=tlostaggis + parseInt(slostaggis[iM]);
}
rlostaggis=aleatorio(1,tlostaggis);
tlostaggis=0;
for(var iM=0;iM < slostaggis.length;iM++) {
if ((iM/2) == Math.floor(iM/2)) {
if (parseInt(slostaggis[iM])) {
lostaggis = slostaggis[iM + 1];
tlostaggis=tlostaggis + parseInt(slostaggis[iM]);
if (tlostaggis >= rlostaggis) {tlostaggis = rlostaggis - (tlostaggis - parseInt(slostaggis[iM]));break;}
};
}
}
taggideliload(usuariodelicious+'/'+lostaggis+'?count=100');
}
