//Whit-html5 theme, <http://xiebiji.com>, My Object Oriented (JavaScript) Tools. Copyright (c) 2009-2010 Joe Zhou, <http://xiebiji.com>, MIT Style License.
(function(o,s,x,y,d){
			s = o.style;//id为w的元素直接充当这里的o了
			d = document;//
			o.onselectstart = function(){ return false; }; //阻止选择
			o.onmousedown = function(e){
				e = e||event;
				x = e.clientX-o.offsetLeft+100;
				y = e.clientY-o.offsetTop;
				d.onmousemove = function(e){
					e = e||event;
					s.left = e.clientX - x+200 + "px";
					s.top = e.clientY - y + "px";
				}
				d.onmouseup = function(){ d.onmouseup = d.onmousemove = ""; }
			}
})(document.getElementById("twitter"))

//滔滔
var lis=$$('#id_apiPane li');
var perHeight=lis[0].getStyle('height').toInt();//移动一次偏移margin
var nowShowLi=0;//当前出现的li号，由0开始
var nowSpan=lis[nowShowLi].getElementsByTagName('SPAN')[0];
$('twi_up').addEvent('click',function(event){
	if(nowShowLi>0){
		nowShowLi--;
		nowSpan=lis[nowShowLi].getElementsByTagName('SPAN')[0];
		$('id_apiPane').setStyle('margin-top',-nowShowLi*perHeight);
		userTooFast(event,'Message:'+(nowShowLi+1));
		resetSpan();
		txtSpanInter=spanCicleMove.delay(1000);
	}
	else
	userTooFast(event,'No previous message!');
	
	return false;
	
});
$('twi_down').addEvent('click',function(event){
	if(nowShowLi<lis.length-1){
		nowShowLi++;
		nowSpan=lis[nowShowLi].getElementsByTagName('SPAN')[0];
		$('id_apiPane').setStyle('margin-top',-nowShowLi*perHeight);
		userTooFast(event,'Message:'+(nowShowLi+1));
		resetSpan();
		txtSpanInter=spanCicleMove.delay(1000);
	}
	else
	userTooFast(event,'No next message!');
	
	return false;
	
});
var txtSpanInter=null;//计时器
var txtWidth=0;//当前span
function spanCicleMove(){
	span=lis[nowShowLi].getElementsByTagName('SPAN')[0];
	//获取实际宽度
	span.setStyle('visibility','hidden');
	span.setStyle('position','absolute');
	txtWidth=span.getStyle('width').toInt();
	span.setStyle('position','relative');
	span.setStyle('visibility','visible');
	$clear(txtSpanInter);
	txtSpanInter=moveTxt.periodical(25);
}
function moveTxt(){
	m=nowSpan.getStyle('margin-left').toInt();
	nowSpan.setStyle('margin-left',m-1);
	if(260+txtWidth<=-span.getStyle('margin-left').toInt()){
		span.setStyle('margin-left',220);
	}
}
function resetSpan(){
	$clear(txtSpanInter);
	span=$$('#id_apiPane li .txt');
	span.each(function(e){e.setStyle('margin-left',0)});
}
$('twitter').addEvent('mouseenter',function(event){
	txtSpanInter=spanCicleMove.delay(1000);
});
$('twitter').addEvent('mouseleave',function(event){
	$clear(txtSpanInter);
	nowSpan.tween('margin-left',0);
});

//看过的日志
$('J_viewed').setStyle('visibility','hidden');
$('J_viewed').setStyle('width','');
$('J_viewed').setStyle('height','');
viewedWidth=$('J_viewed').getStyle('width').toInt();
viewedheight=$('J_viewed').getStyle('height').toInt();
$('J_viewed').setStyle('width',54);
$('J_viewed').setStyle('height',21);
$('J_viewed').setStyle('visibility','visible');
var myEffect = new Fx.Morph($('J_viewed'), {
	duration: 'long', 
	transition: Fx.Transitions.Sine.easeOut
});
$('J_viewed').addEvent('mouseenter',function(){
	this.addClass('viewedHover');
	myEffect.cancel();
	myEffect.start({
		'height': viewedheight, 
    	'width': viewedWidth
	});

});
$('J_viewed').addEvent('mouseleave',function(){
	this.removeClass('viewedHover');
	myEffect.cancel();
	myEffect.start({
		'height': 21, 
    	'width': 54
	});

});

//
function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}