﻿$(document).ready(function(){
//Load Zuosa
$.getJSON("http://api.zuosa.com/statuses/user_timeline.json?id=fantongchen&count=1&callback=?",function(x){
var a=x[0].text,t=x[0].created_at,t=new Date(t.replace(/\+/ig,"UTC+")),d=(new Date().getTime()-t.getTime())/100000,m;
if(d<36){m=Math.floor(d/(0.6))+"分钟"}
else if(d>36&&d<864){m=Math.floor(d/(36))+"小时"}
else if(d>864){m=Math.floor(d/(864))+"天"}
if(a.length+m.length>28){a=a.substr(0,22)+"..";}
$("#msg a").html(a);
$("#msg a").attr("title",x[0].text);
$("#msg span").html(m+"前");});
//load weather
$.post("do.php",{doo:"weather"},function(s){$("#weather").append(s);});
//load exchange rate
$.post("do.php",{doo:"usd"},function(s){$("#usd").html(s);});
//load stock
$.post("do.php",{doo:"stock"},function(s){$("#stock").append(s);});
//load lunar
$("#lunar").append(lunar[Math.floor((Date.parse(Date())-Date.parse("Feb 25, 2010"))/86400000)]);
//show&hide tab
var a="border-bottom",b="#FFF solid 1px",c="#DDD solid 1px";
$("#t1").mouseover(function(){
$("#a").show();$("#b,#c").hide();
$("#t1").css(a,b);$("#t2,#t3").css(a,c);
$("#t1").addClass("t_hover");
$("#t2,#t3").removeClass("t_hover");
});
$("#t2").mouseover(function(){
$("#b").show();$("#a,#c").hide();
$("#t2").css(a,b);$("#t1,#t3").css(a,c);
$("#t2").addClass("t_hover");
$("#t1,#t3").removeClass("t_hover");
});
$("#t3").mouseover(function(){
$("#c").show();$("#a,#b").hide();
$("#t3").css(a,b);$("#t1,#t2").css(a,c);
$("#t3").addClass("t_hover");
$("#t2,#t1").removeClass("t_hover");
});

//Play music
$("#b span").click(function(){
var id=$(this).attr("id").split("m")[1];
window.open("music/index.html?id="+id,"","alwaysRaised=yes,width=300,height=240,toolbar=no,menubar=no");						
});

//Compass slip
var h=new Array(),t=new Array(),l=new Array();
h[0]='blog/index.html'
h[-150]='web/index.html'
h[-300]='twitter.html'
h[-450]='music/index.html'
h[-600]='tool/index.html'
h[-750]='http://www.gmail.com/'
t[0]="我 的 日 志"
t[-150]="网 站 建 设"
t[-300]="我 在 做 啥"
t[-450]="音 乐 匣 子"
t[-600]="在 线 工 具"
t[-750]="我 的 邮 件"
l[0]="访问我的个人博客"
l[-150]="长沙网站建设业务"
l[-300]="看一看我的微博客"
l[-450]="听一听我收藏的音乐"
l[-600]="我开发的各种在线工具"
l[-750]="这个就不要看了"
$("#b3 a").data("px",0);
var px=$("#b3 a").data("px");
$("#l").click(function(){px=px+150;if(px>0||px<-750){px=-750}slip(px-20,px-10,px)});
$("#r").click(function(){px=px-150;if(px>0||px<-750){px=0}slip(px+20,px+10,px)});
function slip(x,y,z){
$("#b3 a").attr("style","background-position:"+x+"px 0");
setTimeout('$("#b3 a").attr("style","background-position:'+y+'px 0")',150);
setTimeout('$("#b3 a").attr("style","background-position:'+z+'px 0")',150);
$("#b3 a").data("px",z);$("#b3 h1").html(t[z]);
if(z==-450){
$("#b3 a").removeAttr("href");
$("#b3 a").removeAttr("target");
$("#b3 a").removeAttr("onClick");
$("#b3 a").attr("onclick",'window.open("music/index.html","","alwaysRaised=yes,width=300,height=240,toolbar=no,menubar=no")')}
else{
$("#b3 a").removeAttr("onClick");
$("#b3 a").attr("href",h[z]);
$("#b3 a").attr("title",l[z]);
$("#icon").attr("target","_blank")}}

})//Jquery End

//Lunar Calendar
var lunar=new Array(
" 正月十二",
" 正月十三",
" 正月十四",
" 正月十五 元宵节",
" 正月十六",
" 正月十七",
" 正月十八",
" 正月十九",
" 正月二十 惊蛰"
);