// Auto-Tagger v0.1
// http://www.greg-hill.id.au   2006
// This work is licensed under a Creative Commons Attribution-ShareAlike 2.1 Australia License.
// Check http://blogfresh.blogspot.com for details

var tpos=0,upos=0,dpos=0; var list=[]; var inp=document.getElementsByTagName('input'); for (var i=0; i<inp.length; i++) {if(inp[i].className=="url"||inp[i].name=="url") upos=i; if(inp[i].className=="tags"||inp[i].name=="tags") tpos=i; if(inp[i].className=="desc"||inp[i].name=="description") dpos=i; if(upos*tpos*dpos>0) {list.push([upos, tpos, dpos]);upos=0;tpos=0;dpos=0;}} list.reverse(); if(list.length>0) url2tags(list.pop()); void(0); function url2tags(pos){upos=pos[0]; tpos=pos[1]; dpos=pos[2]; var u=inp[upos].value; var s=document.createElement('script'); s.type='text/javascript'; s.src='http://tagthe.net/api/?url='+u+'&view=json&callback=cb'; document.getElementsByTagName("head")[0].appendChild(s); return;} function cb(obj){if (typeof(tags=obj.memes[0].dimensions.topic)=='undefined') return; inp[tpos].value+=' '+tags.join(' ').replace(/nullitem/i,''); if (typeof(title=obj.memes[0].dimensions.title)=='undefined') return; inp[dpos].value=title; if(list.length>0) url2tags(list.pop()); return;}