// JavaScript Document
//加载进度
jQuery(window).load(function(){
	$("#page_loading_show").animate({width:"100%"},function(){
		setTimeout(function(){$("#page_loading").animate({opacity:'toggle'},800);},800);
	});
});

/*
$(document).ready(function(){
 	$('ul.thumb li').Zoomer({speedView:200,speedRemove:400,altAnim:true,speedTitle:400,debug:false});
});
*/

//标题伸缩
$(document).ready(function(){
	$('.post-title').live("click",function(){
		if($(this).next().is(':visible')){
			$(this).children().children().text("载入中......");
       		window.location = $(this).children().children().attr('href');
		}else{
			$('.post-content').slideUp(300);
			$(this).next().slideDown(500);
			$(this).next().slideDown(500, 
            function() {
                $body.animate({
                    scrollTop: $(this).offset().top - 200
                },400)});
            return false
        }
    });
	
	$('.post-title:first').click();
});

//AJAX无限翻页 By ImMmMm.com
jQuery(document).ready(function($){
	var $Id = 2;
	var Html = $('#post-home');
	var Load = $('#postlist .pagenavi');
	$('#postlist .pagenavi').live('click',function(){
		var Up = $(this).offset().top - 70 ;
		$.ajax({
			url: "?action=ajax_post&paged="+$Id,
			beforeSend: function(){
				Load.text('文章读取中... ');
			},
			success:function(a){
				$('html,body').animate({scrollTop: Up},800);
				Html.append(a);
				Load.text('更多文章')
			}
		});
		$Id++; //累加，是关键！
		return false;
	});
});

//访客资料滑动 
jQuery(document).ready(function(){
	$('#show_author_info').toggle(function(){
		$('#author_info').show(777);
	},function(){
		$('#author_info').hide(777);	
	});
});


//新窗口打开连接
$(document).ready(function(){
	$('.vcard a').attr({ target: "_blank"});
});

//回顶部
$(document).ready(function(){
	$('#back-to-top').click(function(){
		$('html,body').animate({scrollTop:'0px'},600);
		$('html,body').animate({scrollTop:'20px'},100);
		$('html,body').animate({scrollTop:'0px'},500);
		return false;
	});
});

//更多表情
jQuery(document).ready(function(){
	$('#morepics').hide();
	$('#morepic a').toggle(function(){
		$('#morepics').show(300).addClass("morepics");
		$(this).text('更少');
	},function(){
		$('#morepics').hide(300);
		$(this).text('更多');	
	});
});

//底部功能
$(document).ready(function(){
	//您的足迹
	$("#your-comments").click(function(){
		$("#myapps").hide(200);
		$("#ol").hide(200);
		$("#ycs").toggle(200);
		return false;
	});
	
	//我的应用
	$("#myapp").click(function(){
		$("#ycs").hide(200);
		$("#ol").hide(200);
		$("#myapps").toggle(200);
		return false;
	});
	
	//最近来访
	$("#online").click(function(){
		$("#ycs").hide(200);
		$("#myapps").hide(200);
		$("#ol").toggle(200);
		return false;
	});
	
});

//微薄滚动
$(document).ready(function(){
	$(".tsina a:not(:first)").css("display","none");
	var B=$(".tsina a:last");
	var C=$(".tsina a:first");
	setInterval(function(){
	if(B.is(":visible")){
	C.fadeIn(500).addClass("in");B.hide()
	}else{
	$(".tsina a:visible").addClass("in");
	$(".tsina a.in").next().fadeIn(500);
	$("a.in").hide().removeClass("in")}
	},7000) //每3秒钟切换一条，你可以根据需要更改
});


////得瑟
//$(document).ready(function(){
//	$('#menu ul li').bind({
//		mouseover:function(){$(this).removeClass("fds");$(this).addClass("ds");},
//		mouseout:function(){$(this).removeClass("ds");$(this).addClass("fds");}		
//	});
//	$('.fanr_most_active li').bind({
//		mouseover:function(){$(this).removeClass("fds");$(this).addClass("ds");},
//		mouseout:function(){$(this).removeClass("ds");$(this).addClass("fds");}		
//	});
//});

//LazyLoad
$(document).ready(function(){
	$("#commentlist .comment-author img").lazyload();
	$("img").lazyload();
});


//@回复
$(document).ready(function(){
	//某层数之后，点击回复输入框自动添加"@用户名" By ImMmMm.com
	$('.depth-1').children('.children').find('.reply').click(function(){ //class=".depth-8"子元素class=".children"下的class=".reply"的点击事件，注意：模板不同HTML结构可能不同，需调整！
		var rid= $(this).parent().attr("id"); //取得所回复的评论id，可能需要调整！
		var rna= $(this).next().next().text(); //取得所回复的评论用户名，可能需要调整！
		$("#comment").attr("value","<a href='#"+rid+"'>@"+rna+"</a> ").focus(); //在输入框添加"@用户名"和链接
	});
	$('#cancel-comment-reply-link').click(function() {
			$("#comment").attr("value",''); //点击取消回复时清空输入框
	});	
});

//上下滑动浮动效果
$(function() {
    var $sidebar   = $("#shangxia"),
        $window    = $(window),
        offset     = $sidebar.offset(),
        topPadding = 400;
    $window.scroll(function() {
        if ($window.scrollTop() > offset.top) {
            $sidebar.stop().animate({
                marginTop: $window.scrollTop() - offset.top + topPadding
            });
        } else {
            $sidebar.stop().animate({
                marginTop: 300
            });
        }
    });
}); 

//上下滚动
jQuery(document).ready(function($){
$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');//修复Opera滑动异常地，加过就不需要重复加了。
$('#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()},500);//直接取得页面高度，不再是手动指定页尾ID
});
$('#comt').click(function(){
	$body.animate({scrollTop:$('#comments').offset().top},500);//滑动到id=comments元素，遇到不规范的主题需调整
});
}); 
//下面部分放jQuery外围，几个数值不妨自行改变试试
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);
}


//标题滑动
jQuery(document).ready(function(){
	$(".post-title h2 a").live({
		mouseover:function(){$(this).animate({marginLeft:"15"},200);},
		mouseout:function(){$(this).animate({marginLeft:""},200);}
	});
});

////
//$(document).ready(function(){
//	$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');
//	$(".post-title").click(function(){
//		$body.animate({scrollTop:$(this).offset().top},1500);
//	});
//	
//});

//Google Favicon
jQuery(document).ready(function($){
$(".linkcat a").each(function(e){
	$(this).prepend("<img src=http://www.google.com/s2/favicons?domain="+this.href.replace(/^(http:\/\/[^\/]+).*$/, '$1').replace( 'http://', '' )+" style=float:left;padding:5px;>");
});
});



//网盘
jQuery(document).ready(function($){
$("#itemname a").click(function(){
	$('#itemb').hide(100).empty();
	var rss= "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q="+this.href+"/rss.xml&num=100&callback=?";
	$.getJSON(rss,function(json){
		$(json.responseData.feed.entries).each(function(i,dt){
			var title=dt.title,link=dt.link.replace("box.net", "boxcn.net"),cont=dt.content;
			var src="http://fanr.me/box/images/"+title.replace(/.*\.(.*)$/,'$1').toLowerCase()+".gif"
			$('#itemb').append("<div class='itemb'><div class='thumbb'><a href='"+link+"' title=''><img src='"+src+"'></a></div><div class='file'><div class='name'><a href='"+link+"' title=''>"+title+"</a></div><div class='info'>"+cont+"</div></div></div>");
		});
		$('#itemb').slideDown(300);
	});
	return false;
});
});


//Picasa相册
jQuery(document).ready(function($){
var name = "fanr001" //修改成你的Google用户名
var numx = 9; //每页显示相册数量
var top= $('#navi').offset().top-20; //页面刷动到分页，可修改
$body=(window.opera)?(document.compatMode=="CSS1Compat"?$('html'):$('body')):$('html,body');var href="https://picasaweb.google.com/data/feed/api/user/"+name;$.getJSON(href+"?fields=openSearch:totalResults&alt=json&callback=?",function(c){c=parseInt(c.feed.openSearch$totalResults.$t/numx)+1;for(var b=1;b<=c;){$("#navi").append("<a href='"+b+"'>   </a>  ");b++}$("#navi a").eq(1).addClass("current")});
$("#navi a").live("click",function(){$("#items").fadeOut(500);$(this).addClass("current").siblings().removeClass();var c=$(this).attr("href")-1;$.getJSON(href+"?start-index="+(numx*c+1)+"&max-results="+numx+"&fields=entry(title,gphoto:id,gphoto:numphotos,media:group(media:thumbnail))&alt=json&callback=?",function(b){$("#items").empty();$body.animate({scrollTop:top},400);$(b.feed.entry).each(function(g,d){var f=d.title.$t,e=d.gphoto$id.$t,n=d.gphoto$numphotos.$t,h=d.media$group.media$thumbnail[0].url;$("#items").append("<div class='item'><div class='thumb'><img src='"+
h+"' id='"+e+"'/><br /><span>"+f+" ("+n+")</span></div></div>")});$("#items").fadeIn(400)});return false});$("#navi a").click();
$(".thumb img").live("click",function(){$("#items").fadeOut(500);var c=$(this).attr("id");$.getJSON(href+"/albumid/"+c+"?fields=entry(media:group(media:content,media:title))&alt=json&callback=?",function(b){$("#items").empty();$body.animate({scrollTop:top},400);$(b.feed.entry).each(function(g,d){a=d.media$group;var f=a.media$title.$t,e=a.media$content[0].url;$("#items").append("<div class='item'><div class='thumb-1'><a href='"+e+"?imgmax=800'><img src='"+e+"?imgmax=118'/></a><br /><span>"+f+"</span></div></div>")});
$("#items").fadeIn(500);$(".thumb-1 a:has(img)").slimbox()});return false});
});


