// JavaScript Document
//分享函数
	function getParamsOfShareWindow(width, height) {
		return ['toolbar=0,status=0,resizable=1,width=' + width + ',height=' + height + ',left=', (screen.width - width) / 2, ',top=', (screen.height - height) / 2].join('');
	}
	function bindShareList(){
		var link = encodeURIComponent(document.location);
		var title = encodeURIComponent(document.title.substring(0, 76));
		var source = encodeURIComponent('http://www.biao166.cn');
		var windowName = 'share';
		var site = 'http://www.microhu.com/';
		$('#facebook-share').click(function() {
			var url = 'http://facebook.com/share.php?u=' + link + '&t=' + title;
			var params = getParamsOfShareWindow(626, 436);
			window.open(url, windowName, params)
		});
		$('#twitter-share').click(function() {
			var url = 'http://twitter.com/share?url=' + link + '&text=' + title;
			var params = getParamsOfShareWindow(500, 375);
			window.open(url, windowName, params)
		});
		$('#delicious-share').click(function() {
			var url = 'http://delicious.com/post?url=' + link + '&title=' + title;
			var params = getParamsOfShareWindow(550, 550);
			window.open(url, windowName, params)
		});
		$('#kaixin001-share').click(function() {
			var url = 'http://www.kaixin001.com/repaste/share.php?rurl=' + link + '&rcontent=' + link + '&rtitle=' + title;
			var params = getParamsOfShareWindow(540, 342);
			window.open(url, windowName, params)
		});
		$('#renren-share').click(function() {
			var url = 'http://share.renren.com/share/buttonshare?link=' + link + '&title=' + title;
			var params = getParamsOfShareWindow(626, 436);
			window.open(url, windowName, params)
		});
		$('#douban-share').click(function() {
			var url = 'http://www.douban.com/recommend/?url=' + link + '&title=' + title;
			var params = getParamsOfShareWindow(450, 350);
			window.open(url, windowName, params)
		});
		$('#sina-share').click(function() {
			var url = 'http://v.t.sina.com.cn/share/share.php?url=' + link + '&title=' + title;
			var params = getParamsOfShareWindow(607, 523);
			window.open(url, windowName, params)
		});
		$('#netease-share').click(function() {
			var url = 'http://t.163.com/article/user/checkLogin.do?link=' + link + 'source=' + source + '&info=' + title + ' ' + link;
			var params = getParamsOfShareWindow(642, 468);
			window.open(url, windowName, params)
		});
		$('#tencent-share').click(function() {
			var url = 'http://v.t.qq.com/share/share.php?title=' + title + '&url=' + link + '&site=' + site;
			var params = getParamsOfShareWindow(634, 668);
			window.open(url, windowName, params)
		})
	}
	
	//上下滚动
	function up(){
		$wd = $(window);
		$wd.scrollTop($wd.scrollTop() - 1);
		fq = setTimeout("up()", 50);
	}
	function dn(){
		$wd = $(window);
		$wd.scrollTop($wd.scrollTop() + 1);
		fq = setTimeout("dn()", 50);
	}
	

$(document).ready(function(){
	$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');//修复Opera滑动异常地
	
	//普通css效果处理
	$("#rss li:last").css("border-bottom","none");
	$("#use_box li:last").css("border-bottom","none");
	$("#use_box li:last").css("border-bottom","none");
	$("#recent-comments li:last").css("border-bottom","none");
	$(".commentlist li.depth-1:last").css("border-bottom","none");
	$("textarea#comment").attr( "onkeydown", "if(event.ctrlKey&&event.keyCode==13){document.getElementById('submit').click();return false};");
	$("#submit").attr( "value", "确认提交 / Ctrl + Enter").width(180);

	//菜单处理
	if(!$("#nav li").hasClass("current_page_item")){
		$("#nav li:first").addClass("current_page_item");
	}
	
	
	//订阅和工具下拉框效果
	$("#use_box:has(ul)").hover(function(){
		$(this).children("ul").stop(true,true).slideDown(400);
	}, function(){
		$(this).children("ul").stop(true,true).slideUp("fast");
	})
	$("#rss:has(ul)").hover(function(){
		$(this).children("ul").stop(true,true).slideDown(400);
	}, function(){
		$(this).children("ul").stop(true,true).slideUp("fast");
	})
	

	
	// fancybox图片效果
	$(".entry-content a:has(img)").fancybox({
		'overlayShow'	: true,
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'
	 });
	 
	 //分享
  	bindShareList()
	
	//上下
	$('#shang').mouseover(function(){//鼠标移到id=shang元素上触发事件
		up();
	}).mouseout(function(){//鼠标移出事件
		clearTimeout(fq);
	}).click(function(){//点击事件
		$body.animate({scrollTop:0},400);//400毫秒滑动到顶部
	});
	$('#xia').mouseover(function(){
		dn();
	}).mouseout(function(){
		clearTimeout(fq);
	}).click(function(){
		$body.animate({scrollTop:$(document).height()},400);//直接取得页面高度，不再是手动指定页尾ID
	});
	$('#comt').click(function(){
		$body.animate({scrollTop:$('#comments').offset().top},400);//滑动到id=comments元素，遇到不规范的主题需调整
	});
	
	//归档页面效果
	/* 存档页面 jQ伸缩 */
/*	$('#expand_collapse,.archives-yearmonth').css({cursor:"s-resize"});
	$('#archives ul li ul.archives-monthlisting').hide();
	$('#archives ul li ul.archives-monthlisting:first').show();
	$('#archives ul li span.archives-yearmonth').click(function(){$(this).next().slideToggle('fast');return false;});
	//以下下是全局的操作
	$('#expand_collapse').toggle(function(){
		$('#archives ul li ul.archives-monthlisting').slideDown('fast');
	},function(){
		$('#archives ul li ul.archives-monthlisting').slideUp('fast');
	});	*/		 
})

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-12317316-3']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



