function js_lastcom(obj){
	$(obj).find("ul:first").animate({marginTop:"-25px"},500,function(){$(this).css({marginTop:"0px"}).find("li:first").appendTo(this);});
}
$(document).ready(function(){
	jQuery('.menu').mousemove(function() {
        jQuery(this).find('.rolltu').show();
    });
    jQuery('.menu').mouseleave(function() {
        jQuery(this).find('.rolltu').hide();
    });
	jQuery('.article h2 a').click(function() {
        jQuery(this).text('努力打开中，请稍等...');
        window.location = jQuery(this).attr('href');
    });
	$(window).scroll(function() {
        var scroller = $('.rolltotop');
        document.documentElement.scrollTop + document.body.scrollTop > 800 ? scroller.fadeIn() : scroller.fadeOut();
    });
	$(window).scroll(function() {
        var scroller = $('.rolltofall');
        document.documentElement.scrollTop + document.body.scrollTop < 801 ? scroller.fadeIn() : scroller.fadeOut();
    });
	$('.ico-totop').click(function() {
        $('html,body').animate({
            scrollTop: 0
        },
        300);
    });
	$('.ico-torespond').click(function() {
        scrollTo('.ico-torespond');
        $('#comment').focus();
    });
	$('.ico-tofall').click(function() {
        $('html,body').animate({
            scrollTop: $('#footer').offset().top
        },
        300);
    });
	jQuery(".topnav ul li").hover(function() {
        jQuery(this).children("ul").show();
        jQuery(this).addClass("li01");
    },function() {
        jQuery(this).children("ul").hide();
        jQuery(this).removeClass("li01");
    });
	jQuery('#mp_email').click(function() {
        if ($('#mp_dingyue').css("display") == "none") {
            $("#mp_dingyue").toggle();
        } else {
            $("#mp_dingyue").toggle();
        }
    });
	jQuery('#tab_title span').mouseover(function() {
        jQuery(this).addClass("on").siblings().removeClass();
        jQuery("#tab_content > ul").eq(jQuery('#tab_title span').index(this)).fadeIn(650).siblings().hide();
    });
	jQuery('#close').click(function() {
        $("#placard").slideUp('slow');
    });
	jQuery('.thumbnail img').hover(function() {
        jQuery(this).fadeTo("fast", 0.5);
    },function() {
        jQuery(this).fadeTo("fast", 1);
    });
	$('#al_expand_collapse,#archives span.al_mon').css({
       cursor: "s-resize"
    });
    $('#archives span.al_mon').each(function() {
        var num = $(this).next().children('li').size();
        var text = $(this).text();
        $(this).html(text + '<em> ( ' + num + ' )</em>');
    });
    var $al_post_list = $('#archives ul.al_post_list'),$al_post_list_f = $('#archives ul.al_post_list:first');
    $al_post_list.hide(1,function() {$al_post_list_f.show();});
    $('#archives span.al_mon').click(function() {
        $(this).next().slideToggle(400);
        return false;
    });
    $('#al_expand_collapse').toggle(function() {
       $al_post_list.show();
    },function() {
       $al_post_list.hide();
    });
	$("a:not(.inactive)").each(function(m) {
		if (this.title) {
			var c = this.title;
            var a = 30;
            $(this).mouseover(function(d) {
				this.title = "";
                $("body").append('<div id="pre_a">' + c + "</div>");
                $("#pre_a").css({
					left: (d.pageX + a) + "px",
                    top: d.pageY + "px",
                    opacity: "0.7"
                }).fadeIn(250);
            }).mouseout(function() {
                this.title = c;
                $("#pre_a").remove();
            }).mousemove(function(d) {
                $("#pre_a").css({
                    left: (d.pageX + a) + "px",
                    top: d.pageY + "px"
                });
            });
        }else{
			var c = this.innerText;
			if(c!=null && c!=""){
				var a = 30;
				$(this).mouseover(function(d) {
					this.title = "";
					$("body").append('<div id="pre_a">' + c + "</div>");
					$("#pre_a").css({
						left: (d.pageX + a) + "px",
						top: d.pageY + "px",
						opacity: "0.7"
					}).fadeIn(250);
				}).mouseout(function() {
					this.title = c;
					$("#pre_a").remove();
				}).mousemove(function(d) {
					$("#pre_a").css({
						left: (d.pageX + a) + "px",
						top: d.pageY + "px"
					});
				});
			}
            
		}
    });
	jQuery("a[rel='external'],a[rel='external nofollow']").click(function() {
        window.open(this.href);
        return false;
    });
	jQuery('.icon1,.icon2,.icon3,.icon4,.icon5,.icon6,.icon7').wrapInner('<span class="hover"></span>').css('textIndent', '0').each(function() {
        jQuery('span.hover').css('opacity', 0).hover(function() {
            jQuery(this).stop().fadeTo(200, 1);
        },function() {
            jQuery(this).stop().fadeTo(1200, 0);
        });
    });
	$('.comment-reply-link').click(function() {
        var atname = $(this).parent().find('a:first').text();
        $("#comment").attr("value", "@" + atname).focus();
    });
    $('.mp_qx').click(function() {
        $("#comment").attr("value", '');
    });
	var myar=setInterval('js_lastcom("#mp_lastcom")',3600);
	$("#mp_lastcom").hover(function(){clearInterval(myar);},function(){myar = setInterval('js_lastcom("#mp_lastcom")',3600)});
	setFocusSlid('#focus_links','#slider_img_two',700,'h');
	
});

function single_pix(kuan) {
    var zhai = document.getElementById("stb_btn_zhai");
    var kuans = document.getElementById("stb_btn_kuan");
    var mai = document.getElementById("main");
    var sing = document.getElementById("single");
    var mp_sing = document.getElementById("mp_single");
    var card = document.getElementById("single_card");
    var rev = document.getElementById("review");
    var mp_rev = document.getElementById("mp_review");
    var sid = document.getElementById("sidebar");
    var bjwz = document.getElementById("stb_bjwz");
    if (kuan) {
        if (zhai) {
            zhai.style.display = "block";
        }
        if (kuans) {
            kuans.style.display = "none";
        }
        if (mai) {
            mai.style.width = "982px";
        }
        if (sing) {
            sing.style.width = "982px";
        }
        if (mp_sing) {
            mp_sing.style.width = "962px";
        }
        if (card) {
            card.style.width = "962px";
        }
        if (rev) {
            rev.style.width = "982px";
        }
        if (mp_rev) {
            mp_rev.style.width = "962px";
        }
        if (sid) {
            sid.style.display = "none";
        }
        if (bjwz) {
            bjwz.style.display = "block";
        }
    } else {
        if (zhai) {
            zhai.style.display = "none";
        }
        if (kuans) {
            kuans.style.display = "block";
        }
        if (mai) {
            mai.style.width = "700px";
        }
        if (sing) {
            sing.style.width = "700px";
        }
        if (mp_sing) {
            mp_sing.style.width = "680px";
        }
        if (card) {
            card.style.width = "680px";
        }
        if (rev) {
            rev.style.width = "700px";
        }
        if (mp_rev) {
            mp_rev.style.width = "680px";
        }
        if (sid) {
            sid.style.display = "block";
        }
        if (bjwz) {
            bjwz.style.display = "none";
        }
    }
}
function mp_single_size(size) {
    var zoom = document.all ? document.all['single_read'] : document.getElementById('single_read');
    zoom.style.fontSize = size + 'px';
}

function setFocusSlid(linksId,imgId,height,dir){
	var li=$(linksId).find('li');
	var count=li.length;
	var focusIndex=0;
	var focusInterval;
	var step=1;
	var slidover=function(){
		var li=$(linksId).find('li');
		li.removeClass('act');
		$(li[focusIndex]).addClass('act');
		$(imgId).stop();
		if(dir=='h'){
			$(imgId).animate({scrollLeft:height*focusIndex},500);
		}else{
			$(imgId).animate({scrollTop:height*focusIndex},500);
		}
	}
	var slidout=function(){focusInterval=setInterval(slidInterval,3000);}
	var slidInterval=function(){slidover();if(focusIndex==0){step=1;}
	if(focusIndex==count-1){step=-1;}focusIndex+=step;}
	li.each(function(i){
		$(this).hover(function(){
			clearInterval(focusInterval);
			focusIndex=i;
			slidover();
		},function(){
			slidout();
		});
	});
	focusIndex=1;
	slidout();
}