﻿jQuery(document).ready(function(){
	if (document.getElementById("sidebar_main_right")) {scroll_sidebar(1000);}
});
var tb_pathToImage = "http://www.fineemb.com/wp-includes/js/thickbox/loadingAnimation.gif";
var tb_closeImage = "http://www.fineemb.com/wp-includes/js/thickbox/tb-close.png";
var thickboxL10n = {
	next: "下一张 >",
	prev: "< 上一张",
	image: "图像",
	of: "的",
	close: "关闭",
	noiframes: "这项功能需要 iframe。您停用了 iframe 功能或者您的浏览器不支持它。"
};
try{convertEntities(thickboxL10n);}catch(e){};

jQuery('.gotop').click(function(){jQuery('html,body').animate({scrollTop: '0px'}, 800);});
jQuery('.gobot').click(function(){$('html,body').animate({scrollTop:$('#footer').offset().top}, 800);});

////侧栏滑动 
 
function scroll_sidebar(duration){
        var sidebar = jQuery("#sidebar_main_right li").last();
			sidebar.css('z-index',200);
			sidebar.css('position','relative');
        var sidebar_top = sidebar.offset().top; 
		var sidebar_height = sidebar.height()+25;
		var document_height = jQuery(document).height();
		
		if(jQuery(window).height() > sidebar_height) {
			if(jQuery(window).scrollTop() > sidebar_top){ 
				sidebar.animate({top : jQuery(window).scrollTop() - sidebar_top  +"px" },{ duration:duration || 350 , queue:false }); 
			}
			jQuery(window).scroll(function (){
				var sidebart_height = sidebar.height()+25;
				if(jQuery(window).scrollTop() > sidebar_top ){ 
					if((sidebart_height+jQuery(window).scrollTop())>document_height-100){
						sidebar.animate({top : jQuery(window).scrollTop() - sidebar_top - ((sidebart_height+jQuery(window).scrollTop())-document_height+100) + 'px' },{ duration:duration || 350 , queue:false}); 	
					}else{
						sidebar.animate({top : jQuery(window).scrollTop() - sidebar_top  +"px" },{ duration:duration || 350 , queue:false });
					}					
				}else{
					sidebar.animate({top : 0 },{ duration:duration || 350 , queue:false}); 	
				}
			});
		}else{
			 var content = jQuery("#contentleft");
			 var content_top = content.offset().top; 
			 var content_height = content.height();
			 
			 if(content_height < sidebar_height + 10 ) {
			 	content_height = sidebar_height + 10;
			 }
			 
			if(jQuery(window).scrollTop() +  jQuery(window).height() > sidebar_top + 10 + sidebar_height){ 
				if(content_height +  content_top < jQuery(window).height() + jQuery(window).scrollTop()){
					sidebar.animate({top : content_height + content_top - sidebar_top  - sidebar_height - 10 + "px" },{ duration:duration || 350 , queue:false}); 
				} else {
					sidebar.animate({top : jQuery(window).scrollTop() +  jQuery(window).height() - sidebar_top -  sidebar_height - 10 + "px" },{ duration:duration || 350 , queue:false }); 
				}
			}
			
			jQuery(window).scroll(function (){
				sidebar_height = sidebar.height()+25;
				if(jQuery(window).scrollTop() + jQuery(window).height() > sidebar_top + sidebar_height ){
					if(content_height +  content_top < jQuery(window).height() + jQuery(window).scrollTop()){
						sidebar.animate({top : content_height + content_top - sidebar_top  - sidebar_height - 10 + "px" },{ duration:duration || 350 , queue:false}); 
					} else {
						sidebar.animate({top : jQuery(window).scrollTop() +  jQuery(window).height()- sidebar_top -  sidebar_height  -10 +"px" },{ duration:duration || 350 , queue:false }); 
					}
				}else{
					sidebar.animate({top : 0 },{ duration:duration || 350 , queue:false}); 
				}
			});
		} 
}

////wp-recentcomments


    try {
    window.external.msSiteModeCreateJumplist('Share Post');
    window.external.msSiteModeAddJumpListItem( "Qzone", "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="+encodeURIComponent(document.location.href),"http://ctc.qzs.qq.com/favicon.ico");
    window.external.msSiteModeShowJumplist(); 
    }
    catch (e) {
        //fall silently
    }
//share on    
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('网站名称'); // 网站名称
	var windowName = 'share'; // 子窗口别称
	var site = 'http://www.example.com/'; // 网站链接
 
	jQuery('#buzz-share').click(function() {
		var url = 'http://www.google.com/buzz/post?url=' + link ;
		var params = getParamsOfShareWindow(626, 436);
		window.open(url, windowName, params);
	});
	
	jQuery('#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);
	});
 
	jQuery('#twitter-share').click(function() {
		var url = 'http://twitter.com/share?url=' + link + '&text=' + title;
		var params = getParamsOfShareWindow(500, 375);
		window.open(url, windowName, params);
	});
 
	jQuery('#delicious-share').click(function() {
		var url = 'http://delicious.com/post?url=' + link + '&title=' + title;
		var params = getParamsOfShareWindow(550, 550);
		window.open(url, windowName, params);
	});
 
	jQuery('#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);
	});
 
	jQuery('#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);
	});
 
	jQuery('#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);
	});
 
	jQuery('#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);
	});
 
	jQuery('#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);
	});
 
	jQuery('#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);
	});
}
 
bindShareList();

///Google自定义搜索  
google.load('search', '1', {"nocss" : true });
google.setOnLoadCallback(function(){
var CSE = new google.search.CustomSearchControl('010898642726592824414:sla1nwkxgt0');
CSE.setResultSetSize(google.search.Search.SMALL_RESULTSET);
CSE.setSearchCompleteCallback(null, function() {
	jQuery('b:contains("...")').contents().unwrap();
	jQuery('.gsc-cursor-current-page').removeClass('gsc-cursor-page');
});
CSE.draw('cse');
}, true);

