jQuery.fn.scrollTo = function(speed) {
var targetOffset = $(this).offset().top;
$('html,body').stop().animate({scrollTop: targetOffset}, speed);
return this;
}; 
/* 平滑滚动插件 */
$(function() {
    var twurl = 'http://dimlau.appspot.com/api/search.json';
    var twuser = 'dimlau';
    $.ajaxSetup({ cache: true });
    $.getJSON(
        twurl + '?callback=?&rpp=1&q=%23diggcafe+from:' + twuser,
        function(data) {
            $.each(data.results, function(i,tweet) {
                if (tweet.text !== undefined) {
                    var date_tweet = new Date(tweet.created_at);
                    var date_now = new Date();
                    var date_diff = date_now - date_tweet;
                    var hours = Math.round(date_diff/(1000*60*60));
                    var tweet_html = '<p class="taotaopost">';
                    tweet_html += '<a href="http://www.twitter.com/';
                    tweet_html += twuser +'/status/' +tweet.id +'">';
                    tweet_html += tweet.text + '</a>';
                    tweet_html += '<time pubdate class="smalls"> 约 ' + hours;
                    tweet_html += ' 小时前</time></p>';
                    $('#totaoContent').html(tweet_html);
                }
            });
        }
    );
/* 读取滔滔心情 */
$('a,input[type="button"],input[type="submit"]').bind('focus',function(){
if(this.blur){
this.blur();
};
});
/* 去除链接点击后的虚线框 */
$(".posttext a").not("[href*=diggcafe.com]").not("[href^=#]").not("[href^=javascript]").addClass('gooutsite');
$(".gooutsite").attr({ target: "_blank" });
/* 站外链接标识 */
$("#header_search_query").focus(function(){if (this.value == '搜索内容...') {this.value = '';}}).blur(function(){if (this.value == '') {this.value = '搜索内容...';}});
/* 搜索框文字 */
$("#gototopbox a").click(function(){
$("body").scrollTo(500);
return false;
});
$(".postinfo a").click(function(){
var target_id = $(this).attr("href");
$(target_id).scrollTo(500);
return false;
});
/* 平滑滚动之回到顶部 */
/* setInterval( "dcount(1266076800000)", 1000 ); */
/* 倒计时 */
$("#imgads").scrollable({loop: true,size: 1,speed: 400}).navigator().autoscroll({autopause: true,interval:8000});
$("#indexmainbox").scrollable({loop: true,size: 1,speed: 800}).navigator().autoscroll({autopause: true,interval:8000});
/* 幻灯片 */
$("#diggtree a").tooltip({opacity: 0.85,predelay: 200,position:"center right",offset: [0, -10],effect: 'slide'}).dynamic(); 
/* 日程树浮动层 */
$("form.diggbox :input").tooltip({position: "center right",offset: [0, 5],effect: 'slide',tip: '#comment-greeting'});
$(".expose").click(function() { $(this).expose({api: true}).load();});
/* 聚焦 */
});