﻿jQuery(document).ready(function($){
/* 幻灯片展示 */
	$(".paging").show();
	$(".paging a:first").addClass("active");
		var imageheight = $(".window").height();
	var imageSum = $(".image_reel img").size();
	var imageReelheight = imageheight * imageSum;
		$(".image_reel").css({'height' : imageReelheight});
		rotate = function(){	
		var triggerID = $active.attr("rel") - 1; 
		var image_reelPosition = triggerID * imageheight; 
		$(".paging a").removeClass('active'); 
		$active.addClass('active'); 
		$(".image_reel").animate({ 
			top: -image_reelPosition
		}, 600 );//切换速度		
	}; 
	rotateSwitch = function(){		
		play = setInterval(function(){ 
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { 
				$active = $('.paging a:first'); 
			}
			rotate();
		}, 5000); //间隔时间
	};	
	rotateSwitch(); 	
	$(".image_reel a").hover(function() {
		clearInterval(play); 
	}, function() {
		rotateSwitch(); 
	});		
	//On Click
	$(".paging a").click(function() {	
		$active = $(this); 
		clearInterval(play); 
		rotate(); 
		rotateSwitch();
		return false; 
	});	
/* 导航菜单 */
 	$('#trigger').click(function() {
		$(this).toggleClass('focus');
		$('#menu-li').animate({ height: 'toggle'}, 160);
		return false;
	});
/* tab切换 */	
   $(".tabContent ul:not(:first)").hide();
   $(".tabnavi span").each(function(index){
       $(this).click(
	   	  function(){
			  $(".tabnavi span.selected").removeClass("selected");
			  $(this).addClass("selected");
			  $(".tabContent > ul:visible").slideUp('800');
			  $(".tabContent ul:eq(" + index + ")").slideDown('800');
	  });
   });
/* 链接title提示 */ 
   $("a").mouseover(function(e){
	this.myTitle = this.title;
	this.myHref = this.href;
	this.myHref = (this.myHref.length > 30 ? this.myHref.toString().substring(0,30)+"..." : this.myHref);
	this.title = "";
	var tooltip = "<div id='tooltip'><p>"+this.myTitle+"<em>"+this.myHref+"</em>"+"</p></div>";
	$('body').append(tooltip);
	$('#tooltip').css({"opacity":"0","top":(e.pageY+20)+"px","left":(e.pageX+10)+"px"}).animate({opacity:"0.8"}, 600);
}).mouseout(function(){this.title = this.myTitle;$('#tooltip').remove();
}).mousemove(function(e){$('#tooltip').css({"top":(e.pageY+20)+"px","left":(e.pageX+10)+"px"});

});
/* 友接图标缓存 */ 
	$(".links a").each(function(e){
	$(this).prepend("<img src=http://www.google.com/s2/favicons?domain="+this.href.replace(/^(http:\/\/[^\/]+).*$/, '$1').replace( 'http://', '' )+" style=float:right;>");
});
/* 访客链接_blank */ 
	$('.fn a').attr({ target: "_blank"}); 

/* 显示关闭幻灯 */ 
	$('#close-huan a').toggle(function(){
	$(this).text("显示幻灯片");
		$('#slideshow').animate({ height: 'toggle'}, 360);
	},function(){
	$(this).text("关闭幻灯片");
		$('#slideshow').animate({ height: 'toggle'}, 360);
});
/* 显示关闭侧边栏 */ 
	$('#close-sidebar a').toggle(function(){
	$(this).text("显示侧边栏");
	$('#sidebar').hide();
	$('#shangxia').animate({left:"80%"}, 1000);
	$('#entries').animate({width: "920px"}, 1000);
	},function(){
	$(this).text("关闭侧边栏");
	$('#shangxia').animate({left:"50%"}, 1000);
	$('#entries').animate({width: "610px"}, 800, function(){$('#sidebar').show();});
});
/* 页面载入-平移 */ 
	$('.post-title').click(function(){
    $(this).text('页面载入中…');
    });
	$('#sidebar li a,.post-title a').hover(function() {
	$(this).stop().animate({'left': '5px'}, 'fast');
	}, function() {
	$(this).stop().animate({'left': '0px'}, 'fast');
});
/* 上下滑动 */ 
	var s= $('#shangxia').offset().top; 
	$(window).scroll(function (){ 
	$("#shangxia").animate({top : $(window).scrollTop() + s + "px" },{queue:false,duration:500});	
});
	$('#shang').click(function(){$('html,body').animate({scrollTop: '0px'}, 800);}); 
	$('#comt').click(function(){$('html,body').animate({scrollTop:$('#comments').offset().top}, 800);});
	$('#xia').click(function(){$('html,body').animate({scrollTop:$('#footer').offset().top}, 800);
});
/* 附件图标 */ 
	$("a[href$=.doc]").addClass("doc"); 
	$("a[href$=.pdf]").addClass("pdf"); 
	$("a[href$=.zip],a[href$=.7z]").addClass("zip"); 
	$(".post a[href^=http://www.box.net/]").addClass("box");
	$(".ffox_most_active a:not([href*=http://www.3anshi.com])").attr({ target: "_blank" });
	$(".post a:not([href*=http://www.3anshi.com])").attr({ target: "_blank" });
	$(".post a:not([href*=http://www.3anshi.com],[href*=http://pic.yupoo.com],[href*=http://www.box.net])").not(	"[href$=.pdf],[href$=.doc],[href$=.7z],[href$=.rar],[href$=.zip]").addClass("linkout");
	});
   
