(function(){ fcb = function(d) { ktndata = d; var p = document.getElementsByTagName('img'); for (var i in p) { //Set the explicit height / width otherwise images get resized to the size of the kitten image rather than staying at their original size p[i].width = p[i].width; p[i].height = p[i].height; p[i].src = d.items[Math.floor(Math.random()*(d.items.length))].media.m; } }; if (typeof ktndata == 'undefined') { var jp = document.createElement('script'); jp.setAttribute('type','text/javascript'); jp.setAttribute('src','http://api.flickr.com/services/feeds/photos_public.gne?tags=kitten&tagmode=any&format=json&jsoncallback=fcb'); document.getElementsByTagName('head')[0].appendChild(jp); } else { fcb(ktndata); } })();