
$(".m_label").click(function () {
    $(this).hide();
    $(this).siblings(".m_input").focus();
});
$(".m_input").focus(function () {
    $(this).siblings(".m_label").hide();
});
$(".m_input").blur(function () {
    if ($(this).val() == '') {
        $(this).siblings(".m_label").show();
    }
});
$(".m_input").each(function () {
    if ($(this).val() != '') {
        $(this).siblings(".m_label").hide();
    }
});

$(".paging_num > a").click(function () {
    var index = $(this).index();
    location.hash = index + 1;
    var hash = location.hash;
    $(".total .paging").eq(hash.slice(1) - 1).css("display", "block").siblings().css("display", "none");
    $(this).addClass("paging_hover").siblings().removeClass("paging_hover");
});
var hash = location.hash;
if (!hash) {
    $(".total .paging").eq(0).css("display", "block").siblings().css("display", "none");
} else {
    $(".total .paging").eq(hash.slice(1) - 1).css("display", "block").siblings().css("display", "none");
    $(".paging_num > a").eq(hash.slice(1) - 1).addClass("paging_hover").siblings().removeClass("paging_hover");
}

function SetHome(obj, vrl) {
    try {
        obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
    }
    catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            } catch (e) {
                alert("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”，点击“加入收藏”后忽略安全提示，即可设置成功。");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', vrl);
        } else {
            alert('抱歉，您的浏览器不支持自动设置首页, 请使用浏览器菜单手动设置!');
        }
    }
}


function bb1() {
    var nav_num = '';
    var obj_li = $(".bb li");
    var count = obj_li.length;
    obj_li.first().css("display", "block");
    obj_li.each(function () {
        var index = $(this).index() + 1;
        nav_num += '<li><a href="javascript:void(0)">' + index + '</a></li>';
    });
    $(".banner").append('<ul class="num">' + nav_num + '</ul>');
    $(".num li").first().addClass("num_hover");
    $(".num li").hover(function () {
        sw = $(".num li").index(this);
        myShow(sw);
    });
    function myShow(i) {
        $(".num li").eq(i).addClass("num_hover").siblings().removeClass("num_hover");
        obj_li.eq(i).stop(true, true).fadeIn(600).siblings("li").fadeOut(600);
    }
    var myTime = 0;

    $(".bb").hover(function () {
        if (myTime) {
            clearInterval(myTime);
        }
    }, function () {
        myTime = setInterval(function () {
            myShow(sw);
            sw++;
            if (sw == count) {
                sw = 0;
            }
        }, 3000);
    });
    
    var sw = 0;
    myTime = setInterval(function () {
        myShow(sw);
        sw++;
        if (sw == count) {
            sw = 0;
        }
    }, 2000);
}


function bb2() {
    var sWidth = $("#focus").width(); 
    var len = $("#focus ul li").length; 
    var index = 0;
    var picTimer = 0;
    
    var btn = "<div class='btnBg'></div><div class='btn'>";
    for (var i = 0; i < len; i++) {
        btn += "<span></span>";
    }
    btn += "</div>";
    $("#focus").append(btn);
    $("#focus .btnBg").css("opacity", 0.5);
    $("#focus .btnBg").css("filter", "alpha(opacity=60)");
    
    $("#focus .btn span").css("opacity", 0.4).mouseenter(function () {
        index = $("#focus .btn span").index(this);
        showPics(index);
    }).eq(0).trigger("mouseenter");
    
    $("#focus .pre").click(function () {
        index -= 1;
        if (index == -1) { index = len - 1; }
        showPics(index);
    });
    
    $("#focus .next").click(function () {
        index += 1;
        if (index == len) { index = 0; }
        showPics(index);
    });
    
    $("#focus ul").css("width", sWidth * (len));
    
    $("#focus").hover(function () {
        clearInterval(picTimer);
    }, function () {
        picTimer = setInterval(function () {
            showPics(index);
            index++;
            if (index == len) { index = 0; }
        }, 4000); 
    }).trigger("mouseleave");

    
    function showPics(index) { 
        var nowLeft = -index * sWidth; 
        $("#focus ul").stop(true, false).animate({ "left": nowLeft }, 300); 
        $("#focus .btn span").stop(true, false).animate({ "opacity": "0.4" }, 300).eq(index).stop(true, false).animate({ "opacity": "1" }, 300); 
    }
}


function tabs(tabs, tab_box, _event) {
    $(tab_box).hide();
    $(tab_box).eq(0).show();
    $(tabs).find('li:eq(0)').addClass('cur');
    $(tabs).find("li").bind(_event, function () {
        $(this).addClass("cur").siblings("li").removeClass("cur");
        var _index = $(this).index();
        $(tab_box).eq(_index).show().siblings(tab_box).hide();
    });
};



function scroll() {
    
    var speed = 30; 
    var tab = document.getElementById("demo");
    var tab1 = document.getElementById("demo1");
    var tab2 = document.getElementById("demo2");
    var liwidth = tab1.getElementsByTagName("li");
    var liwidths = liwidth[0].offsetWidth;
    var length = $("#demo1 li").length;
    var mleft = parseInt($("#demo1 li:eq(0)").css("marginLeft"));
    var mright = parseInt($("#demo1 li:eq(0)").css("marginRight"));
    var totalwidth = (liwidths + mleft + mright) * length * 2 + 300;
    $("#indemo").width(totalwidth);
    tab2.innerHTML = tab1.innerHTML;
    function Marquee() {
        if (tab2.offsetWidth - tab.scrollLeft <= 0)
            tab.scrollLeft -= tab1.offsetWidth;
        else {
            tab.scrollLeft++;
        }
    }
    var MyMar = setInterval(Marquee, speed);

    tab.onmouseover = function () {
        clearInterval(MyMar);
    };
    tab.onmouseout = function () {
        MyMar = setInterval(Marquee, speed);
    };
}


function scroll2() {
    
    var speed = 30; 
    var tab = document.getElementById("m_demo");
    var tab1 = document.getElementById("m_demo1");
    var tab2 = document.getElementById("m_demo2");
    var liwidth = tab1.getElementsByTagName("li");
    var liwidths = liwidth[0].offsetWidth;
    var length = $("#m_demo1 li").length;
    var mleft = parseInt($("#m_demo1 li:eq(0)").css("marginLeft"));
    var mright = parseInt($("#m_demo1 li:eq(0)").css("marginRight"));
    var totalwidth = (liwidths + mleft + mright) * length * 2 + 300;
    $("#m_indemo").width(totalwidth);
    tab2.innerHTML = tab1.innerHTML;
    function Marquee() {
        if (tab2.offsetWidth - tab.scrollLeft <= 0)
            tab.scrollLeft -= tab1.offsetWidth;
        else {
            tab.scrollLeft++;
        }
    }
    var MyMar = setInterval(Marquee, speed);

    tab.onmouseover = function () {
        clearInterval(MyMar);
    };
    tab.onmouseout = function () {
        MyMar = setInterval(Marquee, speed);
    };
}







function kehu_top() {
    
    var speed = 60; 
    var tab = document.getElementById("kehu");
    var tab1 = document.getElementById("zheng");
    var tab2 = document.getElementById("xtop");
    tab2.innerHTML = tab1.innerHTML;

    function Marquee() {
        if (tab2.offsetHeight - tab.scrollTop <= 0) {
            tab.scrollTop = 0;
        } else {
            var tmp = tab.scrollTop;
            tab.scrollTop++;
            if (tab.scrollTop == tmp) {
                tab.scrollTop = 1;
            }
        }
    }
    var MyMar = setInterval(Marquee, speed);

    tab.onmouseover = function () {
        clearInterval(MyMar);
    };
    tab.onmouseout = function () {
        MyMar = setInterval(Marquee, speed);
    };
}
