$(document).ready(function() {
    if ($(".banner_box"))
        var pTimer = setInterval(pageTimeGo, 3000);
    if ($(".banner_box02"))
        var pTimer02 = setInterval(page02TimeGo, 3000);
    if ($(".banner_box03"))
        var pTimer03 = setInterval(page03TimeGo, 3000);

    $(".page a").mouseover(function() {
        clearInterval(pTimer);
        $(".page a").parent().removeClass("s");
        $(this).parent().attr("class", "s");
        var imgHeight = $(".banner_img img").height();
        var imgIndex = $(this).parent().index();
        $(".banner_box .banner_img_box").animate({ top: imgIndex * imgHeight * -1 + "px" }, 400);
    });

    $(".page .s").live("mouseout", function(event) {
        clearInterval(pTimer);
        pTimer = setInterval(pageTimeGo, 3000);
        event.preventDefault();
    });

    $(".page02 a").mouseover(function() {
        clearInterval(pTimer02);
        $(".banner_box02 .page02 a").parent().removeClass("s");
        $(this).parent().attr("class", "s");
        var imgHeight = $(".banner_box02 .banner_img img").height();
        var imgIndex = $(this).parent().index();
        $(".banner_box02 .banner_img_box").animate({ top: imgIndex * imgHeight * -1 + "px" }, 400);
    });

    $(".page02 .s").live("mouseout", function(event) {
        clearInterval(pTimer02);
        pTimer02 = setInterval(page02TimeGo, 3000);
        event.preventDefault();
    });

    $(".page03 a").mouseover(function() {
        clearInterval(pTimer03);
        $(".banner_box03 .page03 a").parent().removeClass("s");
        $(this).parent().attr("class", "s");
        var imgHeight = $(".banner_box03 .banner_img03 img").height();
        var imgIndex = $(this).parent().index();
        $(".banner_box03 .banner_img_box").animate({ top: imgIndex * imgHeight * -1 + "px" }, 400);
    });

    $(".page03 .s").live("mouseout", function(event) {
        clearInterval(pTimer03);
        pTimer03 = setInterval(page03TimeGo, 3000);
        event.preventDefault();
    });


    $(".bar_qiehuan span").mouseover(function() {
        if ($(this).attr("class") == "s")
            return;
        $(this).siblings("span").removeClass("s");
        $(this).addClass("s");
        var indexText = $(this).parent().attr("id");
        $("." + indexText + "_show").css("display", "none");
        $("." + indexText + "_show").eq($(this).index()).css("display", "block");
    });


});

var pageTimeGo = function() {
    var imgIndex = $(".banner_box .page .s").index();
    var imgHeight = $(".banner_box .banner_img img").height();
    if (imgIndex < $(".banner_box .page span").length - 1)
        imgIndex++;
    else
        imgIndex = 0;
    $(".banner_box .page a").parent().removeClass("s");
    $(".banner_box .page a").eq(imgIndex).parent().attr("class", "s");
    $(".banner_box .banner_img_box").animate({ top: imgIndex * imgHeight * -1 + "px" }, 500);
};

var page02TimeGo = function() {
    var imgIndex = $(".banner_box02 .page02 .s").index();
    var imgHeight = $(".banner_box02 .banner_img img").height();
    if (imgIndex < $(".banner_box02 .page02 span").length - 1)
        imgIndex++;
    else
        imgIndex = 0;
    $(".banner_box02 .page02 a").parent().removeClass("s");
    $(".banner_box02 .page02 a").eq(imgIndex).parent().attr("class", "s");
    $(".banner_box02 .banner_img_box").animate({ top: imgIndex * imgHeight * -1 + "px" }, 500);
};

var page03TimeGo = function() {
    var imgIndex = $(".banner_box03 .page03 .s").index();
    var imgHeight = $(".banner_box03 .banner_img03 img").height();
    //alert(imgIndex + "_" + imgHeight + "_" + imgIndex * imgHeight * -1);
    if (imgIndex < $(".banner_box03 .page03 span").length - 1)
        imgIndex++;
    else
        imgIndex = 0;
    //alert(imgIndex + "_" + imgHeight + "_" + imgIndex * imgHeight * -1);
    $(".banner_box03 .page03 a").parent().removeClass("s");
    $(".banner_box03 .page03 a").eq(imgIndex).parent().attr("class", "s");
    $(".banner_box03 .banner_img_box").animate({ top: imgIndex * imgHeight * -1 + "px" }, 500);
};

var show_tip =function(o,nom) {
	o.className = "sou_title sou_hover";
	$("#all_"+nom).show();
}

var hide_tip =function(o,nom) {
	o.className = "sou_title";
	$("#all_"+nom).hide();
}
 
