if(!SAPO.Widget||typeof(SAPO.Widget)=='undefined'){SAPO.namespace('Widget');} SAPO.Widget.Tags=function(options) {if(SAPO.Exception&&typeof(SAPO.Exception)!='undefined'){this.exception=new SAPO.Exception('SAPO::Widget.Tags');}else{this.exception=false;} if(options!='undefined'){this.init(options);}else{this.init({});}};tagsShowImage=function(img){return(function(){img.style.display='inline';});};SAPO.Widget.Tags.prototype={init:function(options) {options=SAPO.extendObj({url:false,instance:false},arguments[0]||{});this.options=options;if(this.options.instance===false){this.options.instance=Math.round(10000*Math.random());var cmd='tags'+this.options.instance+'=this';eval(cmd);}},getTagReferer:function(){var keywords='';var ref=document.referrer;if(ref&&ref!==''){var regSearchEng=new RegExp("\.google|\.sapo|\.yahoo","i");if(ref.match(regSearchEng)){var regSearch=new RegExp("(&|\\?)(q|p)=(.*?)&?","i");if(ref.match(regSearch)){var regKeywords=new RegExp("(.*)(&|\\?)(q|p)=([^&]+)?((&)?(.*)?)","ig");keywords=ref.replace(regKeywords,"$4");keywords=unescape(keywords);keywords=keywords.replace(/\+/g,' ');keywords=keywords.replace(/"/g,' ');keywords=keywords.replace(/(^\s+|\s+$|\n)/g,'');keywords=keywords.replace(/\s\s/g,' ');}}} return keywords;},postTags:function(defaultTags,url){var obj=this.setTagVars(url);var urlTags=location.href;if(defaultTags===''){urlTags='http://'+this.options.printtagthis.baseurl+'/post?v=3&url='+encodeURIComponent(obj.url)+'&title='+encodeURIComponent(obj.title)+'&referer='+encodeURIComponent(obj.tags);} else {urlTags='http://'+this.options.printtagthis.baseurl+'/post?v=3&url='+encodeURIComponent(obj.url)+'&title='+encodeURIComponent(obj.title)+'&referer='+encodeURIComponent(obj.tags)+'&tags='+encodeURIComponent(defaultTags);} location.href=urlTags;},setTagVars:function(turl) {if(turl===''){url=location.href;}else{if(turl.match("http://")){url=turl;}else{url='http://'+turl;}} url=url.replace(/\'/g,"%27;");url=url.replace(/\"/g,"%22");var title=document.title;title=title.replace(/\'/g,"%27");title=title.replace(/\"/g,"%22");var myvars={url:url,title:title,tags:this.getTagReferer()};return myvars;},getDefaultTags:function(jslocation){var tags='';if(jslocation){var mTags=new RegExp("(&|\\?)tags=([^&]*)($|&)","i");if(jslocation.match(mTags)){var reTags=new RegExp("(.*)(&|\\?)tags=([^&]*)&?(.*)","gm");tags=jslocation.replace(reTags,"$3");}} return decodeURIComponent(tags).replace(/^\s+|\s+$|\n/g,'').replace(/(<[^>]>|\+)/g,' ');},printTagThis:function(options){options=SAPO.extendObj({b:3,baseurl:'links.sapo.pt',t:'Guardar esta página',tags:'',url:''},arguments[0]||{});this.options.printtagthis=options;switch(parseInt(options.b,10)){case 1:buttonName='';break;case 2:buttonName='';break;case 3:buttonName='';break;default:buttonName=''+options.t+'';break;} document.write(buttonName);},newPrintBookmarks:function(feed,title,more,limit,uimg,width,cut){var html='