jQuery(document).ready(function($){

//滚屏
$('#roll_top').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);}); 
$('#ct').click(function(){$('html,body').animate({scrollTop:$('#comments').offset().top}, 800);});
$('#fall').click(function(){$('html,body').animate({scrollTop:$('#footer').offset().top}, 800);});

//加载中提示 
$('.post-top h2 a').click(function(){
myloadoriginal = this.text;
$(this).text('[ Loading …… ]');
var myload = this;
 setTimeout(function() { $(myload).text(myloadoriginal); }, 2011);
});

//褪色
$('.infiniteCarousel ul img').hover(
function() {$(this).fadeTo("fast", 0.5);},
function() {$(this).fadeTo("fast", 1);
});

//延时图片
$(".entry img").lazyload ({
		placeholder : "http://fxpai.com/wp-content/themes/Fxpaicom/images/fill.gif",
		effect : "fadeIn",
		threshold : 2000
});

//菜单滚动置顶
$(window).scroll(function () {
	//获取滚动高度，兼容ie/ff和Chrome
	var st=document.documentElement.scrollTop + document.body.scrollTop;
	//判断滚动高度是否超过菜单位置高度
	if ( st >= 115 ) {
		$("#scroll-fix").css({
		"position":"fixed",
		"width":"960px",
		"z-index":"9998",
		"top":"0px"
		});
		//判断是否有wordpress顶部登录条
		if ( $("#wp-admin-bar-dashboard").length ) {
			if ( st >= 115 ) {
				$("#scroll-fix").css({
					"top":"28px"
				});
			}
		}
	//$("#scroll-fix").css("top" , 0 + document.documentElement.scrollTop - 100);
	} else {
		//恢复顶部位置后，还原position设置，并还原top数值
		$("#scroll-fix").css({
			"position":"relative",
			"top":"0px"
		});
	}
});

//鼠标悬停，图片滑动显示提示功能  测试
$("#infiniteCarousel").hover(
	function(){
		$(".infiniteCarousel-title").css('opacity','0.7');
		$(".infiniteCarousel-title").show(500);
	},
	function(){
		$(".infiniteCarousel-title").hide(500);
	});

//相册CSS深度定制
$(".gallery").has(".attachment-full").addClass("gallery-full");
$(".gallery").has(".attachment-medium").addClass("gallery-medium");
$(".gallery").has(".attachment-thumbnail").addClass("gallery-thumbnail");

//jquery辅助布局，masonry语句尾不得加逗号
$('.gallery-thumbnail').masonry({
	itemSelector: '.gallery-item'
});
$('#lens-masonry').masonry({
	itemSelector: '.post-lens'
});
$('#sidebar-bottom').masonry({
	itemSelector: '.widget',
	columnWidth: 115
});

//相册图片编号
	//按图片宽度，设定gallery-icon宽度，设gallery-icon为raletive布局
$(".gallery-icon").each(
	function(){
		var gallery_icon_width=$(this).find("img").width();
		$(this).width(gallery_icon_width);
	}
);
	//取得总图片数量，each遍历计算每张图片的序号，文字显示加入gallery-icon中
$(".gallery-item").each(
	function(i){
		i=i+1;
		var totle_num=$(".gallery-item").length;
		$(this).find(".gallery-icon").prepend("<span class=\"gallery-item-num-bg\">"+ i + "/" + totle_num +"</span><span class=\"gallery-item-num\">"+ i + "/" + totle_num +"</span>");
	}

);

//搜索框表单设置
$("#s").focus(function() {$(this).addClass("searchonfocus"), $(this).removeClass("searchonblur"), $(this).val("") }).blur(function() {$(this).removeClass("searchonfocus"), $(this).addClass("searchonblur"), $(this).val("SEARCH") });

//The Good Pic menu 展开设置 class=expation-button
var goodtopUlHeight=$(".header-tags ul").height();
$(".expation-button").toggle(
	//function() {$(".header-tags").append(goodtopUlHeight)},
	function(){
		$(".header-tags").animate(
			{height : goodtopUlHeight},"slow"
		);
		$(".expation-button").removeClass("expation-button-open").addClass("expation-button-close");
	},
	function(){$(".header-tags").animate(
			{height:"20px"},"slow"
		);
		$(".expation-button").removeClass("expation-button-close").addClass("expation-button-open");
	}
);

//结束
});
