var HomepageFavorite = {

    //设为首页
    Homepage: function () {
        if (document.all) {
            document.body.style.behavior = 'url(#default#homepage)';
            document.body.setHomePage(window.location.href);
        }
        else if (window.sidebar) {
            if (window.netscape) {
                try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                }
                catch (e) {
                    alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
                    history.go(-1);   //这里我用firefox测试的时候出错，我把它注释掉，改成 return false;
                }
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', window.location.href);
        }
    },

    //加入收获
    Favorite: function Favorite(sURL, sTitle) {
        try {
            window.external.addFavorite(sURL, sTitle);
        }
        catch (e) {
            try {
                window.sidebar.addPanel(sTitle, sURL, "");
            }
            catch (e) {
                alert("加入收藏失败,请手动添加.");
            }
        }
    }
}//HomepageFavorite end;


function changeSize()//动态放大文字
{
	$(".entry-content *").animate({"fontSize":"+=4px","line-height":"+=4px"});
}

function changeSizeMinus()//动态放大文字
{
	$(".entry-content *").animate({fontSize:"-=4px","line-height":"-=4px"});
}



$(document).ready(function(){
//定义文章广告样式
$(".post blockquote").prepend("<span class='tt'>广告位</span>");

//侧边导航样式定义
$("#leftnav li ul:eq(0) a:last").css({'border':'none'});
$("#leftnav li ul:eq(1) a:last").css({'border':'none'});
$("#leftnav li ul:eq(3) a:last").css({'border':'none'});
$("#leftnav li ul:eq(4) a:last").css({'border':'none'});

//显示/隐藏搜索框
$(".topnav a:eq(2)").click(function(){
  $("#searchform").slideToggle();
  });

//动态放大/缩小文字+提示信息
$(".zoom").click(function(){
	changeSize();
	$(".zoomMinus span").html("+4px");
	$(".zoomMinus span").show(100);
	$(".zoomMinus span").animate({top:"-40px"},"slow");
	$(".zoomMinus span").fadeOut(200);
	$(".zoomMinus span").animate({top:"0"},"slow");
});
$(".minus").click(function(){
	changeSizeMinus();
	$(".zoomMinus span").html("-4px");
	$(".zoomMinus span").show(100);
	$(".zoomMinus span").animate({top:"-40px"},"slow");
	$(".zoomMinus span").fadeOut(200);
	$(".zoomMinus span").animate({top:"0"},"slow");
});


//在留言问题中添加　显示/隐藏
$("<span>　[ 回复：<a href='javascript:;' class='show'>查看</a>|<a href='javascript:;' class='hide'>隐藏</a>]</span>").appendTo(".comment p");


//显示/隐藏
$(".commentlist>li>ul").hide();
$li = $(".commentlist>li").length;
for (i=0;i<$li;i++)
{
show(i);
hide(i);
}

function show(i){
	$(".commentlist>li").eq(i).find("a.show").mousedown(function(){
      $(".commentlist>li").eq(i).find(">ul").slideDown(500);
    });
}
function hide(i){
	$(".commentlist>li").eq(i).find("a.hide").mousedown(function(){
      $(".commentlist>li").eq(i).find(">ul").slideUp(500);
    });
}

//Tab切换效果（首页/产品详细页）
$('.tab-content div:first').show();
$('.tab h2 span:first').addClass("current");
$('.tab h2 span').click(function(){ //鼠标移至 .tab-title 下的span标签时，触发
	$(this).addClass("current").siblings().removeClass(); //给当前的添加class="current"，并且让其同辈元素（即其余.tab-title span）移除class="current"；
	$(".tab-content>div").eq($(this).index()).show().siblings().hide(); //鼠标移至的span动态获这个的index值，并显示指定某个相同元素值的元素；并隐藏他的同辈同胞元素（即.tab-content ul）；
});

//底部导航第1个li去掉边距
$('#footnav li:first').css({"margin-left":"0"});


//左右层高度相等
var h1 = $("#home #secondary").height(); 
var h2 = $("#home #primary").height(); 
if(h1 < h2){ 
$("#home #secondary").height(h2); 
}else { 
$("#home #primary").height(h1); 
}
//产品页
var p1 = $("#primary").height(); 
var p2 = $(".category-products .widget-right").height(); 
if(p1 < p2){ 
$("#primary").height(p2); 
}else { 
$(".category-products .widget-right").height(p1); 
}
//新闻首页
var p1 = $(".news1").height(); 
var p2 = $(".news2").height(); 
if(p1 < p2){ 
$(".news1").height(p2); 
} else { 
$(".news2").height(p1);
}

//侧边
$('aside.widget h2').addClass("hr");
$('aside.widget h2:first').removeClass();
$('.join').prepend("<span class='top'></span>");

//9.2 无限同级元素伸缩 只保留当前展开
$(".service-home dt:first,.faqlist dt:first").addClass("nobk")
$(".service-home dt,.faqlist dt").click(function(){
	$(this).siblings().next("dd").slideUp("slow");//隐藏这个元素的同辈同胞元素的同级下一条dd元素并隐藏；
	$(this).next("dd").slideToggle("slow");//获得 (this) 这个元素下一条dd父元素并展开；
});

});
