function friendfeed() { var e=document.createElement('script'); e.setAttribute('type','text/javascript'); e.setAttribute('src','http://friendfeed.com/share/bookmarklet/javascript'); document.body.appendChild(e) } function delicious() { window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=600,height=400'); return false; } function twitter() { window.open('http://twitter.com/home?status='+encodeURIComponent('看看这儿 '+'@parandroid -'+document.title)+encodeURIComponent(location.href),'twitter','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes'); return false; } function douban() { window.open('http://9.douban.com/recommend/?url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title)+'&amp;v=2&amp;n=1','douban','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes'); return false; } function facebook() { window.open('http://www.facebook.com/share.php?u='+encodeURIComponent(location.href)+'&amp;t='+encodeURIComponent(document.title),'Facebook','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes'); return false; } function kaixin(desc) { window.open('http://www.kaixin001.com/~repaste/repaste.php?rtitle='+encodeURIComponent(document.title)+'&rurl='+encodeURIComponent(location.href)+'&rcontent='+encodeURIComponent(desc),'kaixin','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes'); return false; } function par_replyto(commentID,author) { var inReplyTo='@<a href="#comment-'+commentID+'">'+author+' <\/a>'; var myField; if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') { myField = document.getElementById('comment'); } else { return false; } if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = inReplyTo; myField.focus(); } else if (myField.selectionStart || myField.selectionStart == '0') { var startPos = myField.selectionStart; var endPos = myField.selectionEnd; var cursorPos = endPos; myField.value = myField.value.substring(0, startPos) + inReplyTo + myField.value.substring(endPos, myField.value.length); cursorPos += inReplyTo.length; myField.focus(); myField.selectionStart = cursorPos; myField.selectionEnd = cursorPos; } else { myField.value += inReplyTo; myField.focus(); } } var ss = { fixAllLinks: function() { var allLinks = document.getElementsByTagName('a'); for (var i=0;i<allLinks.length;i++) { var lnk = allLinks[i]; if ((lnk.href && lnk.href.indexOf('#') != -1) && ( (lnk.pathname == location.pathname) || ('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) { ss.addEvent(lnk,'click',ss.smoothScroll); } } }, 
smoothScroll: function(e) { if (window.event) { target = window.event.srcElement; } else if (e) { target = e.target; } else return; if (target.nodeName.toLowerCase() != 'a') { target = target.parentNode; } if (target.nodeName.toLowerCase() != 'a') return; anchor = target.hash.substr(1); var allLinks = document.getElementsByTagName('a'); var destinationLink = null; for (var i=0;i<allLinks.length;i++) { var lnk = allLinks[i]; if (lnk.name && (lnk.name == anchor)) { destinationLink = lnk; break; } } if (!destinationLink) destinationLink = document.getElementById(anchor); if (!destinationLink) return true; var destx = destinationLink.offsetLeft; var desty = destinationLink.offsetTop; var thisNode = destinationLink; while (thisNode.offsetParent && (thisNode.offsetParent != document.body)) { thisNode = thisNode.offsetParent; destx += thisNode.offsetLeft; desty += thisNode.offsetTop; } clearInterval(ss.INTERVAL); cypos = ss.getCurrentYPos(); ss_stepsize = parseInt((desty-cypos)/ss.STEPS); ss.INTERVAL =setInterval('ss.scrollWindow('+ss_stepsize+','+desty+',"'+anchor+'")',10); if (window.event) { window.event.cancelBubble = true; window.event.returnValue = false; } if (e && e.preventDefault && e.stopPropagation) { e.preventDefault(); e.stopPropagation(); } }, scrollWindow: function(scramount,dest,anchor) { wascypos = ss.getCurrentYPos(); isAbove = (wascypos < dest); window.scrollTo(0,wascypos + scramount); iscypos = ss.getCurrentYPos(); isAboveNow = (iscypos < dest); if ((isAbove != isAboveNow) || (wascypos == iscypos)) { window.scrollTo(0,dest); clearInterval(ss.INTERVAL); location.hash = anchor; } }, getCurrentYPos: function() { if (document.body && document.body.scrollTop) return document.body.scrollTop; if (document.documentElement && document.documentElement.scrollTop) return document.documentElement.scrollTop; if (window.pageYOffset) return window.pageYOffset; return 0; }, addEvent: function(elm, evType, fn, useCapture) { if (elm.addEventListener){ elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent){ var r = elm.attachEvent("on"+evType, fn); return r; } else { alert("Handler could not be removed"); } } } ; ss.STEPS = 10; ss.addEvent(window,"load",ss.fixAllLinks); 

